/** * Gets the {@link HudsonFilter} created for the given * {@link ServletContext}. */ public static HudsonFilter get(ServletContext context) { // As of 3.0.0 we no longer set it to the context return HudsonSecurityEntitiesHolder.getHudsonSecurityFilter(); }
public InitialSetupLogin(InitialSetup initSetup) { initialSetup = initSetup; hudsonSecurityManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; HudsonSecurityManager hudsonSecurityManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); try { SecurityRealm securityRealm = hudsonSecurityManager.getSecurityRealm(); reset(securityRealm); logger.debug("securityRealm is {}", securityRealm); logger.debug("Security initialized"); } catch (Exception exc) { // see HUDSON-4592. In some containers this happens before // WebAppMain.contextInitialized kicks in, which makes // the whole thing fail hard before a nicer error check // in WebAppMain.contextInitialized. So for now, // just report it here, and let the WebAppMain handle the failure gracefully. logger.error("Failed to initialize Hudson", exc); } // This is how we make this security filter available to the rest of Hudson. HudsonSecurityEntitiesHolder.setHudsonSecurityFilter(this); }
HudsonSecurityEntitiesHolder.setHudsonSecurityManager(new HudsonSecurityManager(home)); } catch (Exception ex) { ex.printStackTrace(); if (initSetup.needsInitSetup()) { logger.info("\n\n\n================>\n\nInitial setup required. Please go to the Hudson Dashboard and complete the setup.\n\n<================\n\n\n"); if (HudsonSecurityEntitiesHolder.getHudsonSecurityManager().isUseSecurity() && !securityLoadFailed) { controller.install(new InitialSetupLogin(initSetup)); } else {
/** * Creates a new instance of {@link Hudson}. If the derived class wants to * create it in a different way, you can override it. */ protected Hudson newHudson() throws Exception { File home = homeLoader.allocate(); // Create the Security Manager HudsonSecurityEntitiesHolder.setHudsonSecurityManager(new HudsonSecurityManager(home)); for (Runner r : recipes) { r.decorateHome(this, home); } return new Hudson(home, createWebServer(), useLocalPluginManager ? null : TestPluginManager.INSTANCE); }
@Override public void run() { try { // Creating of the god object performs most of the booting muck Hudson hudson = new Hudson(hudsonHomeDir, servletContext, null, restart); //Now Hudson is fully loaded, reload Hudson Security Manager HudsonSecurityEntitiesHolder.setHudsonSecurityManager(new HudsonSecurityManager(hudsonHomeDir)); // once its done, hook up to stapler and things should be ready to go controller.install(hudson); // trigger the loading of changelogs in the background, // but give the system 10 seconds so that the first page // can be served quickly // Trigger.timer.schedule(new SafeTimerTask() { // public void doRun() { // User.getUnknown().getBuilds(); // } // }, 1000 * 10); } catch (Error e) { logger.error("Failed to initialize Hudson", e); controller.install(new HudsonFailedToLoad(e)); throw e; } catch (Exception e) { logger.error("Failed to initialize Hudson", e); controller.install(new HudsonFailedToLoad(e)); } } }
public HudsonSecurityManager getSecurityManager() { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); }
/** * Set a Security Realm to the Manager * * @param securityRealm */ public void setSecurityRealm(SecurityRealm securityRealm) { if (securityRealm == null) { securityRealm = SecurityRealm.NO_AUTHENTICATION; } this.securityRealm = securityRealm; // reset the filters and proxies for the new SecurityRealm try { HudsonFilter filter = HudsonSecurityEntitiesHolder.getHudsonSecurityFilter(); if (filter == null) { // Fix for #3069: This filter is not necessarily initialized before the servlets. // when HudsonFilter does come back, it'll initialize itself. logger.debug("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { logger.debug("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); logger.debug("Security is now fully set up"); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new RuntimeException("Failed to configure filter", e) { }; } }
/** * Gets the directory where the user information is stored. */ private static File getRootDir() { return new File(HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getHudsonHome(), "users"); }
private TeamAwareSecurityRealm getTeamAwareSecurityRealm() { HudsonSecurityManager hudsonSecurityManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); if (hudsonSecurityManager != null) { SecurityRealm securityRealm = hudsonSecurityManager.getSecurityRealm(); if ((securityRealm != null) && securityRealm instanceof TeamAwareSecurityRealm) { return (TeamAwareSecurityRealm) securityRealm; } } return null; }
/** * If the security is not enabled, there's no point in having this type * of views. */ @Override public boolean isInstantiable() { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().isUseSecurity(); }
@Override public boolean isApplicable(Class<? extends Job> jobType) { // only applicable when ProjectMatrixAuthorizationStrategy is in charge return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getAuthorizationStrategy() instanceof ProjectMatrixAuthorizationStrategy; }
public TeamManager getTeamManager() { if (teamManager == null) { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getTeamManager(); } else { return teamManager; } }
@Override public void checkPermission(Permission permission) { HudsonSecurityEntitiesHolder.getHudsonSecurityManager().checkPermission(permission); }
private TeamManager getTeamManager() { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getTeamManager(); } }
private boolean isTeamAwareSecurityRealm() { HudsonSecurityManager hudsonSecurityManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); SecurityRealm securityRealm = null; if (hudsonSecurityManager != null) { securityRealm = hudsonSecurityManager.getSecurityRealm(); } if ((securityRealm != null) && securityRealm instanceof TeamAwareSecurityRealm) { return true; } return false; } }
public boolean isTeamManagementEnabled() { HudsonSecurityManager hudsonSecurityManager = HudsonSecurityEntitiesHolder.getHudsonSecurityManager(); if (hudsonSecurityManager != null) { AuthorizationStrategy authorizationStrategy = hudsonSecurityManager.getAuthorizationStrategy(); if (authorizationStrategy instanceof TeamBasedAuthorizationStrategy) { return true; } } return false; }
@Override public String getIconFileName() { if (HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getSecurityRealm() instanceof HudsonPrivateSecurityRealm) { return "user.png"; } else { return null; // not applicable now } }
private TeamManager getTeamManager() { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getTeamManager(); } }
@Override public boolean isEnabled() { return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getSecurityRealm() instanceof HudsonPrivateSecurityRealm; }