use of hudson.cli.CliManagerImpl in project hudson-2.x by hudson.
the class Hudson method doCli.
/**
* Handles HTTP requests for duplex channels for CLI.
*/
public void doCli(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, InterruptedException {
if (!"POST".equals(req.getMethod())) {
// for GET request, serve _cli.jelly, assuming this is a browser
checkPermission(READ);
req.getView(this, "_cli.jelly").forward(req, rsp);
return;
}
// do not require any permission to establish a CLI connection
// the actual authentication for the connecting Channel is done by CLICommand
UUID uuid = UUID.fromString(req.getHeader("Session"));
// set the header so that the client would know
rsp.setHeader("Hudson-Duplex", "");
FullDuplexHttpChannel server;
if (req.getHeader("Side").equals("download")) {
duplexChannels.put(uuid, server = new FullDuplexHttpChannel(uuid, !hasPermission(ADMINISTER)) {
protected void main(Channel channel) throws IOException, InterruptedException {
// capture the identity given by the transport, since this can be useful for SecurityRealm.createCliAuthenticator()
channel.setProperty(CLICommand.TRANSPORT_AUTHENTICATION, getAuthentication());
channel.setProperty(CliEntryPoint.class.getName(), new CliManagerImpl());
}
});
try {
server.download(req, rsp);
} finally {
duplexChannels.remove(uuid);
}
} else {
duplexChannels.get(uuid).upload(req, rsp);
}
}
Aggregations