本文整理汇总了Java中org.apache.guacamole.net.GuacamoleTunnel类的典型用法代码示例。如果您正苦于以下问题:Java GuacamoleTunnel类的具体用法?Java GuacamoleTunnel怎么用?Java GuacamoleTunnel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GuacamoleTunnel类属于org.apache.guacamole.net包,在下文中一共展示了GuacamoleTunnel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
protected GuacamoleTunnel createTunnel(Session session,
EndpointConfig config) throws GuacamoleException {
Map<String, Object> userProperties = config.getUserProperties();
// Get original tunnel request
TunnelRequest tunnelRequest = (TunnelRequest) userProperties.get(TUNNEL_REQUEST_PROPERTY);
if (tunnelRequest == null)
return null;
// Get tunnel request service
TunnelRequestService tunnelRequestService = (TunnelRequestService) userProperties.get(TUNNEL_REQUEST_SERVICE_PROPERTY);
if (tunnelRequestService == null)
return null;
// Create and return tunnel
return tunnelRequestService.createTunnel(tunnelRequest);
}
示例2: invalidate
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
/**
* Closes all associated tunnels and prevents any further use of this
* session.
*/
public void invalidate() {
// Close all associated tunnels, if possible
for (GuacamoleTunnel tunnel : tunnels.values()) {
try {
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close tunnel.", e);
}
}
// Invalidate all user contextx
for (UserContext userContext : userContexts)
userContext.invalidate();
// Invalidate the authenticated user object
authenticatedUser.invalidate();
}
示例3: getGuacamoleTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
@Transactional
public GuacamoleTunnel getGuacamoleTunnel(RemoteAuthenticatedUser user,
SharedConnectionDefinition definition,
GuacamoleClientInformation info)
throws GuacamoleException {
// Create a connection record which describes the shared connection
ActiveConnectionRecord connectionRecord = activeConnectionRecordProvider.get();
connectionRecord.init(user, definition.getActiveConnection(),
definition.getSharingProfile());
// Connect to shared connection described by the created record
GuacamoleTunnel tunnel = assignGuacamoleTunnel(connectionRecord, info, false);
// Register tunnel, such that it is closed when the
// SharedConnectionDefinition is invalidated
definition.registerTunnel(tunnel);
return tunnel;
}
示例4: deleteObject
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public void deleteObject(ModeledAuthenticatedUser user, String identifier)
throws GuacamoleException {
// Only administrators may delete active connections
if (!user.getUser().isAdministrator())
throw new GuacamoleSecurityException("Permission denied.");
// Close connection, if it exists (and we have permission)
ActiveConnection activeConnection = retrieveObject(user, identifier);
if (activeConnection != null) {
// Close connection if not already closed
GuacamoleTunnel tunnel = activeConnection.getTunnel();
if (tunnel != null && tunnel.isOpen())
tunnel.close();
}
}
示例5: doConnect
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
protected GuacamoleTunnel doConnect(HttpServletRequest request) throws GuacamoleException {
// guacd connection information
String hostname = "localhost";
int port = 4822;
// VNC connection information
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol("vnc");
config.setParameter("hostname", "localhost");
config.setParameter("port", "5901");
config.setParameter("password", "potato");
// Connect to guacd, proxying a connection to the VNC server above
GuacamoleSocket socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket(hostname, port),
config
);
// Create tunnel from now-configured socket
GuacamoleTunnel tunnel = new SimpleGuacamoleTunnel(socket);
return tunnel;
}
示例6: getActiveConnection
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
/**
* Returns the ActiveConnection object associated with this tunnel within
* the AuthenticationProvider and UserContext which created the tunnel. If
* the AuthenticationProvider is not tracking active connections, or this
* tunnel is no longer active, this will be null.
*
* @return
* The ActiveConnection object associated with this tunnel, or null if
* this tunnel is no longer active or the AuthenticationProvider which
* created the tunnel is not tracking active connections.
*
* @throws GuacamoleException
* If an error occurs which prevents retrieval of the user's current
* active connections.
*/
public ActiveConnection getActiveConnection() throws GuacamoleException {
// Pull the UUID of the current tunnel
UUID uuid = getUUID();
// Get the directory of active connections
Directory<ActiveConnection> activeConnectionDirectory = userContext.getActiveConnectionDirectory();
Collection<String> activeConnectionIdentifiers = activeConnectionDirectory.getIdentifiers();
// Search all connections for a tunnel which matches this tunnel
for (ActiveConnection activeConnection : activeConnectionDirectory.getAll(activeConnectionIdentifiers)) {
// If we lack access, continue with next tunnel
GuacamoleTunnel tunnel = activeConnection.getTunnel();
if (tunnel == null)
continue;
// Tunnels are equivalent if they have the same UUID
if (uuid.equals(tunnel.getUUID()))
return activeConnection;
}
// No active connection associated with this tunnel
return null;
}
示例7: assignGuacamoleTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
/**
* Associates a new GuacamoleTunnel with this connection record using the
* given socket.
*
* @param socket
* The GuacamoleSocket to use to create the tunnel associated with this
* connection record.
*
* @param connectionID
* The connection ID assigned to this connection by guacd.
*
* @return
* The newly-created tunnel associated with this connection record.
*/
public GuacamoleTunnel assignGuacamoleTunnel(final GuacamoleSocket socket,
String connectionID) {
// Create tunnel with given socket
this.tunnel = new AbstractGuacamoleTunnel() {
@Override
public GuacamoleSocket getSocket() {
return socket;
}
@Override
public UUID getUUID() {
return uuid;
}
};
// Store connection ID of the primary connection only
if (isPrimaryConnection())
this.connectionID = connectionID;
// Return newly-created tunnel
return this.tunnel;
}
示例8: cleanup
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
protected void cleanup(GuacamoleTunnel tunnel) {
try {
tunnel.close();
}
catch (GuacamoleException e) {
logger.debug("Unable to close tunnel of shared connection.", e);
}
}
示例9: connect
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public GuacamoleTunnel connect(GuacamoleClientInformation info) throws GuacamoleException {
// Prevent future use immediately upon connect
if (connection.isSingleUse()) {
// Deny access if another user already used the connection
if (data.removeConnection(getIdentifier()) == null)
throw new GuacamoleSecurityException("Permission denied");
}
// Perform connection operation
return super.connect(info);
}
示例10: getTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public GuacamoleTunnel getTunnel() {
return tunnel;
}
示例11: setTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public void setTunnel(GuacamoleTunnel tunnel) {
this.tunnel = tunnel;
}
示例12: connect
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException {
throw new GuacamoleSecurityException("Permission denied.");
}
示例13: connect
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
public GuacamoleTunnel connect(GuacamoleClientInformation info)
throws GuacamoleException {
// Retrieve proxy configuration from environment
Environment environment = new LocalEnvironment();
GuacamoleProxyConfiguration proxyConfig = environment.getDefaultGuacamoleProxyConfiguration();
// Get guacd connection parameters
String hostname = proxyConfig.getHostname();
int port = proxyConfig.getPort();
GuacamoleSocket socket;
// Determine socket type based on required encryption method
switch (proxyConfig.getEncryptionMethod()) {
// If guacd requires SSL, use it
case SSL:
socket = new ConfiguredGuacamoleSocket(
new SSLGuacamoleSocket(hostname, port),
config, info
);
break;
// Connect directly via TCP if encryption is not enabled
case NONE:
socket = new ConfiguredGuacamoleSocket(
new InetGuacamoleSocket(hostname, port),
config, info
);
break;
// Abort if encryption method is unknown
default:
throw new GuacamoleServerException("Unimplemented encryption method.");
}
return new SimpleGuacamoleTunnel(socket);
}
示例14: createTunnel
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
/**
* Creates a new tunnel using the parameters and credentials present in
* the given request.
*
* @param request
* The request describing the tunnel to create.
*
* @return
* The created tunnel, or null if the tunnel could not be created.
*
* @throws GuacamoleException
* If an error occurs while creating the tunnel.
*/
public GuacamoleTunnel createTunnel(TunnelRequest request)
throws GuacamoleException {
// Parse request parameters
String authToken = request.getAuthenticationToken();
String id = request.getIdentifier();
TunnelRequest.Type type = request.getType();
String authProviderIdentifier = request.getAuthenticationProviderIdentifier();
GuacamoleClientInformation info = getClientInformation(request);
GuacamoleSession session = authenticationService.getGuacamoleSession(authToken);
UserContext userContext = session.getUserContext(authProviderIdentifier);
try {
// Create connected tunnel using provided connection ID and client information
GuacamoleTunnel tunnel = createConnectedTunnel(userContext, type, id, info);
// Notify listeners to allow connection to be vetoed
fireTunnelConnectEvent(session.getAuthenticatedUser(),
session.getAuthenticatedUser().getCredentials(), tunnel);
// Associate tunnel with session
return createAssociatedTunnel(tunnel, authToken, session, userContext, type, id);
}
// Ensure any associated session is invalidated if unauthorized
catch (GuacamoleUnauthorizedException e) {
// If there is an associated auth token, invalidate it
if (authenticationService.destroyGuacamoleSession(authToken))
logger.debug("Implicitly invalidated session for token \"{}\".", authToken);
// Continue with exception processing
throw e;
}
}
示例15: doConnect
import org.apache.guacamole.net.GuacamoleTunnel; //导入依赖的package包/类
@Override
protected GuacamoleTunnel doConnect(TunnelRequest request)
throws GuacamoleException {
return tunnelRequestService.createTunnel(request);
}