public int main(List<String> args, Locale locale, InputStream stdin, OutputStream stdout, OutputStream stderr) { // remoting sets the context classloader to the RemoteClassLoader, // which slows down the classloading. we don't load anything from CLI, // so counter that effect. Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); PrintStream out = new PrintStream(stdout); PrintStream err = new PrintStream(stderr); String subCmd = args.get(0); CLICommand cmd = CLICommand.clone(subCmd); if(cmd!=null) { cmd.channel = Channel.current(); final CLICommand old = CLICommand.setCurrent(cmd); try { transportAuth = Channel.currentOrFail().getProperty(CLICommand.TRANSPORT_AUTHENTICATION); cmd.setTransportAuth(transportAuth); return cmd.main(args.subList(1,args.size()),locale, stdin, out, err); } finally { CLICommand.setCurrent(old); } } err.println("No such command: "+subCmd); new HelpCommand().main(Collections.emptyList(), locale, stdin, out, err); return -1; }
return; command.setTransportAuth(Jenkins.getAuthentication()); command.setClientCharset(connection.encoding); CLICommand orig = CLICommand.setCurrent(command);
public void superSetTransportAuth(Authentication transportAuth) { super.setTransportAuth(transportAuth); }
/** * Run the command as a given username. * Test setup should have first defined a meaningful security realm and authorization strategy. * @see Jenkins#setSecurityRealm * @see JenkinsRule#createDummySecurityRealm * @see Jenkins#setAuthorizationStrategy * @see MockAuthorizationStrategy */ public CLICommandInvoker asUser(String user) { command.setTransportAuth(User.get(user).impersonate()); return this; }
@Override public void setTransportAuth(Authentication transportAuth) { initPython(); if (pexec.isImplemented(6)) { pexec.execPythonVoid("set_transport_auth", transportAuth); } else { super.setTransportAuth(transportAuth); } }
public int main(List<String> args, Locale locale, InputStream stdin, OutputStream stdout, OutputStream stderr) { // remoting sets the context classloader to the RemoteClassLoader, // which slows down the classloading. we don't load anything from CLI, // so counter that effect. Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); PrintStream out = new PrintStream(stdout); PrintStream err = new PrintStream(stderr); String subCmd = args.get(0); CLICommand cmd = CLICommand.clone(subCmd); if(cmd!=null) { cmd.channel = Channel.current(); final CLICommand old = CLICommand.setCurrent(cmd); try { transportAuth = Channel.current().getProperty(CLICommand.TRANSPORT_AUTHENTICATION); cmd.setTransportAuth(transportAuth); return cmd.main(args.subList(1,args.size()),locale, stdin, out, err); } finally { CLICommand.setCurrent(old); } } err.println("No such command: "+subCmd); new HelpCommand().main(Collections.<String>emptyList(), locale, stdin, out, err); return -1; }
return; command.setTransportAuth(Jenkins.getAuthentication()); command.setClientCharset(connection.encoding); CLICommand orig = CLICommand.setCurrent(command);
private void setAuth() { if (permissions.isEmpty()) return; JenkinsRule.DummySecurityRealm realm = rule.createDummySecurityRealm(); realm.addGroups(username, "group"); originalSecurityRealm = rule.jenkins.getSecurityRealm(); rule.jenkins.setSecurityRealm(realm); originalAuthorizationStrategy = rule.jenkins.getAuthorizationStrategy(); rule.jenkins.setAuthorizationStrategy(new GrantPermissions(username, permissions)); command.setTransportAuth(user().impersonate()); // Otherwise it is SYSTEM, which would be relevant for a command overriding main: originalSecurityContext = ACL.impersonate(Jenkins.ANONYMOUS); }