public final void run() { // background activity gets system credential, // just like executors get it. HudsonSecurityManager.grantFullControl(); try { doRun(); } catch (Throwable t) { LOGGER.log(Level.SEVERE, "Timer task " + this + " failed", t); } finally { HudsonSecurityManager.resetFullControl(); } }
@Override public void checkPermission(Permission permission) { HudsonSecurityEntitiesHolder.getHudsonSecurityManager().checkPermission(permission); }
/** * Logs out the user. */ public void doLogout(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException { getSecurityManager().doLogout(req, rsp); }
HudsonSecurityManager.grantFullControl(); try { this.root = root; int slaveAgentPort = HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getSlaveAgentPort(); HudsonSecurityManager.resetFullControl();
@Override public void run() { try { HudsonSecurityManager.grantFullControl(); reload(); } catch (IOException e) { logger.error("Failed to reload Hudson config", e); } catch (ReactorException e) { logger.error("Failed to reload Hudson config", e); } catch (InterruptedException e) { logger.error("Failed to reload Hudson config", e); } } }.start();
/** * Checks if the current user is anonymous. */ public static boolean isAnonymous() { return HudsonSecurityManager.getAuthentication() instanceof AnonymousAuthenticationToken; }
BulkChange bc = new BulkChange(this); try { checkPermission(Permission.HUDSON_ADMINISTER); if (!isUseSecurity() || v == null || v.equals("random")) { slaveAgentPort = 0; } else if (v.equals("disable")) { Hudson.getInstance().setSlaveAgentPort(slaveAgentPort); setSecurityRealm(SecurityRealm.all().newInstanceFromRadioList(security, "realm")); setAuthorizationStrategy(AuthorizationStrategy.all().newInstanceFromRadioList(security, "authorization")); setSecurityRealm(SecurityRealm.NO_AUTHENTICATION); authorizationStrategy = AuthorizationStrategy.UNSECURED;
/** * @return never null. */ public AuthorizationStrategy getAuthorizationStrategy() { return getSecurityManager().getAuthorizationStrategy(); }
XmlFile config = getConfigFile(); try { if (config.exists()) { } else { if (extractSecurityConfig()) { config.unmarshal(this); setSecurityRealm(SecurityRealm.NO_AUTHENTICATION); } else { setSecurityRealm(new LegacySecurityRealm()); setSecurityRealm(securityRealm); setSecurityRealm(SecurityRealm.NO_AUTHENTICATION);
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); }
/** * Short for {@code getACL().checkPermission(p)} */ public void checkPermission(Permission p) { getACL().checkPermission(p); }
/** * Save the settings to the configuration file. */ public synchronized void save() throws IOException { if (BulkChange.contains(this)) { return; } getConfigFile().write(this); SaveableListener.fireOnChange(this, getConfigFile()); }
@Override public void run() { try { HudsonSecurityManager.grantFullControl(); // give some time for the browser to load the "reloading" page Thread.sleep(5000); logger.error(String.format("Restarting VM as requested by %s", exitUser)); for (RestartListener listener : RestartListener.all()) { listener.onRestart(); } lifecycle.restart(); } catch (InterruptedException e) { logger.warn("Failed to restart Hudson", e); } catch (IOException e) { logger.warn("Failed to restart Hudson", e); } } }.start();
/** * @deprecated As of release 3.0.0, replaced by * {@link HudsonSecurityManager#getAuthentication()} */ @Deprecated public static Authentication getAuthentication() { return HudsonSecurityManager.getAuthentication(); }
@Override public boolean isApplicable(Class<? extends Job> jobType) { // only applicable when ProjectMatrixAuthorizationStrategy is in charge return HudsonSecurityEntitiesHolder.getHudsonSecurityManager().getAuthorizationStrategy() instanceof ProjectMatrixAuthorizationStrategy; }
@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)); } } }
/** * Short for {@code getACL().hasPermission(p)} */ public boolean hasPermission(Permission p) { return getACL().hasPermission(p); }
/** * Sets the thread name to the task for better diagnostics. */ @Override protected void runTask(Task task) throws Exception { if (is != null && is.skipInitTask(task)) { return; } // full access in the initialization thread HudsonSecurityManager.grantFullControl(); String taskName = task.getDisplayName(); Thread t = Thread.currentThread(); String name = t.getName(); if (taskName != null) { t.setName(taskName); } try { long start = System.currentTimeMillis(); super.runTask(task); if (LOG_STARTUP_PERFORMANCE) { logger.info(String.format("Took %dms for %s by %s", System.currentTimeMillis() - start, taskName, name)); } } finally { t.setName(name); HudsonSecurityManager.resetFullControl(); } } };
@Override public void run() { try { HudsonSecurityManager.grantFullControl(); logger.error(String.format("Shutting down VM as requested by %s from %s", exitUser, exitAddr)); // Wait 'til we have no active executors. while (isQuietingDown && (overallLoad.computeTotalExecutors() > overallLoad.computeIdleExecutors())) { Thread.sleep(5000); } // Make sure isQuietingDown is still true. if (isQuietingDown) { cleanUp(); System.exit(0); } } catch (InterruptedException e) { logger.warn("Failed to shutdown Hudson", e); } } }.start();