1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-03 01:17:56 +03:00

Organizing a bit the code into more repositories

This commit is contained in:
Adolfo Gómez García 2023-06-06 21:58:27 +02:00
parent 75cef5b1ab
commit 0f2c1f50db
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
50 changed files with 0 additions and 1081 deletions

View File

@ -1,11 +0,0 @@
# Backup files
*~
# Generated files
target/
# IDE-specific configuration
nb-configuration.xml
.classpath
.project

View File

@ -1,92 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.openuds.server</groupId>
<artifactId>guacamole-auth-uds</artifactId>
<packaging>jar</packaging>
<version>4.0.0</version>
<name>UDS Integration Extension for Apache Guacamole</name>
<url>https://github.com/VirtualCable/openuds</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<!-- Compile using Java 11 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
<compilerArgs>
<arg>-Xlint:all</arg>
<arg>-Werror</arg>
</compilerArgs>
<fork>true</fork>
</configuration>
</plugin>
<!-- Copy dependencies prior to packaging -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-dependencies</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
<version>2.5</version>
</dependency>
<!-- JAX-RS API -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<scope>provided</scope>
<version>1.1.1</version>
</dependency>
<!-- Guacamole extension API -->
<dependency>
<groupId>org.apache.guacamole</groupId>
<artifactId>guacamole-ext</artifactId>
<version>1.5.1</version>
<scope>provided</scope>
</dependency>
<!-- Guice - Dependency Injection -->
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,103 +0,0 @@
/*
* Copyright (c) 2020 Virtual Cable S.L.U.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole;
import org.apache.guacamole.net.auth.AbstractAuthenticatedUser;
import org.apache.guacamole.net.auth.AuthenticatedUser;
import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.auth.Credentials;
import org.openuds.guacamole.connection.UDSConnection;
/**
* A Guacamole user that was authenticated by an external UDS service.
*/
public class UDSAuthenticatedUser extends AbstractAuthenticatedUser {
/**
* The AuthenticationProvider that authenticated this user.
*/
private final AuthenticationProvider authProvider;
/**
* The credentials provided by this user when they authenticated.
*/
private final Credentials credentials;
/**
* The single connection that this user should be authorized to access.
*/
private final UDSConnection connection;
/**
* Creates a new UDSAuthenticatedUser representing a Guacamole user that
* was authenticated by an external UDS service.
*
* @param authProvider
* The AuthenticationProvider that authenticated the user.
*
* @param credentials
* The credentials provided by the user when they authenticated.
*
* @param connection
* The single connection that the user should be authorized to access.
*/
public UDSAuthenticatedUser(AuthenticationProvider authProvider,
Credentials credentials, UDSConnection connection) {
this.authProvider = authProvider;
this.credentials = credentials;
this.connection = connection;
}
@Override
public String getIdentifier() {
return AuthenticatedUser.ANONYMOUS_IDENTIFIER;
}
@Override
public AuthenticationProvider getAuthenticationProvider() {
return authProvider;
}
@Override
public Credentials getCredentials() {
return credentials;
}
/**
* Returns the single connection that this user should be authorized to
* access.
*
* @return
* The single connection that this user should be authorized to access.
*/
public UDSConnection getConnection() {
return connection;
}
}

View File

@ -1,149 +0,0 @@
/*
* Copyright (c) 2020 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole;
import com.google.inject.Guice;
import com.google.inject.Injector;
import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.form.Field;
import org.apache.guacamole.net.auth.AbstractAuthenticationProvider;
import org.apache.guacamole.net.auth.AuthenticatedUser;
import org.apache.guacamole.net.auth.Credentials;
import org.apache.guacamole.net.auth.UserContext;
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
import org.openuds.guacamole.connection.ConnectionService;
import org.openuds.guacamole.connection.UDSConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* AuthenticationProvider implementation which authenticates users that are
* confirmed as authorized by an external UDS service.
*/
public class UDSAuthenticationProvider extends AbstractAuthenticationProvider {
/**
* The name of the query parameter that should contain the data sent to
* the UDS service for authentication.
*/
private static final String DATA_PARAMETER_NAME = "data";
/**
* The form of credentials accepted by this extension.
*/
private static final CredentialsInfo UDS_CREDENTIALS =
new CredentialsInfo(Collections.<Field>singletonList(
new Field(DATA_PARAMETER_NAME, Field.Type.QUERY_PARAMETER)
));
/**
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(UDSAuthenticationProvider.class);
/**
* Service for retrieving connection configuration information from the
* UDS service.
*/
private final ConnectionService connectionService;
/**
* Creates a new UDSAuthenticationProvider which authenticates users
* against an external UDS service.
*
* @throws GuacamoleException
* If an error prevents guacamole.properties from being read.
*/
public UDSAuthenticationProvider() throws GuacamoleException {
// Create an injector with OpenUDS- and Guacamole-specific services
// properly bound
Injector injector = Guice.createInjector(
new UDSModule()
);
// Pull instance of connection service from injector
connectionService = injector.getInstance(ConnectionService.class);
}
@Override
public String getIdentifier() {
return "uds";
}
@Override
public AuthenticatedUser authenticateUser(Credentials credentials)
throws GuacamoleException {
HttpServletRequest request = credentials.getRequest();
// Pull OpenUDS-specific "data" parameter
String data = request.getParameter(DATA_PARAMETER_NAME);
if (data == null || data.isEmpty()) {
logger.debug("UDS connection data was not provided. No connection retrieval from UDS will be performed.");
throw new GuacamoleInvalidCredentialsException("Connection data was not provided.", UDS_CREDENTIALS);
}
try {
// Retrieve connection information using provided data
UDSConnection connection = new UDSConnection(connectionService, data);
// Report successful authentication as a temporary, anonymous user,
// storing the retrieved connection configuration data for future use
return new UDSAuthenticatedUser(this, credentials, connection);
}
catch (GuacamoleException e) {
logger.info("Provided connection data could not be validated with UDS: {}", e.getMessage());
logger.debug("Validation of UDS connection data failed.", e);
throw new GuacamoleInvalidCredentialsException("Connection data was rejected by UDS.", e, UDS_CREDENTIALS);
}
}
@Override
public UserContext getUserContext(AuthenticatedUser authenticatedUser)
throws GuacamoleException {
// Provide data only for users authenticated by this extension
if (!(authenticatedUser instanceof UDSAuthenticatedUser))
return null;
// Expose a single connection (derived from the "data" parameter
// provided during authentication)
return new UDSUserContext(this, (UDSAuthenticatedUser) authenticatedUser);
}
}

View File

@ -1,73 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole;
import com.google.inject.AbstractModule;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.environment.LocalEnvironment;
import org.openuds.guacamole.config.ConfigurationService;
import org.openuds.guacamole.connection.ConnectionService;
/**
* Guice module which binds classes required by the OpenUDS integration of
* Apache Guacamole.
*/
public class UDSModule extends AbstractModule {
/**
* The Guacamole server environment.
*/
private final Environment environment;
/**
* Creates a new UDSModule which binds classes required by the OpenUDS
* integration of Apache Guacamole, including an implementation of the
* Guacamole server {@link Environment}.
*
* @throws GuacamoleException
* If the guacamole.properties file cannot be read.
*/
public UDSModule() throws GuacamoleException {
this.environment = LocalEnvironment.getInstance();
}
@Override
protected void configure() {
// Bind instance of Guacamole server environment
bind(Environment.class).toInstance(environment);
// Bind UDS-specific services
bind(ConfigurationService.class);
bind(ConnectionService.class);
}
}

View File

@ -1,110 +0,0 @@
/*
* Copyright (c) 2020 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole;
import java.util.Collections;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.auth.AbstractUserContext;
import org.apache.guacamole.net.auth.AuthenticationProvider;
import org.apache.guacamole.net.auth.Connection;
import org.apache.guacamole.net.auth.Directory;
import org.apache.guacamole.net.auth.User;
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
import org.apache.guacamole.net.auth.simple.SimpleDirectory;
import org.apache.guacamole.net.auth.simple.SimpleObjectPermissionSet;
import org.apache.guacamole.net.auth.simple.SimpleUser;
import org.openuds.guacamole.connection.UDSConnection;
/**
* UserContext implementation which exposes access only to a single
* UDSConnection. The details of the connection exposed are determined by the
* UDS-specific data associated with the user.
*/
public class UDSUserContext extends AbstractUserContext {
/**
* The unique identifier of the root connection group.
*/
public static final String ROOT_CONNECTION_GROUP = DEFAULT_ROOT_CONNECTION_GROUP;
/**
* The AuthenticationProvider that produced this UserContext.
*/
private final AuthenticationProvider authProvider;
/**
* The AuthenticatedUser for whom this UserContext was created.
*/
private final UDSAuthenticatedUser authenticatedUser;
/**
* Creates a new UDSUserContext that is associated with the given
* AuthenticationProvider and uses the UDS-specific data of the given
* UDSAuthenticatedUser to determine the connection that user can access.
*
* @param authProvider
* The AuthenticationProvider that is producing the UserContext.
*
* @param authenticatedUser
* The AuthenticatedUser for whom this UserContext is being created.
*/
public UDSUserContext(AuthenticationProvider authProvider,
UDSAuthenticatedUser authenticatedUser) {
this.authProvider = authProvider;
this.authenticatedUser = authenticatedUser;
}
@Override
public User self() {
return new SimpleUser() {
@Override
public ObjectPermissionSet getConnectionGroupPermissions() throws GuacamoleException {
return new SimpleObjectPermissionSet(Collections.singleton(DEFAULT_ROOT_CONNECTION_GROUP));
}
@Override
public ObjectPermissionSet getConnectionPermissions() throws GuacamoleException {
return new SimpleObjectPermissionSet(Collections.singleton(UDSConnection.IDENTIFIER));
}
};
}
@Override
public AuthenticationProvider getAuthenticationProvider() {
return authProvider;
}
@Override
public Directory<Connection> getConnectionDirectory() throws GuacamoleException {
return new SimpleDirectory<>(authenticatedUser.getConnection());
}
}

View File

@ -1,80 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole.config;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.net.URI;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.environment.Environment;
import org.apache.guacamole.properties.URIGuacamoleProperty;
/**
* Service that provides access to OpenUDS-specific configuration information
* stored within guacamole.properties.
*/
@Singleton
public class ConfigurationService {
/**
* The name of the property within guacamole.properties which defines the
* base URL of the service providing connection configuration information.
*/
private static final URIGuacamoleProperty UDS_BASE_URL_PROPERTY = new URIGuacamoleProperty() {
@Override
public String getName() {
return "uds-base-url";
}
};
/**
* The Guacamole server environment.
*/
@Inject
private Environment environment;
/**
* Returns the base URI of the OpenUDS service. All services providing data
* to this Guacamole integration are hosted beneath this base URI.
*
* @return
* The base URI of the OpenUDS service.
*
* @throws GuacamoleException
* If the base URI of the OpenUDS service is not defined because the
* tunnel.properties file could not be parsed when the web application
* started.
*/
public URI getUDSBaseURI() throws GuacamoleException {
return environment.getRequiredProperty(UDS_BASE_URL_PROPERTY);
}
}

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Classes used to retrieve OpenUDS-specific configuration information.
*/
package org.openuds.guacamole.config;

View File

@ -1,201 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole.connection;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.UriBuilder;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.GuacamoleServerException;
import org.apache.guacamole.protocol.GuacamoleConfiguration;
import org.openuds.guacamole.config.ConfigurationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Service which communicates with the remote OpenUDS connection service,
* providing access to the underlying connection configuration.
*/
@Singleton
public class ConnectionService {
/**
* Logger for this class.
*/
private final Logger logger = LoggerFactory.getLogger(ConnectionService.class);
/**
* The name of the parameter returned by the OpenUDS connection
* configuration service which will contain the protocol that Guacamole
* should use to initiate the remote desktop connection.
*/
private static final String PROTOCOL_PARAMETER = "protocol";
/**
* Service for retrieving configuration information.
*/
@Inject
private ConfigurationService configService;
/**
* Makes an HTTP GET request to the OpenUDS service running at the given
* URI, parsing the response into connection configuration data. The
* response MUST be simple text, one line per connection parameter, with the
* name of the connection parameter separated from the corresponding value
* by a tab character. If the OpenUDS service encounters an error, it is
* expected to return the single word "ERROR" on one line. Lines which do
* not match these expectations will be skipped.
*
* @param uri
* The URI of the OpenUDS service to which the HTTP GET request should
* be made.
*
* @return
* A map of all parameter name/value pairs returned by the OpenUDS
* service.
*
* @throws GuacamoleException
* If the OpenUDS service returns an error, or the response from the
* service cannot be read.
*/
private Map<String, String> readConnectionConfiguration(URI uri)
throws GuacamoleException {
BufferedReader response;
// Connect to OpenUDS
try {
URLConnection connection = uri.toURL().openConnection();
response = new BufferedReader(new InputStreamReader(connection.getInputStream()));
}
catch (IOException e) {
throw new GuacamoleServerException("Unable to open connection to OpenUDS service.", e);
}
Map<String, String> parameters = new HashMap<String, String>();
// Read and parse each line of the response
try {
String inputLine;
while ((inputLine = response.readLine()) != null) {
// Abort upon error
if (inputLine.equals("ERROR"))
throw new GuacamoleServerException("OpenUDS service returned an error.");
// Determine separation between each line's key and value
int tab = inputLine.indexOf('\t');
if (tab == -1)
continue;
// Add key/value pair from either side of the tab
parameters.put(
inputLine.substring(0, tab),
inputLine.substring(tab + 1)
);
}
}
// Rethrow any error which occurs during reading
catch (IOException e) {
throw new GuacamoleServerException("Failed to read response from OpenUDS service.", e);
}
// Always close the stream
finally {
try {
response.close();
}
catch (IOException e) {
logger.warn("Closure of connection to OpenUDS failed. Resource may leak.", e);
}
}
// Parameters have been successfully parsed
return parameters;
}
/**
* Queries OpenUDS for the connection configuration for the connection
* associated with the given data. This data is an opaque value provided
* via the "data" parameter to the Guacamole tunnel.
*
* @param data
* The OpenUDS-specific data which defines the connection whose
* configuration should be retrieved.
*
* @return
* The configuration of the connection associated with the provided
* OpenUDS-specific data.
*
* @throws GuacamoleException
* If the connection configuration could not be retrieved from OpenUDS,
* of the response from OpenUDS was missing required information.
*/
public GuacamoleConfiguration getConnectionConfiguration(String data)
throws GuacamoleException {
logger.debug("Retrieving/validating connection configuration using data from \"{}\"...", data);
// Build URI of remote service from the base URI and given data
URI serviceURI = UriBuilder.fromUri(configService.getUDSBaseURI())
.path(data)
.build();
// Pull connection configuration from remote service
Map<String, String> params = readConnectionConfiguration(serviceURI);
// Pull the protocol from the parameters
String protocol = params.remove(PROTOCOL_PARAMETER);
if (protocol == null)
throw new GuacamoleServerException("Protocol missing from OpenUDS response.");
// Create our configuration
GuacamoleConfiguration config = new GuacamoleConfiguration();
config.setProtocol(protocol);
config.setParameters(params);
return config;
}
}

View File

@ -1,142 +0,0 @@
/*
* Copyright (c) 2020 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.openuds.guacamole.connection;
import java.util.Map;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.net.GuacamoleTunnel;
import org.apache.guacamole.net.auth.simple.SimpleConnection;
import org.apache.guacamole.protocol.GuacamoleClientInformation;
import org.openuds.guacamole.UDSUserContext;
/**
* Connection implementation which uses provided data to communicate with a
* remote UDS service to dynamically authorize access to a remote desktop. The
* provided data is validated when the UDSConnection is created and upon each
* connection attempt.
*/
public class UDSConnection extends SimpleConnection {
/**
* The name of the single connection that should be exposed to any user
* that authenticates via UDS.
*/
public static final String NAME = "UDS";
/**
* The unique identifier of the single connection that should be exposed to
* any user that authenticates via UDS.
*/
public static final String IDENTIFIER = NAME;
/**
* Service for retrieving configuration information.
*/
private final ConnectionService connectionService;
/**
* The UDS-specific data that should be provided to the remote UDS service
* to re-authenticate the user and determine the details of the connection
* they are authorized to access.
*/
private final String data;
/**
* Creates a new UDSConnection which exposes access to a remote desktop
* that is dynamically authorized by exchanging arbitrary UDS-specific data
* with a remote service. If the data is accepted by the UDS service, the
* data will also be re-validated upon each connection attempt.
*
* @param connectionService
* The service that should be used to validate the provided UDS data
* and retrieve corresponding connection configuration information.
*
* @param data
* The UDS-specific data that should be provided to the remote UDS
* service.
*
* @throws GuacamoleException
* If the provided data is no longer valid or the UDS service does not
* respond successfully.
*/
public UDSConnection(ConnectionService connectionService, String data)
throws GuacamoleException {
// Validate provided data
super.setConfiguration(connectionService.getConnectionConfiguration(data));
this.connectionService = connectionService;
this.data = data;
}
@Override
public String getParentIdentifier() {
return UDSUserContext.ROOT_CONNECTION_GROUP;
}
@Override
public void setParentIdentifier(String parentIdentifier) {
throw new UnsupportedOperationException("UDSConnection is read-only.");
}
@Override
public String getName() {
return NAME;
}
@Override
public void setName(String name) {
throw new UnsupportedOperationException("UDSConnection is read-only.");
}
@Override
public String getIdentifier() {
return IDENTIFIER;
}
@Override
public void setIdentifier(String identifier) {
throw new UnsupportedOperationException("UDSConnection is read-only.");
}
@Override
public GuacamoleTunnel connect(GuacamoleClientInformation info,
Map<String, String> tokens) throws GuacamoleException {
// Re-validate provided data (do not allow connections if data is no
// longer valid)
super.setConfiguration(connectionService.getConnectionConfiguration(data));
// Connect with configuration produced from data
return super.connect(info, tokens);
}
}

View File

@ -1,33 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Classes used to communicate with OpenUDS' connection configuration web
* service.
*/
package org.openuds.guacamole.connection;

View File

@ -1,32 +0,0 @@
/*
* Copyright (c) 2015 Virtual Cable S.L.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Virtual Cable S.L. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* Classes associated with the OpenUDS integration of Apache Guacamole.
*/
package org.openuds.guacamole;

View File

@ -1,16 +0,0 @@
{
"guacamoleVersion" : "1.2.0",
"name" : "UDS Integration Extension for Apache Guacamole",
"namespace" : "uds",
"authProviders" : [
"org.openuds.guacamole.UDSAuthenticationProvider"
],
"translations" : [
"translations/en.json"
]
}

View File

@ -1,7 +0,0 @@
{
"DATA_SOURCE_UDS" : {
"NAME" : "UDS"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 586 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 512 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 690 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 525 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 707 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 560 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 648 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 810 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 843 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 717 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB