public void setSecurityRealm(SecurityRealm securityRealm) { if(securityRealm==null) securityRealm= SecurityRealm.NO_AUTHENTICATION; this.useSecurity = true; IdStrategy oldUserIdStrategy = this.securityRealm == null ? securityRealm.getUserIdStrategy() // don't trigger rekey on Jenkins load : this.securityRealm.getUserIdStrategy(); this.securityRealm = securityRealm; // reset the filters and proxies for the new SecurityRealm try { HudsonFilter filter = HudsonFilter.get(servletContext); 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.fine("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { LOGGER.fine("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); LOGGER.fine("Security is now fully set up"); } if (!oldUserIdStrategy.equals(this.securityRealm.getUserIdStrategy())) { User.rekey(); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new AcegiSecurityException("Failed to configure filter",e) {}; } saveQuietly(); }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; // this is how we make us available to the rest of Hudson. filterConfig.getServletContext().setAttribute(HudsonFilter.class.getName(),this); try { Jenkins hudson = Jenkins.getInstanceOrNull(); if (hudson != null) { // looks like we are initialized after Hudson came into being. initialize it now. See #3069 LOGGER.fine("Security wasn't initialized; Initializing it..."); SecurityRealm securityRealm = hudson.getSecurityRealm(); reset(securityRealm); LOGGER.fine("securityRealm is " + securityRealm); LOGGER.fine("Security initialized"); } } catch (ExceptionInInitializerError e) { // 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.log(SEVERE, "Failed to initialize Jenkins",e); } }
private boolean isReady() { // Hudson does not give us a nice InitMilestone when its really ready, // but if its not yet COMPLETED, don't bother trying to figure out more if (hudson.getInitLevel() != InitMilestone.COMPLETED) { return false; } HudsonFilter filter = HudsonFilter.get(hudson.servletContext); if (filter == null) { return false; } // Need to get access to the filter's filter field to see if its actually initialized or not // it does not expose it directly, so we have to use reflection to force access Filter delegate = getDelegate(filter); if (delegate == null) { return false; } // At this point we _should_ be ready, see if the app root object is installed... fingers crossed! try { Object app = controller.current(); // FIXME: This may actually be the only check needed? return app instanceof hudson.model.Hudson; } catch (IllegalStateException e) { return false; // context not yet available } }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; // this is how we make us available to the rest of Hudson. filterConfig.getServletContext().setAttribute(HudsonFilter.class.getName(),this); try { Jenkins hudson = Jenkins.getInstanceOrNull(); if (hudson != null) { // looks like we are initialized after Hudson came into being. initialize it now. See #3069 LOGGER.fine("Security wasn't initialized; Initializing it..."); SecurityRealm securityRealm = hudson.getSecurityRealm(); reset(securityRealm); LOGGER.fine("securityRealm is " + securityRealm); LOGGER.fine("Security initialized"); } } catch (ExceptionInInitializerError e) { // 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.log(SEVERE, "Failed to initialize Jenkins",e); } }
private boolean isReady() { // Hudson does not give us a nice InitMilestone when its really ready, // but if its not yet COMPLETED, don't bother trying to figure out more if (hudson.getInitLevel() != InitMilestone.COMPLETED) { return false; } HudsonFilter filter = HudsonFilter.get(hudson.servletContext); if (filter == null) { return false; } // Need to get access to the filter's filter field to see if its actually initialized or not // it does not expose it directly, so we have to use reflection to force access Filter delegate = getDelegate(filter); if (delegate == null) { return false; } // At this point we _should_ be ready, see if the app root object is installed... fingers crossed! try { Object app = controller.current(); // FIXME: This may actually be the only check needed? return app instanceof hudson.model.Hudson; } catch (IllegalStateException e) { return false; // context not yet available } }
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 = HudsonFilter.get(servletContext); 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.fine("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { LOGGER.fine("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); LOGGER.fine("Security is now fully set up"); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new SpringSecurityException("Failed to configure filter", e) { }; } }
/** * 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) { }; } }
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 = HudsonFilter.get(servletContext); 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.fine("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { LOGGER.fine("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); LOGGER.fine("Security is now fully set up"); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new AcegiSecurityException("Failed to configure filter", e) { }; } }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; // this is how we make us available to the rest of Hudson. filterConfig.getServletContext().setAttribute(HudsonFilter.class.getName(),this); try { Hudson hudson = Hudson.getInstance(); if (hudson != null) { // looks like we are initialized after Hudson came into being. initialize it now. See #3069 LOGGER.fine("Security wasn't initialized; Initializing it..."); SecurityRealm securityRealm = hudson.getSecurityRealm(); reset(securityRealm); LOGGER.fine("securityRealm is " + securityRealm); LOGGER.fine("Security initialized"); } } catch (ExceptionInInitializerError e) { // 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.log(SEVERE, "Failed to initialize Hudson",e); } }
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 = HudsonFilter.get(servletContext); 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.fine("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { LOGGER.fine("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); LOGGER.fine("Security is now fully set up"); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new AcegiSecurityException("Failed to configure filter", e) { }; } }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; // this is how we make us available to the rest of Hudson. filterConfig.getServletContext().setAttribute(HudsonFilter.class.getName(),this); try { Hudson hudson = Hudson.getInstance(); if (hudson != null) { // looks like we are initialized after Hudson came into being. initialize it now. See #3069 LOGGER.fine("Security wasn't initialized; Initializing it..."); SecurityRealm securityRealm = hudson.getSecurityRealm(); reset(securityRealm); LOGGER.fine("securityRealm is " + securityRealm); LOGGER.fine("Security initialized"); } } catch (ExceptionInInitializerError e) { // 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.log(SEVERE, "Failed to initialize Hudson",e); } }
public void setSecurityRealm(SecurityRealm securityRealm) { if(securityRealm==null) securityRealm= SecurityRealm.NO_AUTHENTICATION; this.useSecurity = true; IdStrategy oldUserIdStrategy = this.securityRealm == null ? securityRealm.getUserIdStrategy() // don't trigger rekey on Jenkins load : this.securityRealm.getUserIdStrategy(); this.securityRealm = securityRealm; // reset the filters and proxies for the new SecurityRealm try { HudsonFilter filter = HudsonFilter.get(servletContext); 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.fine("HudsonFilter has not yet been initialized: Can't perform security setup for now"); } else { LOGGER.fine("HudsonFilter has been previously initialized: Setting security up"); filter.reset(securityRealm); LOGGER.fine("Security is now fully set up"); } if (!oldUserIdStrategy.equals(this.securityRealm.getUserIdStrategy())) { User.rekey(); } } catch (ServletException e) { // for binary compatibility, this method cannot throw a checked exception throw new AcegiSecurityException("Failed to configure filter",e) {}; } saveQuietly(); }
public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; // this is how we make us available to the rest of Hudson. filterConfig.getServletContext().setAttribute(HudsonFilter.class.getName(),this); try { Hudson hudson = Hudson.getInstance(); if (hudson != null) { // looks like we are initialized after Hudson came into being. initialize it now. See #3069 LOGGER.fine("Security wasn't initialized; Initializing it..."); SecurityRealm securityRealm = hudson.getSecurityRealm(); reset(securityRealm); LOGGER.fine("securityRealm is " + securityRealm); LOGGER.fine("Security initialized"); } } catch (ExceptionInInitializerError e) { // 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.log(SEVERE, "Failed to initialize Hudson",e); } }
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); }