public void initializeTunnel(AgentTunnel tunnel) {
tunnel.registerRequestHandler(SETUP_AND_LAUNCH_TUNNEL, this);
}
public boolean processRequest(Request request, MultiplexedConnection connection) {
AgentTunnel agent = (AgentTunnel) connection;
if (request.getRequestName().equals(SETUP_AND_LAUNCH_TUNNEL) && request.getRequestData()!=null) {
try {
ByteArrayReader reader = new ByteArrayReader(request.getRequestData());
int id = (int)reader.readInt();
Tunnel resource = (Tunnel)TunnelPlugin.SSL_TUNNEL_RESOURCE_TYPE.getResourceById(id);
if (resource == null) {
throw new Exception("No resource with ID " + id);
}
Policy policy = LaunchSessionManager.getLaunchRequestPolicy(null, agent.getSession(), resource);
if (resource.sessionPasswordRequired(agent.getSession())) {
// TODO: prompt user for credentials through agent!
return true;
} else {
LaunchSession launchSession = LaunchSessionFactory.getInstance().createLaunchSession(agent.getSession(),
resource,
policy);
launchSession.checkAccessRights(null, agent.getSession());
if (resource.getType() == TransportType.LOCAL_TUNNEL_ID) {
try {
Request req = buildLocalTunnel(resource, launchSession);
request.setRequestData(req.getRequestData());
return true;