Add .gitignore and .ratignore files for various directories
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
2
guacamole-ext/.gitignore
vendored
Normal file
2
guacamole-ext/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
target/
|
||||
*~
|
0
guacamole-ext/.ratignore
Normal file
0
guacamole-ext/.ratignore
Normal file
121
guacamole-ext/pom.xml
Normal file
121
guacamole-ext/pom.xml
Normal file
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<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.apache.guacamole</groupId>
|
||||
<artifactId>guacamole-ext</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.6.0</version>
|
||||
<name>guacamole-ext</name>
|
||||
<url>http://guacamole.apache.org/</url>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache.guacamole</groupId>
|
||||
<artifactId>guacamole-client</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<description>
|
||||
The Java API for extending the main Guacamole web application. This
|
||||
is not needed for authoring a new Guacamole-based web application.
|
||||
</description>
|
||||
|
||||
<!-- All applicable licenses -->
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<!-- Git repository -->
|
||||
<scm>
|
||||
<url>https://github.com/apache/guacamole-client</url>
|
||||
<connection>scm:git:https://git.wip-us.apache.org/repos/asf/guacamole-client.git</connection>
|
||||
</scm>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<!-- Attach source and JavaDoc .jars -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Java servlet API -->
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
<version>2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Guacamole Java API -->
|
||||
<dependency>
|
||||
<groupId>org.apache.guacamole</groupId>
|
||||
<artifactId>guacamole-common</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Guava Base Libraries -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Jackson for JSON support -->
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Library for unified IPv4/6 parsing and validation -->
|
||||
<dependency>
|
||||
<groupId>com.github.seancfoley</groupId>
|
||||
<artifactId>ipaddress</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.environment;
|
||||
|
||||
import org.apache.guacamole.properties.GuacamoleProperties;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.properties.CaseSensitivity;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Internal implementation of Environment that provides the default
|
||||
* implementations for any functions that are added to the Environment
|
||||
* interface. This is primarily necessary to allow those default implementations
|
||||
* to log warnings or informational messages without needing to repeatedly
|
||||
* recreate the Logger.
|
||||
*/
|
||||
class DefaultEnvironment extends DelegatingEnvironment {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(DefaultEnvironment.class);
|
||||
|
||||
/**
|
||||
* Creates a new DefaultEnvironment that provides default implementations
|
||||
* for functions that may not be implemented by the given Environment
|
||||
* implementation. The versions provided by DefaultEnvironment must still
|
||||
* be manually called by actual <code>public default</code> functions on
|
||||
* Environment to have any effect.
|
||||
*
|
||||
* @param environment
|
||||
* The environment that may not provide implementations for all
|
||||
* functions defined by the Environment interface.
|
||||
*/
|
||||
protected DefaultEnvironment(Environment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
|
||||
/* Pull the given property as a string. */
|
||||
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return property.getName(); }
|
||||
|
||||
};
|
||||
|
||||
/* Parse the string to a Collection of the desired type. */
|
||||
return property.parseValueCollection(getProperty(stringProperty));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property, Type defaultValue)
|
||||
throws GuacamoleException {
|
||||
|
||||
/* Pull the given property as a string. */
|
||||
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return property.getName(); }
|
||||
|
||||
};
|
||||
|
||||
/* Check the value and return the default if null. */
|
||||
String stringValue = getProperty(stringProperty);
|
||||
if (stringValue == null)
|
||||
return Collections.singletonList(defaultValue);
|
||||
|
||||
/* Parse the string and return the collection. */
|
||||
return property.parseValueCollection(stringValue);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property, Collection<Type> defaultValue)
|
||||
throws GuacamoleException {
|
||||
|
||||
/* Pull the given property as a string. */
|
||||
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return property.getName(); }
|
||||
|
||||
};
|
||||
|
||||
/* Check the value and return the default if null. */
|
||||
String stringValue = getProperty(stringProperty);
|
||||
if (stringValue == null)
|
||||
return defaultValue;
|
||||
|
||||
/* Parse the string and return the collection. */
|
||||
return property.parseValueCollection(stringValue);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getRequiredPropertyCollection(
|
||||
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
|
||||
/* Pull the given property as a string. */
|
||||
StringGuacamoleProperty stringProperty = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return property.getName(); }
|
||||
|
||||
};
|
||||
|
||||
/* Parse the string to a Collection of the desired type. */
|
||||
return property.parseValueCollection(getRequiredProperty(stringProperty));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuacamoleProperties(GuacamoleProperties properties)
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException(String.format("%s does not "
|
||||
+ "support dynamic definition of Guacamole properties.",
|
||||
getClass()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaseSensitivity getCaseSensitivity() {
|
||||
|
||||
try {
|
||||
return DefaultEnvironment.this.getProperty(CASE_SENSITIVITY, CaseSensitivity.ENABLED);
|
||||
}
|
||||
catch (GuacamoleException e) {
|
||||
|
||||
logger.error("Defaulting to case-sensitive handling of "
|
||||
+ "usernames and group names as the desired case "
|
||||
+ "sensitivity configuration could not be read: {}",
|
||||
e.getMessage());
|
||||
|
||||
logger.debug("Error reading case sensitivity configuration.", e);
|
||||
return CaseSensitivity.ENABLED;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.environment;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||
import org.apache.guacamole.properties.CaseSensitivity;
|
||||
import org.apache.guacamole.properties.GuacamoleProperties;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
import org.apache.guacamole.protocols.ProtocolInfo;
|
||||
|
||||
/**
|
||||
* Environment implementation which simply delegates all function calls to a
|
||||
* wrapped Environment instance.
|
||||
*/
|
||||
public class DelegatingEnvironment implements Environment {
|
||||
|
||||
/**
|
||||
* The Environment instance that all function calls should be delegated to.
|
||||
*/
|
||||
private final Environment environment;
|
||||
|
||||
/**
|
||||
* Creates a new DelegatingEnvironment which delegates all function calls
|
||||
* to the given Environment.
|
||||
*
|
||||
* @param environment
|
||||
* The Environment that all function calls should be delegated to.
|
||||
*/
|
||||
public DelegatingEnvironment(Environment environment) {
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGuacamoleHome() {
|
||||
return environment.getGuacamoleHome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ProtocolInfo> getProtocols() {
|
||||
return environment.getProtocols();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolInfo getProtocol(String name) {
|
||||
return environment.getProtocol(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
return environment.getProperty(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property, Type defaultValue) throws GuacamoleException {
|
||||
return environment.getProperty(property, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException {
|
||||
return environment.getPropertyCollection(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||
Type defaultValue) throws GuacamoleException {
|
||||
return environment.getPropertyCollection(property, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||
Collection<Type> defaultValue) throws GuacamoleException {
|
||||
return environment.getPropertyCollection(property, defaultValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
return environment.getRequiredProperty(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getRequiredPropertyCollection(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException {
|
||||
return environment.getRequiredPropertyCollection(property);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration() throws GuacamoleException {
|
||||
return environment.getDefaultGuacamoleProxyConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuacamoleProperties(GuacamoleProperties properties) throws GuacamoleException {
|
||||
environment.addGuacamoleProperties(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaseSensitivity getCaseSensitivity() {
|
||||
return environment.getCaseSensitivity();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.environment;
|
||||
|
||||
import org.apache.guacamole.properties.GuacamoleProperties;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.CaseSensitivity;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
import org.apache.guacamole.protocols.ProtocolInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The environment of an arbitrary Guacamole instance, describing available
|
||||
* protocols, configuration parameters, and the GUACAMOLE_HOME directory.
|
||||
*/
|
||||
public interface Environment {
|
||||
|
||||
/**
|
||||
* The hostname of the server where guacd (the Guacamole proxy server) is
|
||||
* running.
|
||||
*/
|
||||
public static final StringGuacamoleProperty GUACD_HOSTNAME = new StringGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "guacd-hostname"; }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* The port that guacd (the Guacamole proxy server) is listening on.
|
||||
*/
|
||||
public static final IntegerGuacamoleProperty GUACD_PORT = new IntegerGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "guacd-port"; }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether guacd requires SSL/TLS on connections.
|
||||
*/
|
||||
public static final BooleanGuacamoleProperty GUACD_SSL = new BooleanGuacamoleProperty() {
|
||||
|
||||
@Override
|
||||
public String getName() { return "guacd-ssl"; }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* A property that configures how Guacamole handles case sensitivity - it
|
||||
* can be enabled for both usernames and group names, just usernames, just
|
||||
* group names, or disabled for both.
|
||||
*/
|
||||
public static final EnumGuacamoleProperty<CaseSensitivity> CASE_SENSITIVITY =
|
||||
new EnumGuacamoleProperty<CaseSensitivity>(CaseSensitivity.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "case-sensitivity"; }
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the Guacamole home directory as determined when this Environment
|
||||
* object was created. The Guacamole home directory is found by checking, in
|
||||
* order: the guacamole.home system property, the GUACAMOLE_HOME environment
|
||||
* variable, and finally the .guacamole directory in the home directory of
|
||||
* the user running the servlet container.
|
||||
*
|
||||
* @return The File representing the Guacamole home directory, which may
|
||||
* or may not exist, and may turn out to not be a directory.
|
||||
*/
|
||||
public File getGuacamoleHome();
|
||||
|
||||
/**
|
||||
* Returns a map of all available protocols, where each key is the name of
|
||||
* that protocol as would be passed to guacd during connection.
|
||||
*
|
||||
* @return A map of all available protocols.
|
||||
*/
|
||||
public Map<String, ProtocolInfo> getProtocols();
|
||||
|
||||
/**
|
||||
* Returns the protocol having the given name. The name must be the
|
||||
* protocol name as would be passed to guacd during connection.
|
||||
*
|
||||
* @param name The name of the protocol.
|
||||
* @return The protocol having the given name, or null if no such
|
||||
* protocol is registered.
|
||||
*/
|
||||
public ProtocolInfo getProtocol(String name);
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||
* property in guacamole.properties, if any.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* The parsed value of the property as read from guacamole.properties.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties.
|
||||
*/
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||
* property in guacamole.properties, if any. If no value is found, the
|
||||
* provided default value is returned.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @param defaultValue
|
||||
* The value to return if no value was given in guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* The parsed value of the property as read from guacamole.properties,
|
||||
* or the provided default value if no value was found.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties.
|
||||
*/
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property,
|
||||
Type defaultValue) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns a sorted Collection of the
|
||||
* value set for that property in guacamole.properties, if any. The
|
||||
* implementation of parsing and returning a collection of multiple
|
||||
* values is up to the individual property implementations, and not all
|
||||
* implementations will support reading and returning multiple values.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* A sorted collection of the the parsed values of the property as read
|
||||
* from guacamole.properties.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties.
|
||||
*/
|
||||
public default <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
return new DefaultEnvironment(this).getPropertyCollection(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||
* property in guacamole.properties, if any. If no value is found, a
|
||||
* Collection is returned with the provided default value. The
|
||||
* implementation of parsing and returning a collection of multiple
|
||||
* values is up to the individual property implementations, and not all
|
||||
* implementations will support reading and returning multiple values.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @param defaultValue
|
||||
* The single value to return in the Collection if no value was given
|
||||
* in guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* A sorted collection of the the parsed values of the property as read
|
||||
* from guacamole.properties, or a Collection with the single default
|
||||
* value provided.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties.
|
||||
*/
|
||||
public default <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property, Type defaultValue)
|
||||
throws GuacamoleException {
|
||||
return new DefaultEnvironment(this).getPropertyCollection(property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||
* property in guacamole.properties, if any. If no value is found, the
|
||||
* provided Collection of default values is returned. The
|
||||
* implementation of parsing and returning a collection of multiple
|
||||
* values is up to the individual property implementations, and not all
|
||||
* implementations will support reading and returning multiple values.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @param defaultValue
|
||||
* The Collection of values to return in the Collection if no value was
|
||||
* given in guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* A sorted collection of the the parsed values of the property as read
|
||||
* from guacamole.properties, or a Collection with the single default
|
||||
* value provided.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties.
|
||||
*/
|
||||
public default <Type> Collection<Type> getPropertyCollection(
|
||||
GuacamoleProperty<Type> property, Collection<Type> defaultValue)
|
||||
throws GuacamoleException {
|
||||
return new DefaultEnvironment(this).getPropertyCollection(property, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns the value set for that
|
||||
* property in guacamole.properties. An exception is thrown if the value
|
||||
* is not provided.
|
||||
*
|
||||
* @param <Type> The type that the given property is parsed into.
|
||||
* @param property The property to read from guacamole.properties.
|
||||
* @return The parsed value of the property as read from
|
||||
* guacamole.properties.
|
||||
* @throws GuacamoleException If an error occurs while parsing the value
|
||||
* for the given property in
|
||||
* guacamole.properties, or if the property is
|
||||
* not specified.
|
||||
*/
|
||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given a GuacamoleProperty, parses and returns a sorted Collection of
|
||||
* values for that property in guacamole.properties. An exception is thrown
|
||||
* if the value is not provided. The implementation of parsing and returning
|
||||
* a collection of multiple values is up to the individual property
|
||||
* implementations, and not all implementations will support reading and
|
||||
* returning multiple values.
|
||||
*
|
||||
* @param <Type>
|
||||
* The type that the given property is parsed into.
|
||||
*
|
||||
* @param property
|
||||
* The property to read from guacamole.properties.
|
||||
*
|
||||
* @return
|
||||
* A sorted Collection of the property as read from guacamole.properties.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while parsing the value for the given property in
|
||||
* guacamole.properties, or if the property is not specified.
|
||||
*/
|
||||
public default <Type> Collection<Type> getRequiredPropertyCollection(
|
||||
GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
return new DefaultEnvironment(this).getRequiredPropertyCollection(property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the connection information which should be used, by default, to
|
||||
* connect to guacd when establishing a remote desktop connection.
|
||||
*
|
||||
* @return
|
||||
* The connection information which should be used, by default, to
|
||||
* connect to guacd.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the connection information for guacd cannot be retrieved.
|
||||
*/
|
||||
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration()
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Adds another possible source of Guacamole configuration properties to
|
||||
* this Environment. Properties not already defined by other sources of
|
||||
* Guacamole configuration properties will alternatively be read from the
|
||||
* given {@link GuacamoleProperties}.
|
||||
*
|
||||
* @param properties
|
||||
* The GuacamoleProperties to add to this Environment.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the given GuacamoleProperties cannot be added, or if this
|
||||
* Environment does not support this operation.
|
||||
*/
|
||||
public default void addGuacamoleProperties(GuacamoleProperties properties)
|
||||
throws GuacamoleException {
|
||||
new DefaultEnvironment(this).addGuacamoleProperties(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the case sensitivity configuration for Guacamole as defined
|
||||
* in guacamole.properties, or the default of enabling case sensitivity
|
||||
* for both usernames and group names.
|
||||
*
|
||||
* @return
|
||||
* The case sensitivity setting as configured in guacamole.properties,
|
||||
* or the default of enabling case sensitivity.
|
||||
*/
|
||||
public default CaseSensitivity getCaseSensitivity() {
|
||||
return new DefaultEnvironment(this).getCaseSensitivity();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,443 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.environment;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.net.auth.GuacamoleProxyConfiguration;
|
||||
import org.apache.guacamole.properties.GuacamoleProperties;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
import org.apache.guacamole.protocols.ProtocolInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The environment of the locally-running Guacamole instance, describing
|
||||
* available protocols, configuration parameters, and the GUACAMOLE_HOME
|
||||
* directory. Sources of configuration properties like guacamole.properties and
|
||||
* environment variables will be automatically added by the Guacamole web
|
||||
* application and may also be added by extensions using
|
||||
* {@link #addGuacamoleProperties(org.apache.guacamole.properties.GuacamoleProperties)}.
|
||||
*/
|
||||
public class LocalEnvironment implements Environment {
|
||||
|
||||
/**
|
||||
* Logger for this class.
|
||||
*/
|
||||
private static final Logger logger = LoggerFactory.getLogger(LocalEnvironment.class);
|
||||
|
||||
/**
|
||||
* Array of all known protocol names.
|
||||
*/
|
||||
private static final String[] KNOWN_PROTOCOLS = new String[] {
|
||||
"kubernetes",
|
||||
"rdp",
|
||||
"ssh",
|
||||
"telnet",
|
||||
"vnc",
|
||||
};
|
||||
|
||||
/**
|
||||
* The hostname to use when connecting to guacd if no hostname is provided
|
||||
* within guacamole.properties.
|
||||
*/
|
||||
private static final String DEFAULT_GUACD_HOSTNAME = "localhost";
|
||||
|
||||
/**
|
||||
* The port to use when connecting to guacd if no port is provided within
|
||||
* guacamole.properties.
|
||||
*/
|
||||
private static final int DEFAULT_GUACD_PORT = 4822;
|
||||
|
||||
/**
|
||||
* Whether SSL/TLS is enabled for connections to guacd if not specified
|
||||
* within guacamole.properties.
|
||||
*/
|
||||
private static final boolean DEFAULT_GUACD_SSL = false;
|
||||
|
||||
/**
|
||||
* The location of GUACAMOLE_HOME, which may not truly exist.
|
||||
*/
|
||||
private final File guacHome;
|
||||
|
||||
/**
|
||||
* The map of all available protocols.
|
||||
*/
|
||||
private final Map<String, ProtocolInfo> availableProtocols;
|
||||
|
||||
/**
|
||||
* All GuacamoleProperties instances added via addGuacamoleProperties(), in
|
||||
* the order that they were added. This storage has been made static to
|
||||
* allow addGuacamoleProperties() to work as expected even if extensions
|
||||
* continue to use the deprecated constructor to create non-singleton
|
||||
* instances.
|
||||
*/
|
||||
private static final List<GuacamoleProperties> availableProperties = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* The Jackson parser for parsing JSON files.
|
||||
*/
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
/**
|
||||
* Singleton instance of this environment, to be returned by calls to
|
||||
* getInstance().
|
||||
*/
|
||||
private static final LocalEnvironment instance = new LocalEnvironment();
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of LocalEnvironment which may be shared by
|
||||
* the Guacamole web application and all extensions.
|
||||
*
|
||||
* @return
|
||||
* A singleton instance of this class.
|
||||
*/
|
||||
public static LocalEnvironment getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new LocalEnvironment, initializing that environment based on
|
||||
* the contents of GUACAMOLE_HOME. Sources of configuration properties like
|
||||
* guacamole.properties and environment variables will be automatically
|
||||
* added by the Guacamole web application and/or any installed extensions.
|
||||
*
|
||||
* @deprecated
|
||||
* Extensions leveraging LocalEnvironment should instead use
|
||||
* LocalEnvironment.getInstance() to obtain a singleton instance of the
|
||||
* environment.
|
||||
*/
|
||||
@Deprecated
|
||||
public LocalEnvironment() {
|
||||
|
||||
// Determine location of GUACAMOLE_HOME
|
||||
guacHome = findGuacamoleHome();
|
||||
logger.info("GUACAMOLE_HOME is \"{}\".", guacHome.getAbsolutePath());
|
||||
|
||||
// Read all protocols
|
||||
availableProtocols = readProtocols();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Locates the Guacamole home directory by checking, in order:
|
||||
* the guacamole.home system property, the GUACAMOLE_HOME environment
|
||||
* variable, and finally the .guacamole directory in the home directory of
|
||||
* the user running the servlet container. If even the .guacamole directory
|
||||
* doesn't exist, then /etc/guacamole will be used.
|
||||
*
|
||||
* @return The File representing the Guacamole home directory, which may
|
||||
* or may not exist, and may turn out to not be a directory.
|
||||
*/
|
||||
private static File findGuacamoleHome() {
|
||||
|
||||
// Attempt to find Guacamole home
|
||||
File guacHome;
|
||||
|
||||
// Use system property by default
|
||||
String desiredDir = System.getProperty("guacamole.home");
|
||||
|
||||
// Failing that, try the GUACAMOLE_HOME environment variable
|
||||
if (desiredDir == null) desiredDir = System.getenv("GUACAMOLE_HOME");
|
||||
|
||||
// If successful, use explicitly specified directory
|
||||
if (desiredDir != null)
|
||||
guacHome = new File(desiredDir);
|
||||
|
||||
// If not explicitly specified, use standard locations
|
||||
else {
|
||||
|
||||
// Try ~/.guacamole first
|
||||
guacHome = new File(System.getProperty("user.home"), ".guacamole");
|
||||
|
||||
// If that doesn't exist, try /etc/guacamole if the /etc directory
|
||||
// exists on this system
|
||||
if (!guacHome.exists() && new File("/etc").exists())
|
||||
guacHome = new File("/etc/guacamole");
|
||||
|
||||
}
|
||||
|
||||
// Return discovered directory
|
||||
return guacHome;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given JSON file, returning the parsed ProtocolInfo. The JSON
|
||||
* format is conveniently and intentionally identical to a serialized
|
||||
* ProtocolInfo object, which is identical to the JSON format used by the
|
||||
* protocol REST service built into the Guacamole web application.
|
||||
*
|
||||
* @param input
|
||||
* An input stream containing JSON describing the forms and parameters
|
||||
* associated with a protocol supported by Guacamole.
|
||||
*
|
||||
* @return
|
||||
* A new ProtocolInfo object which contains the forms and parameters
|
||||
* described by the JSON file parsed.
|
||||
*
|
||||
* @throws IOException
|
||||
* If an error occurs while parsing the JSON file.
|
||||
*/
|
||||
private ProtocolInfo readProtocol(InputStream input)
|
||||
throws IOException {
|
||||
return mapper.readValue(input, ProtocolInfo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads through all pre-defined protocols and any protocols within the
|
||||
* "protocols" subdirectory of GUACAMOLE_HOME, returning a map containing
|
||||
* each of these protocols. The key of each entry will be the name of that
|
||||
* protocol, as would be passed to guacd during connection.
|
||||
*
|
||||
* @return
|
||||
* A map of all available protocols.
|
||||
*/
|
||||
private Map<String, ProtocolInfo> readProtocols() {
|
||||
|
||||
// Map of all available protocols
|
||||
Map<String, ProtocolInfo> protocols = new HashMap<String, ProtocolInfo>();
|
||||
|
||||
// Get protcols directory
|
||||
File protocol_directory = new File(getGuacamoleHome(), "protocols");
|
||||
|
||||
// Read protocols from directory if it exists
|
||||
if (protocol_directory.isDirectory()) {
|
||||
|
||||
// Get all JSON files
|
||||
File[] files = protocol_directory.listFiles(
|
||||
new FilenameFilter() {
|
||||
|
||||
@Override
|
||||
public boolean accept(File file, String string) {
|
||||
return string.endsWith(".json");
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
// Warn if directory contents are not available
|
||||
if (files == null) {
|
||||
logger.error("Unable to read contents of \"{}\".", protocol_directory.getAbsolutePath());
|
||||
files = new File[0];
|
||||
}
|
||||
|
||||
// Load each protocol from each file
|
||||
for (File file : files) {
|
||||
|
||||
try {
|
||||
|
||||
// Parse protocol
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
ProtocolInfo protocol = readProtocol(stream);
|
||||
stream.close();
|
||||
|
||||
// Store protocol
|
||||
protocols.put(protocol.getName(), protocol);
|
||||
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.error("Unable to read connection parameter information from \"{}\": {}", file.getAbsolutePath(), e.getMessage());
|
||||
logger.debug("Error reading protocol JSON.", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// If known protocols are not already defined, read from classpath
|
||||
for (String protocol : KNOWN_PROTOCOLS) {
|
||||
|
||||
// If protocol not defined yet, attempt to load from classpath
|
||||
if (!protocols.containsKey(protocol)) {
|
||||
|
||||
InputStream stream = LocalEnvironment.class.getResourceAsStream(
|
||||
"/org/apache/guacamole/protocols/"
|
||||
+ protocol + ".json");
|
||||
|
||||
// Parse JSON if available
|
||||
if (stream != null) {
|
||||
try {
|
||||
protocols.put(protocol, readProtocol(stream));
|
||||
}
|
||||
catch (IOException e) {
|
||||
logger.error("Unable to read pre-defined connection parameter information for protocol \"{}\": {}", protocol, e.getMessage());
|
||||
logger.debug("Error reading pre-defined protocol JSON.", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Protocols map now fully populated
|
||||
return protocols;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getGuacamoleHome() {
|
||||
return guacHome;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string value of the property having the given name, trying
|
||||
* each source of properties added with addGuacamoleProperties() until a
|
||||
* value is found. If no such property is defined, null is returned.
|
||||
*
|
||||
* @param name
|
||||
* The name of the property value to retrieve.
|
||||
*
|
||||
* @return
|
||||
* The value of the property having the given name, or null if no such
|
||||
* property is defined.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs retrieving a property from a GuacamoleProperties
|
||||
* implementation added via addGuacamoleProperties().
|
||||
*/
|
||||
private String getPropertyValue(String name) throws GuacamoleException {
|
||||
|
||||
// Search all provided GuacamoleProperties implementations, in order
|
||||
for (GuacamoleProperties properties : availableProperties) {
|
||||
String value = properties.getProperty(name);
|
||||
if (value != null)
|
||||
return value;
|
||||
}
|
||||
|
||||
// No such property
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property) throws GuacamoleException {
|
||||
return property.parseValue(getPropertyValue(property.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getProperty(GuacamoleProperty<Type> property,
|
||||
Type defaultValue) throws GuacamoleException {
|
||||
|
||||
Type value = getProperty(property);
|
||||
if (value == null)
|
||||
return defaultValue;
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException {
|
||||
|
||||
return property.parseValueCollection(getPropertyValue(property.getName()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||
Type defaultValue) throws GuacamoleException {
|
||||
|
||||
Collection<Type> value = getPropertyCollection(property);
|
||||
if (value == null)
|
||||
return Collections.singletonList(defaultValue);
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getPropertyCollection(GuacamoleProperty<Type> property,
|
||||
Collection<Type> defaultValue) throws GuacamoleException {
|
||||
|
||||
Collection<Type> value = getPropertyCollection(property);
|
||||
if (value == null)
|
||||
return defaultValue;
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Type getRequiredProperty(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException {
|
||||
|
||||
Type value = getProperty(property);
|
||||
if (value == null)
|
||||
throw new GuacamoleServerException("Property " + property.getName() + " is required.");
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <Type> Collection<Type> getRequiredPropertyCollection(GuacamoleProperty<Type> property)
|
||||
throws GuacamoleException {
|
||||
|
||||
Collection<Type> value = getPropertyCollection(property);
|
||||
if (value == null)
|
||||
throw new GuacamoleServerException("Property " + property.getName() + " is required.");
|
||||
|
||||
return value;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ProtocolInfo> getProtocols() {
|
||||
return availableProtocols;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProtocolInfo getProtocol(String name) {
|
||||
return availableProtocols.get(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleProxyConfiguration getDefaultGuacamoleProxyConfiguration()
|
||||
throws GuacamoleException {
|
||||
|
||||
// Parse guacd hostname/port/ssl properties
|
||||
return new GuacamoleProxyConfiguration(
|
||||
getProperty(Environment.GUACD_HOSTNAME, DEFAULT_GUACD_HOSTNAME),
|
||||
getProperty(Environment.GUACD_PORT, DEFAULT_GUACD_PORT),
|
||||
getProperty(Environment.GUACD_SSL, DEFAULT_GUACD_SSL)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGuacamoleProperties(GuacamoleProperties properties) {
|
||||
availableProperties.add(properties);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Represents a field with strictly one possible value. It is assumed that the
|
||||
* field may be blank, but that its sole non-blank value is the value provided.
|
||||
* The provided value represents "true" while all other values, including
|
||||
* having no associated value, represent "false".
|
||||
*/
|
||||
public class BooleanField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new BooleanField with the given name and truth value. The
|
||||
* truth value is the value that, when assigned to this field, means that
|
||||
* this field is "true".
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param truthValue
|
||||
* The value to consider "true" for this field. All other values will
|
||||
* be considered "false".
|
||||
*/
|
||||
public BooleanField(String name, String truthValue) {
|
||||
super(name, Field.Type.BOOLEAN, Collections.singletonList(truthValue));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Represents a date field. The field may contain only date values which
|
||||
* conform to a standard pattern, defined by DateField.FORMAT.
|
||||
*/
|
||||
public class DateField extends Field {
|
||||
|
||||
/**
|
||||
* The date format used by date fields, compatible with SimpleDateFormat.
|
||||
*/
|
||||
public static final String FORMAT = "yyyy-MM-dd";
|
||||
|
||||
/**
|
||||
* Creates a new DateField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public DateField(String name) {
|
||||
super(name, Field.Type.DATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given date into a string which follows the format used by
|
||||
* date fields.
|
||||
*
|
||||
* @param date
|
||||
* The date value to format, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The formatted date, or null if the provided time was null.
|
||||
*/
|
||||
public static String format(Date date) {
|
||||
DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT);
|
||||
return date == null ? null : dateFormat.format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string into a corresponding date. The string must
|
||||
* follow the standard format used by date fields, as defined by FORMAT
|
||||
* and as would be produced by format().
|
||||
*
|
||||
* @param dateString
|
||||
* The date string to parse, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The date corresponding to the given date string, or null if the
|
||||
* provided date string was null or blank.
|
||||
*
|
||||
* @throws ParseException
|
||||
* If the given date string does not conform to the standard format
|
||||
* used by date fields.
|
||||
*/
|
||||
public static Date parse(String dateString)
|
||||
throws ParseException {
|
||||
|
||||
// Return null if no date provided
|
||||
if (dateString == null || dateString.isEmpty())
|
||||
return null;
|
||||
|
||||
// Parse date according to format
|
||||
DateFormat dateFormat = new SimpleDateFormat(DateField.FORMAT);
|
||||
return dateFormat.parse(dateString);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a text field which may contain an email address.
|
||||
*/
|
||||
public class EmailField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new EmailField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public EmailField(String name) {
|
||||
super(name, Field.Type.EMAIL);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents an arbitrary field with a finite, enumerated set of possible
|
||||
* values.
|
||||
*/
|
||||
public class EnumField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new EnumField with the given name and possible values.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param options
|
||||
* All possible legal options for this field.
|
||||
*/
|
||||
public EnumField(String name, Collection<String> options) {
|
||||
super(name, Field.Type.ENUM, options);
|
||||
}
|
||||
|
||||
}
|
250
guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java
Normal file
250
guacamole-ext/src/main/java/org/apache/guacamole/form/Field.java
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents an arbitrary field, such as an HTTP parameter, the parameter of a
|
||||
* remote desktop protocol, or an input field within a form. Fields are generic
|
||||
* and typed dynamically through a type string, with the semantics of the field
|
||||
* defined by the type string. The behavior of each field type is defined
|
||||
* either through the web application itself (see FormService.js) or through
|
||||
* extensions.
|
||||
*/
|
||||
@JsonInclude(value=Include.NON_NULL)
|
||||
public class Field {
|
||||
|
||||
/**
|
||||
* All types of fields which are available by default. Additional field
|
||||
* types may be defined by extensions by using a unique field type name and
|
||||
* registering that name with the form service within JavaScript.
|
||||
*
|
||||
* See FormService.js.
|
||||
*/
|
||||
public static class Type {
|
||||
|
||||
/**
|
||||
* A text field, accepting arbitrary values.
|
||||
*/
|
||||
public static final String TEXT = "TEXT";
|
||||
|
||||
/**
|
||||
* An email address field. This field type generally behaves
|
||||
* identically to arbitrary text fields, but has semantic differences.
|
||||
*/
|
||||
public static final String EMAIL = "EMAIL";
|
||||
|
||||
/**
|
||||
* A username field. This field type generally behaves identically to
|
||||
* arbitrary text fields, but has semantic differences.
|
||||
*/
|
||||
public static final String USERNAME = "USERNAME";
|
||||
|
||||
/**
|
||||
* A password field, whose value is sensitive and must be hidden.
|
||||
*/
|
||||
public static final String PASSWORD = "PASSWORD";
|
||||
|
||||
/**
|
||||
* A numeric field, whose value must contain only digits.
|
||||
*/
|
||||
public static final String NUMERIC = "NUMERIC";
|
||||
|
||||
/**
|
||||
* A boolean field, whose value is either blank or "true".
|
||||
*/
|
||||
public static final String BOOLEAN = "BOOLEAN";
|
||||
|
||||
/**
|
||||
* An enumerated field, whose legal values are fully enumerated by a
|
||||
* provided, finite list.
|
||||
*/
|
||||
public static final String ENUM = "ENUM";
|
||||
|
||||
/**
|
||||
* A text field that can span more than one line.
|
||||
*/
|
||||
public static final String MULTILINE = "MULTILINE";
|
||||
|
||||
/**
|
||||
* A time zone field whose legal values are only valid time zone IDs,
|
||||
* as dictated by Java within TimeZone.getAvailableIDs().
|
||||
*/
|
||||
public static final String TIMEZONE = "TIMEZONE";
|
||||
|
||||
/**
|
||||
* Field type which allows selection of languages. The languages
|
||||
* displayed are the set of languages supported by the Guacamole web
|
||||
* application. Legal values are valid language IDs, as dictated by
|
||||
* the filenames of Guacamole's available translations.
|
||||
*/
|
||||
public static final String LANGUAGE = "LANGUAGE";
|
||||
|
||||
/**
|
||||
* A date field whose legal values conform to the pattern "YYYY-MM-DD",
|
||||
* zero-padded.
|
||||
*/
|
||||
public static final String DATE = "DATE";
|
||||
|
||||
/**
|
||||
* A time field whose legal values conform to the pattern "HH:MM:SS",
|
||||
* zero-padded, 24-hour.
|
||||
*/
|
||||
public static final String TIME = "TIME";
|
||||
|
||||
/**
|
||||
* An HTTP query parameter which is expected to be embedded in the URL
|
||||
* given to a user.
|
||||
*/
|
||||
public static final String QUERY_PARAMETER = "QUERY_PARAMETER";
|
||||
|
||||
/**
|
||||
* A color scheme accepted by the Guacamole server terminal emulator
|
||||
* and protocols which leverage it.
|
||||
*/
|
||||
public static final String TERMINAL_COLOR_SCHEME = "TERMINAL_COLOR_SCHEME";
|
||||
|
||||
/**
|
||||
* A redirect field whose value is an encoded URL to which the user
|
||||
* will be redirected.
|
||||
*/
|
||||
public static final String REDIRECT = "REDIRECT";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The unique name that identifies this field.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The type of this field.
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* A collection of all legal values of this field.
|
||||
*/
|
||||
private Collection<String> options;
|
||||
|
||||
/**
|
||||
* Creates a new Parameter with no associated name or type.
|
||||
*/
|
||||
public Field() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Field with the given name and type.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param type
|
||||
* The type of this field.
|
||||
*/
|
||||
public Field(String name, String type) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Field with the given name, type, and possible values.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param type
|
||||
* The type of this field.
|
||||
*
|
||||
* @param options
|
||||
* A collection of all possible valid options for this field.
|
||||
*/
|
||||
public Field(String name, String type, Collection<String> options) {
|
||||
this.name = name;
|
||||
this.type = type;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the unique name associated with this field.
|
||||
*
|
||||
* @return
|
||||
* The unique name associated with this field.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the unique name associated with this field.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to assign to this field.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this field.
|
||||
*
|
||||
* @return
|
||||
* The type of this field.
|
||||
*/
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of this field.
|
||||
*
|
||||
* @param type
|
||||
* The type of this field.
|
||||
*/
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable collection of field options. Changes to this
|
||||
* collection directly affect the available options.
|
||||
*
|
||||
* @return
|
||||
* A mutable collection of field options, or null if the field has no
|
||||
* options.
|
||||
*/
|
||||
public Collection<String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options available as possible values of this field.
|
||||
*
|
||||
* @param options
|
||||
* The options to associate with this field.
|
||||
*/
|
||||
public void setOptions(Collection<String> options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
|
||||
/**
|
||||
* Describes an available legal value for an enumerated field.
|
||||
*/
|
||||
@JsonInclude(value=Include.NON_NULL)
|
||||
public class FieldOption {
|
||||
|
||||
/**
|
||||
* The value that will be assigned if this option is chosen.
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* A human-readable title describing the effect of the value.
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Creates a new FieldOption with no associated value or title.
|
||||
*/
|
||||
public FieldOption() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new FieldOption having the given value and title.
|
||||
*
|
||||
* @param value
|
||||
* The value to assign if this option is chosen.
|
||||
*
|
||||
* @param title
|
||||
* The human-readable title to associate with this option.
|
||||
*/
|
||||
public FieldOption(String value, String title) {
|
||||
this.value = value;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value that will be assigned if this option is chosen.
|
||||
*
|
||||
* @return
|
||||
* The value that will be assigned if this option is chosen.
|
||||
*/
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value that will be assigned if this option is chosen.
|
||||
*
|
||||
* @param value
|
||||
* The value to assign if this option is chosen.
|
||||
*/
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the human-readable title describing the effect of this option.
|
||||
*
|
||||
* @return
|
||||
* The human-readable title describing the effect of this option.
|
||||
*/
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the human-readable title describing the effect of this option.
|
||||
*
|
||||
* @param title
|
||||
* A human-readable title describing the effect of this option.
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
}
|
110
guacamole-ext/src/main/java/org/apache/guacamole/form/Form.java
Normal file
110
guacamole-ext/src/main/java/org/apache/guacamole/form/Form.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Information which describes logical set of fields.
|
||||
*/
|
||||
@JsonInclude(value=Include.NON_NULL)
|
||||
public class Form {
|
||||
|
||||
/**
|
||||
* The name of this form. The form name must identify the form uniquely
|
||||
* from other forms.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* All fields associated with this form.
|
||||
*/
|
||||
private Collection<Field> fields;
|
||||
|
||||
/**
|
||||
* Creates a new Form object with no associated fields. The name is left
|
||||
* unset as null. If no form name is provided, this form must not be used
|
||||
* in the same context as another unnamed form.
|
||||
*/
|
||||
public Form() {
|
||||
fields = new ArrayList<Field>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Form object having the given name and containing the given
|
||||
* fields.
|
||||
*
|
||||
* @param name
|
||||
* A name which uniquely identifies this form.
|
||||
*
|
||||
* @param fields
|
||||
* The fields to provided within the new Form.
|
||||
*/
|
||||
public Form(String name, Collection<Field> fields) {
|
||||
this.name = name;
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mutable collection of the fields associated with this form.
|
||||
* Changes to this collection affect the fields exposed to the user.
|
||||
*
|
||||
* @return
|
||||
* A mutable collection of fields.
|
||||
*/
|
||||
public Collection<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the collection of fields associated with this form.
|
||||
*
|
||||
* @param fields
|
||||
* The collection of fields to associate with this form.
|
||||
*/
|
||||
public void setFields(Collection<Field> fields) {
|
||||
this.fields = fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this form. Form names must uniquely identify each
|
||||
* form.
|
||||
*
|
||||
* @return
|
||||
* The name of this form, or null if the form has no name.
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of this form. Form names must uniquely identify each form.
|
||||
*
|
||||
* @param name
|
||||
* The name to assign to this form.
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a language field. The field may contain only valid language
|
||||
* identifiers as used by the Guacamole web application for its translations.
|
||||
* Language identifiers are defined by the filenames of the JSON files
|
||||
* containing the translation.
|
||||
*/
|
||||
public class LanguageField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new LanguageField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public LanguageField(String name) {
|
||||
super(name, Field.Type.LANGUAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string into a language ID string. As any string may be
|
||||
* a valid language ID as long as it has a corresponding translation, the
|
||||
* only transformation currently performed by this function is to ensure
|
||||
* that a blank language string is parsed into null.
|
||||
*
|
||||
* @param language
|
||||
* The language string to parse, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The ID of the language corresponding to the given string, or null if
|
||||
* if the given language string was null or blank.
|
||||
*/
|
||||
public static String parse(String language) {
|
||||
|
||||
// Return null if no language is provided
|
||||
if (language == null || language.isEmpty())
|
||||
return null;
|
||||
|
||||
// Otherwise, assume language is already a valid language ID
|
||||
return language;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a field which can contain multiple lines of text.
|
||||
*/
|
||||
public class MultilineField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new MultilineField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public MultilineField(String name) {
|
||||
super(name, Field.Type.MULTILINE);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a field which may contain only integer values.
|
||||
*/
|
||||
public class NumericField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new NumericField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public NumericField(String name) {
|
||||
super(name, Field.Type.NUMERIC);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats the given integer in the format required by a numeric field.
|
||||
*
|
||||
* @param i
|
||||
* The integer to format, which may be null.
|
||||
*
|
||||
* @return
|
||||
* A string representation of the given integer, or null if the given
|
||||
* integer was null.
|
||||
*/
|
||||
public static String format(Integer i) {
|
||||
|
||||
// Return null if no value provided
|
||||
if (i == null)
|
||||
return null;
|
||||
|
||||
// Convert to string
|
||||
return i.toString();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string as an integer, where the given string is in the
|
||||
* format required by a numeric field.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse as an integer, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The integer representation of the given string, or null if the given
|
||||
* string was null.
|
||||
*
|
||||
* @throws NumberFormatException
|
||||
* If the given string is not in a parseable format.
|
||||
*/
|
||||
public static Integer parse(String str) throws NumberFormatException {
|
||||
|
||||
// Return null if no value provided
|
||||
if (str == null || str.isEmpty())
|
||||
return null;
|
||||
|
||||
// Parse as integer
|
||||
return Integer.valueOf(str);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a field which contains sensitive text information related to
|
||||
* authenticating a user.
|
||||
*/
|
||||
public class PasswordField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new PasswordField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public PasswordField(String name) {
|
||||
super(name, Field.Type.PASSWORD);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.net.URI;
|
||||
import org.apache.guacamole.language.Translatable;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* A Guacamole field that redirects a user to another page.
|
||||
*/
|
||||
public class RedirectField extends Field implements Translatable {
|
||||
|
||||
/**
|
||||
* The URL to which the user should be redirected. The URL should be
|
||||
* encoded
|
||||
*/
|
||||
private final URI redirectUrl;
|
||||
|
||||
/**
|
||||
* The translatable message that should be displayed for the user while the
|
||||
* browser redirects.
|
||||
*/
|
||||
private final TranslatableMessage redirectMessage;
|
||||
|
||||
/**
|
||||
* Creates a new field which facilitates redirection of the user
|
||||
* to another page.
|
||||
*
|
||||
* @param name
|
||||
* The name of this field.
|
||||
*
|
||||
* @param redirectUrl
|
||||
* The URL to which the user should be redirected.
|
||||
*
|
||||
* @param redirectMessage
|
||||
* The translatable message that should be displayed for the user while
|
||||
* the browser redirects.
|
||||
*/
|
||||
public RedirectField(String name, URI redirectUrl,
|
||||
TranslatableMessage redirectMessage) {
|
||||
|
||||
// Init base field properties
|
||||
super(name, Field.Type.REDIRECT);
|
||||
|
||||
// Store the URL to which the user will be redirected
|
||||
this.redirectUrl = redirectUrl;
|
||||
|
||||
// Store the message that will be displayed for the user during redirect
|
||||
this.redirectMessage = redirectMessage;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL to which the user should be redirected.
|
||||
*
|
||||
* @return
|
||||
* The URL to which the user should be redirected.
|
||||
*/
|
||||
public String getRedirectUrl() {
|
||||
return redirectUrl.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return redirectMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a terminal color scheme field. The field may contain only valid
|
||||
* terminal color schemes as used by the Guacamole server terminal emulator
|
||||
* and protocols which leverage it (SSH, telnet, Kubernetes).
|
||||
*/
|
||||
public class TerminalColorSchemeField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new TerminalColorSchemeField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public TerminalColorSchemeField(String name) {
|
||||
super(name, Field.Type.TERMINAL_COLOR_SCHEME);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Represents a basic text field. The field may generally contain any data, but
|
||||
* may not contain multiple lines.
|
||||
*/
|
||||
public class TextField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new TextField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public TextField(String name) {
|
||||
super(name, Field.Type.TEXT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TextField with the given name and possible values. As a
|
||||
* text field may contain any data by definition, any provided options are
|
||||
* simply known-good values.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*
|
||||
* @param options
|
||||
* A set of known legal options for this field.
|
||||
*/
|
||||
public TextField(String name, Collection<String> options) {
|
||||
super(name, Field.Type.TEXT, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string, interpreting empty strings as equivalent to
|
||||
* null. For all other cases, the given string is returned verbatim.
|
||||
*
|
||||
* @param str
|
||||
* The string to parse, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The given string, or null if the given string was null or empty.
|
||||
*/
|
||||
public static String parse(String str) {
|
||||
|
||||
// Return null if no value provided
|
||||
if (str == null || str.isEmpty())
|
||||
return null;
|
||||
|
||||
// Otherwise, return string unmodified
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Represents a time field. The field may contain only time values which
|
||||
* conform to a standard pattern, defined by TimeField.FORMAT.
|
||||
*/
|
||||
public class TimeField extends Field {
|
||||
|
||||
/**
|
||||
* The time format used by time fields, compatible with SimpleDateFormat.
|
||||
*/
|
||||
public static final String FORMAT = "HH:mm:ss";
|
||||
|
||||
/**
|
||||
* Creates a new TimeField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public TimeField(String name) {
|
||||
super(name, Field.Type.TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string into a corresponding time. The string must
|
||||
* follow the standard format used by time fields, as defined by
|
||||
* FORMAT and as would be produced by format().
|
||||
*
|
||||
* @param timeString
|
||||
* The time string to parse, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The time corresponding to the given time string, or null if the
|
||||
* provided time string was null or blank.
|
||||
*
|
||||
* @throws ParseException
|
||||
* If the given time string does not conform to the standard format
|
||||
* used by time fields.
|
||||
*/
|
||||
public static Date parse(String timeString)
|
||||
throws ParseException {
|
||||
|
||||
// Return null if no time provided
|
||||
if (timeString == null || timeString.isEmpty())
|
||||
return null;
|
||||
|
||||
// Parse time according to format
|
||||
DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT);
|
||||
return timeFormat.parse(timeString);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given time into a string which follows the format used by
|
||||
* time fields.
|
||||
*
|
||||
* @param time
|
||||
* The time value to format, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The formatted time, or null if the provided time was null.
|
||||
*/
|
||||
public static String format(Date time) {
|
||||
DateFormat timeFormat = new SimpleDateFormat(TimeField.FORMAT);
|
||||
return time == null ? null : timeFormat.format(time);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a time zone field. The field may contain only valid time zone
|
||||
* identifiers, as defined by the IANA time zone database. Such identifiers are
|
||||
* also valid Java time zone IDs as dictated by TimeZone.getAvailableIDs().
|
||||
*/
|
||||
public class TimeZoneField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new TimeZoneField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public TimeZoneField(String name) {
|
||||
super(name, Field.Type.TIMEZONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string into a time zone ID string. As these strings are
|
||||
* equivalent, the only transformation currently performed by this function
|
||||
* is to ensure that a blank time zone string is parsed into null.
|
||||
*
|
||||
* @param timeZone
|
||||
* The time zone string to parse, which may be null.
|
||||
*
|
||||
* @return
|
||||
* The ID of the time zone corresponding to the given string, or null
|
||||
* if the given time zone string was null or blank.
|
||||
*/
|
||||
public static String parse(String timeZone) {
|
||||
|
||||
// Return null if no time zone provided
|
||||
if (timeZone == null || timeZone.isEmpty())
|
||||
return null;
|
||||
|
||||
// Otherwise, assume time zone is valid
|
||||
return timeZone;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.form;
|
||||
|
||||
/**
|
||||
* Represents a text field which will contain the uniquely-identifying name of
|
||||
* a user.
|
||||
*/
|
||||
public class UsernameField extends Field {
|
||||
|
||||
/**
|
||||
* Creates a new UsernameField with the given name.
|
||||
*
|
||||
* @param name
|
||||
* The unique name to associate with this field.
|
||||
*/
|
||||
public UsernameField(String name) {
|
||||
super(name, Field.Type.USERNAME);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides classes which describe the contents and semantics of forms which
|
||||
* may be presented to the user.
|
||||
*/
|
||||
package org.apache.guacamole.form;
|
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
/**
|
||||
* An object which is associated with a translatable message that can be passed
|
||||
* through an arbitrary translation service, producing a human-readable message
|
||||
* in the user's native language.
|
||||
*/
|
||||
public interface Translatable {
|
||||
|
||||
/**
|
||||
* Returns a message which can be translated using a translation service,
|
||||
* consisting of a translation key and optional set of substitution
|
||||
* variables.
|
||||
*
|
||||
* @return
|
||||
* A message which can be translated using a translation service.
|
||||
*/
|
||||
TranslatableMessage getTranslatableMessage();
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleClientBadTypeException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleClientBadTypeException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleClientBadTypeException extends GuacamoleClientBadTypeException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientBadTypeException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientBadTypeException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientBadTypeException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleClientBadTypeException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientBadTypeException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientBadTypeException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientBadTypeException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleClientBadTypeException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleClientException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleClientException} whose associated message is translatable
|
||||
* and can be passed through an arbitrary translation service, producing a
|
||||
* human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleClientException extends GuacamoleClientException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleClientException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleClientException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleClientOverrunException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleClientOverrunException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleClientOverrunException extends GuacamoleClientOverrunException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientOverrunException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientOverrunException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientOverrunException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleClientOverrunException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientOverrunException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientOverrunException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientOverrunException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleClientOverrunException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleClientTimeoutException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleClientTimeoutException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleClientTimeoutException extends GuacamoleClientTimeoutException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTimeoutException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTimeoutException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTimeoutException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTimeoutException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTimeoutException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTimeoutException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTimeoutException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTimeoutException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleClientTooManyException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleClientTooManyException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleClientTooManyException extends GuacamoleClientTooManyException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTooManyException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTooManyException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTooManyException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTooManyException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTooManyException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTooManyException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleClientTooManyException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleClientTooManyException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleConnectionClosedException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleConnectionClosedException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleConnectionClosedException extends GuacamoleConnectionClosedException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleConnectionClosedException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleConnectionClosedException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleConnectionClosedException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleConnectionClosedException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleConnectionClosedException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleConnectionClosedException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleConnectionClosedException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleConnectionClosedException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleCredentialsException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleCredentialsException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleCredentialsException
|
||||
extends GuacamoleCredentialsException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleCredentialsException with the given
|
||||
* message, cause, and associated credential information. The message must
|
||||
* be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
super(message, cause, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleCredentialsException with the given
|
||||
* message, and associated credential information. The message must be
|
||||
* provided in both non-translatable (readable as-written) and translatable
|
||||
* forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, CredentialsInfo credentialsInfo) {
|
||||
super(message, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleCredentialsException with the given
|
||||
* message, cause, and associated credential information. The message must
|
||||
* be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleCredentialsException(String message,
|
||||
String key, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), cause, credentialsInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleCredentialsException with the given
|
||||
* message, and associated credential information. The message must be
|
||||
* provided in both non-translatable (readable as-written) and translatable
|
||||
* forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleCredentialsException(String message,
|
||||
String key, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), credentialsInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleInsufficientCredentialsException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleInsufficientCredentialsException} whose associated message
|
||||
* is translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleInsufficientCredentialsException
|
||||
extends GuacamoleInsufficientCredentialsException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInsufficientCredentialsException with
|
||||
* the given message, cause, and associated credential information. The
|
||||
* message must be provided in both non-translatable (readable as-written)
|
||||
* and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInsufficientCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
super(message, cause, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInsufficientCredentialsException with
|
||||
* the given message, and associated credential information. The message
|
||||
* must be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInsufficientCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, CredentialsInfo credentialsInfo) {
|
||||
super(message, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInsufficientCredentialsException with
|
||||
* the given message, cause, and associated credential information. The
|
||||
* message must be provided in both non-translatable (readable as-written)
|
||||
* and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInsufficientCredentialsException(String message,
|
||||
String key, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), cause, credentialsInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInsufficientCredentialsException with
|
||||
* the given message, and associated credential information. The message
|
||||
* must be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInsufficientCredentialsException(String message,
|
||||
String key, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), credentialsInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.net.auth.credentials.CredentialsInfo;
|
||||
import org.apache.guacamole.net.auth.credentials.GuacamoleInvalidCredentialsException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleInvalidCredentialsException} whose associated message
|
||||
* is translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleInvalidCredentialsException
|
||||
extends GuacamoleInvalidCredentialsException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInvalidCredentialsException with
|
||||
* the given message, cause, and associated credential information. The
|
||||
* message must be provided in both non-translatable (readable as-written)
|
||||
* and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInvalidCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
super(message, cause, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInvalidCredentialsException with
|
||||
* the given message, and associated credential information. The message
|
||||
* must be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInvalidCredentialsException(String message,
|
||||
TranslatableMessage translatableMessage, CredentialsInfo credentialsInfo) {
|
||||
super(message, credentialsInfo);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInvalidCredentialsException with
|
||||
* the given message, cause, and associated credential information. The
|
||||
* message must be provided in both non-translatable (readable as-written)
|
||||
* and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInvalidCredentialsException(String message,
|
||||
String key, Throwable cause, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), cause, credentialsInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleInvalidCredentialsException with
|
||||
* the given message, and associated credential information. The message
|
||||
* must be provided in both non-translatable (readable as-written) and
|
||||
* translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param credentialsInfo
|
||||
* Information describing the form of valid credentials.
|
||||
*/
|
||||
public TranslatableGuacamoleInvalidCredentialsException(String message,
|
||||
String key, CredentialsInfo credentialsInfo) {
|
||||
this(message, new TranslatableMessage(key), credentialsInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleResourceClosedException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleResourceClosedException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleResourceClosedException extends GuacamoleResourceClosedException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceClosedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceClosedException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceClosedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceClosedException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceClosedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceClosedException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceClosedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceClosedException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleResourceConflictException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleResourceConflictException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleResourceConflictException extends GuacamoleResourceConflictException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceConflictException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceConflictException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceConflictException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceConflictException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceConflictException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceConflictException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceConflictException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceConflictException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleResourceNotFoundException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleResourceNotFoundException extends GuacamoleResourceNotFoundException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceNotFoundException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceNotFoundException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceNotFoundException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceNotFoundException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceNotFoundException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceNotFoundException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleResourceNotFoundException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleResourceNotFoundException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleSecurityException} whose associated message is translatable
|
||||
* and can be passed through an arbitrary translation service, producing a
|
||||
* human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleSecurityException extends GuacamoleSecurityException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSecurityException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSecurityException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSecurityException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleSecurityException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSecurityException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSecurityException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSecurityException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleSecurityException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleServerBusyException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleServerBusyException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleServerBusyException extends GuacamoleServerBusyException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerBusyException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleServerBusyException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerBusyException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleServerBusyException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerBusyException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleServerBusyException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerBusyException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleServerBusyException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleServerException} whose associated message is translatable
|
||||
* and can be passed through an arbitrary translation service, producing a
|
||||
* human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleServerException extends GuacamoleServerException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleServerException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleServerException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleServerException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleServerException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleServerException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleSessionClosedException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleSessionClosedException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleSessionClosedException extends GuacamoleSessionClosedException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionClosedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionClosedException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionClosedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionClosedException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionClosedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionClosedException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionClosedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionClosedException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleSessionConflictException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleSessionConflictException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleSessionConflictException extends GuacamoleSessionConflictException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionConflictException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionConflictException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionConflictException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionConflictException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionConflictException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionConflictException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionConflictException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionConflictException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleSessionTimeoutException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleSessionTimeoutException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleSessionTimeoutException extends GuacamoleSessionTimeoutException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionTimeoutException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionTimeoutException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionTimeoutException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionTimeoutException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionTimeoutException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionTimeoutException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleSessionTimeoutException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleSessionTimeoutException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUnauthorizedException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUnauthorizedException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUnauthorizedException extends GuacamoleUnauthorizedException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnauthorizedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUnauthorizedException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnauthorizedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUnauthorizedException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnauthorizedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUnauthorizedException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnauthorizedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUnauthorizedException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUnsupportedException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUnsupportedException extends GuacamoleUnsupportedException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnsupportedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUnsupportedException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnsupportedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUnsupportedException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnsupportedException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUnsupportedException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUnsupportedException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUnsupportedException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUpstreamException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUpstreamException} whose associated message is translatable
|
||||
* and can be passed through an arbitrary translation service, producing a
|
||||
* human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUpstreamException extends GuacamoleUpstreamException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamException with the given
|
||||
* message and cause. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamException with the given
|
||||
* message. The message must be provided in both non-translatable (readable
|
||||
* as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUpstreamNotFoundException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUpstreamNotFoundException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUpstreamNotFoundException extends GuacamoleUpstreamNotFoundException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamNotFoundException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamNotFoundException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamNotFoundException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamNotFoundException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamNotFoundException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamNotFoundException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamNotFoundException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamNotFoundException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUpstreamTimeoutException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUpstreamTimeoutException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUpstreamTimeoutException extends GuacamoleUpstreamTimeoutException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamTimeoutException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamTimeoutException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamTimeoutException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamTimeoutException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamTimeoutException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamTimeoutException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamTimeoutException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamTimeoutException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
import org.apache.guacamole.GuacamoleUpstreamUnavailableException;
|
||||
|
||||
/**
|
||||
* A {@link GuacamoleUpstreamUnavailableException} whose associated message is
|
||||
* translatable and can be passed through an arbitrary translation service,
|
||||
* producing a human-readable message in the user's native language.
|
||||
*/
|
||||
public class TranslatableGuacamoleUpstreamUnavailableException extends GuacamoleUpstreamUnavailableException implements Translatable {
|
||||
|
||||
/**
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
private final TranslatableMessage translatableMessage;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamUnavailableException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamUnavailableException(String message, TranslatableMessage translatableMessage, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamUnavailableException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param translatableMessage
|
||||
* A translatable, human-readable description of the exception that
|
||||
* occurred.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamUnavailableException(String message, TranslatableMessage translatableMessage) {
|
||||
super(message);
|
||||
this.translatableMessage = translatableMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamUnavailableException with the
|
||||
* given message and cause. The message must be provided in both
|
||||
* non-translatable (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @param cause
|
||||
* The cause of this exception.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamUnavailableException(String message, String key, Throwable cause) {
|
||||
this(message, new TranslatableMessage(key), cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableGuacamoleUpstreamUnavailableException with the
|
||||
* given message. The message must be provided in both non-translatable
|
||||
* (readable as-written) and translatable forms.
|
||||
*
|
||||
* @param message
|
||||
* A human-readable description of the exception that occurred. This
|
||||
* message should be readable on its own and as-written, without
|
||||
* requiring a translation service.
|
||||
*
|
||||
* @param key
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
public TranslatableGuacamoleUpstreamUnavailableException(String message, String key) {
|
||||
this(message, new TranslatableMessage(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getTranslatableMessage() {
|
||||
return translatableMessage;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.language;
|
||||
|
||||
/**
|
||||
* A message which can be translated using a translation service, providing a
|
||||
* translation key and optional set of values to be substituted into the
|
||||
* translation string associated with that key.
|
||||
*/
|
||||
public class TranslatableMessage {
|
||||
|
||||
/**
|
||||
* The arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*/
|
||||
private final String key;
|
||||
|
||||
/**
|
||||
* An arbitrary object whose properties should be substituted for the
|
||||
* corresponding placeholders within the string associated with the key.
|
||||
*/
|
||||
private final Object variables;
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableMessage associated with the given translation
|
||||
* key, without any associated variables.
|
||||
*
|
||||
* @param key
|
||||
* The translation key to associate with the TranslatableMessage.
|
||||
*/
|
||||
public TranslatableMessage(String key) {
|
||||
this(key, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new TranslatableMessage associated with the given translation
|
||||
* key and associated variables.
|
||||
*
|
||||
* @param key
|
||||
* The translation key to associate with the TranslatableMessage.
|
||||
*
|
||||
* @param variables
|
||||
* An arbitrary object whose properties should be substituted for the
|
||||
* corresponding placeholders within the string associated with the
|
||||
* given translation key.
|
||||
*/
|
||||
public TranslatableMessage(String key, Object variables) {
|
||||
this.key = key;
|
||||
this.variables = variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the arbitrary key which can be used to look up the message to be
|
||||
* displayed in the user's native language.
|
||||
*
|
||||
* @return
|
||||
* The arbitrary key associated with the human-readable message.
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an arbitrary object whose properties should be substituted for
|
||||
* the corresponding placeholders within the string associated with the key.
|
||||
* If not applicable, null is returned.
|
||||
*
|
||||
* @return
|
||||
* An arbitrary object whose properties should be substituted for the
|
||||
* corresponding placeholders within the string associated with the key,
|
||||
* or null if not applicable.
|
||||
*/
|
||||
public Object getVariables() {
|
||||
return variables;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,411 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* A copy of the details of an HTTP request. The values within this object can
|
||||
* be accessed even when outside the scope of the specific request represented.
|
||||
*/
|
||||
public class RequestDetails {
|
||||
|
||||
/**
|
||||
* The address of the client that sent the associated request.
|
||||
*/
|
||||
private final String remoteAddress;
|
||||
|
||||
/**
|
||||
* The hostname or, if the hostname cannot be determined, the address of the
|
||||
* client that sent the associated request.
|
||||
*/
|
||||
private final String remoteHostname;
|
||||
|
||||
/**
|
||||
* The HttpSession associated with the request, if any.
|
||||
*/
|
||||
private final HttpSession session;
|
||||
|
||||
/**
|
||||
* An unmodifiable Map of all HTTP headers included in the associated
|
||||
* request. If there are no such headers, this Map will be empty. As there
|
||||
* may be many values for each header, each value is stored as a separate
|
||||
* entry in an unmodifiable List. The keys of this map (header names) are
|
||||
* case-insensitive.
|
||||
*/
|
||||
private final Map<String, List<String>> headers;
|
||||
|
||||
/**
|
||||
* An unmodifiable Map of all HTTP parameters included in the associated
|
||||
* request. If there are no such parameters, this Map will be empty. As
|
||||
* there may be many values for each parameter, each value is stored as a
|
||||
* separate entry in an unmodifiable List. Unlike headers, the keys of this
|
||||
* map (parameter names) are case-sensitive.
|
||||
*/
|
||||
private final Map<String, List<String>> parameters;
|
||||
|
||||
/**
|
||||
* An unmodifiable list of all cookies associated with the request. If
|
||||
* there are no cookies associated with the request, this List will be
|
||||
* empty.
|
||||
*/
|
||||
private final List<Cookie> cookies;
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of all HTTP headers within the given request.
|
||||
* If there are no such headers, the returned Map will be empty. As there
|
||||
* may be many values for each header, each value is stored as a separate
|
||||
* entry in an unmodifiable List. The keys of the returned map (header
|
||||
* names) are case-insensitive.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP request to extract all headers from.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Map of all HTTP headers in the given request.
|
||||
*/
|
||||
private static Map<String, List<String>> getHeaders(HttpServletRequest request) {
|
||||
|
||||
@SuppressWarnings("unchecked") // getHeaderNames() is explicitly documented as returning a Enumeration<String>
|
||||
Enumeration<String> names = (Enumeration<String>) request.getHeaderNames();
|
||||
|
||||
// Represent the total lack of headers as an empty map, not null
|
||||
if (names == null)
|
||||
return Collections.emptyMap();
|
||||
|
||||
// Headers are case-insensitive
|
||||
Map<String, List<String>> headers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
|
||||
names.asIterator().forEachRemaining((String name) -> {
|
||||
|
||||
@SuppressWarnings("unchecked") // getHeaders() is explicitly documented as returning a Enumeration<String>
|
||||
Enumeration<String> values = (Enumeration<String>) request.getHeaders(name);
|
||||
if (values != null && values.hasMoreElements())
|
||||
headers.put(name, Collections.unmodifiableList(Collections.list(values)));
|
||||
|
||||
});
|
||||
|
||||
return Collections.unmodifiableMap(headers);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of all HTTP parameters within the given
|
||||
* request. If there are no such parameters, the returned Map will be empty.
|
||||
* As there may be many values for each parameter, each value is stored as a
|
||||
* separate entry in an unmodifiable List. Unlike headers, the keys of the
|
||||
* returned map (parameter names) are case-sensitive.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP request to extract all parameters from.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Map of all HTTP parameters in the given request.
|
||||
*/
|
||||
private static Map<String, List<String>> getParameters(HttpServletRequest request) {
|
||||
|
||||
@SuppressWarnings("unchecked") // getParameterNames() is explicitly documented as returning a Enumeration<String>
|
||||
Enumeration<String> names = (Enumeration<String>) request.getParameterNames();
|
||||
|
||||
// Represent the total lack of parameters as an empty map, not null
|
||||
if (names == null)
|
||||
return Collections.emptyMap();
|
||||
|
||||
// Unlike headers, parameters are case-sensitive
|
||||
Map<String, List<String>> parameters = new HashMap<>();
|
||||
names.asIterator().forEachRemaining((String name) -> {
|
||||
|
||||
String[] values = request.getParameterValues(name);
|
||||
if (values != null && values.length != 0)
|
||||
parameters.put(name, Collections.unmodifiableList(Arrays.asList(values)));
|
||||
|
||||
});
|
||||
|
||||
return Collections.unmodifiableMap(parameters);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable List of all cookies in the given HTTP request.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP request to extract all cookies from.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable List of all cookies in the given request.
|
||||
*/
|
||||
private static List<Cookie> getCookies(HttpServletRequest request) {
|
||||
|
||||
Cookie[] cookies = request.getCookies();
|
||||
if (cookies == null || cookies.length == 0)
|
||||
return Collections.emptyList();
|
||||
|
||||
return Collections.unmodifiableList(Arrays.asList(cookies));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RequestDetails that copies the details of the given HTTP
|
||||
* request. The provided request may safely go out of scope and be reused
|
||||
* for future requests without rendering the content of this RequestDetails
|
||||
* invalid or inaccessible.
|
||||
* <p>
|
||||
* Though an HttpSession will be retrieved from the given request if the
|
||||
* HttpSession already exists on the request, no HttpSession will be created
|
||||
* through invoking this constructor.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP request to copy the details of.
|
||||
*/
|
||||
public RequestDetails(HttpServletRequest request) {
|
||||
this.cookies = getCookies(request);
|
||||
this.headers = getHeaders(request);
|
||||
this.parameters = getParameters(request);
|
||||
this.remoteAddress = request.getRemoteAddr();
|
||||
this.remoteHostname = request.getRemoteHost();
|
||||
this.session = request.getSession(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RequestDetails that copies the details of the given
|
||||
* RequestDetails.
|
||||
*
|
||||
* @param requestDetails
|
||||
* The RequestDetails to copy.
|
||||
*/
|
||||
public RequestDetails(RequestDetails requestDetails) {
|
||||
this.cookies = requestDetails.getCookies();
|
||||
this.headers = requestDetails.getHeaders();
|
||||
this.parameters = requestDetails.getParameters();
|
||||
this.remoteAddress = requestDetails.getRemoteAddress();
|
||||
this.remoteHostname = requestDetails.getRemoteHostname();
|
||||
this.session = requestDetails.getSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first value stored for the given key in the given Map. If no
|
||||
* such key exists in the map, or no values are associated with the given
|
||||
* key, null is returned.
|
||||
*
|
||||
* @param map
|
||||
* A Map of keys to multiple values, where each set of multiple values
|
||||
* is represented by a List.
|
||||
*
|
||||
* @param key
|
||||
* The key to look up.
|
||||
*
|
||||
* @return
|
||||
* The first value stored for the given key in the given Map, or null
|
||||
* if there is no such value or no such key.
|
||||
*/
|
||||
private static String getFirstValue(Map<String, List<String>> map, String key) {
|
||||
|
||||
List<String> values = map.get(key);
|
||||
if (values == null || values.isEmpty())
|
||||
return null;
|
||||
|
||||
return values.get(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the HTTP header having the given name. Header names
|
||||
* are case-insensitive. If no such header was present, null is returned. If
|
||||
* the header had multiple values, the first value is returned.
|
||||
*
|
||||
* @param name
|
||||
* The name of the header to retrieve. This name is case-insensitive.
|
||||
*
|
||||
* @return
|
||||
* The first value of the HTTP header with the given name, or null if
|
||||
* there is no such header.
|
||||
*/
|
||||
public String getHeader(String name) {
|
||||
return getFirstValue(headers, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable List of all values of the HTTP header having the
|
||||
* given name. Header names are case-insensitive. If no such header was
|
||||
* present, the returned List will be empty.
|
||||
*
|
||||
* @param name
|
||||
* The name of the header to retrieve. This name is case-insensitive.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable List of all values of the HTTP header with the
|
||||
* given name, or an empty List if there is no such header.
|
||||
*/
|
||||
public List<String> getHeaders(String name) {
|
||||
return headers.getOrDefault(name, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Set of the names of all HTTP headers present on
|
||||
* the request. If there are no headers, this set will be empty. Header
|
||||
* names are case-insensitive, and the returned Set will perform lookups in
|
||||
* a case-insensitive manner.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Set of the names of all HTTP headers present on the
|
||||
* request.
|
||||
*/
|
||||
public Set<String> getHeaderNames() {
|
||||
return headers.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of all values of all HTTP headers on the
|
||||
* request, where each Map key is a header name. Each Map value is an
|
||||
* unmodifiable List of all values provided for the associated header and
|
||||
* will contain at least one value. Header names are case-insensitive, and
|
||||
* the returned map will perform lookups in a case-insensitive manner.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Map of all values of all HTTP headers on the
|
||||
* request.
|
||||
*/
|
||||
public Map<String, List<String>> getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the HTTP parameter having the given name. Parameter
|
||||
* names are case-sensitive. If no such parameter was present, null is
|
||||
* returned. If the parameter had multiple values, the first value is
|
||||
* returned.
|
||||
*
|
||||
* @param name
|
||||
* The name of the parameter to retrieve. This name is case-sensitive.
|
||||
*
|
||||
* @return
|
||||
* The first value of the HTTP parameter with the given name, or null
|
||||
* if there is no such parameter.
|
||||
*/
|
||||
public String getParameter(String name) {
|
||||
return getFirstValue(parameters, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable List of all values of the HTTP parameter having
|
||||
* the given name. Parameter names are case-sensitive. If no such parameter
|
||||
* was present, the returned List will be empty.
|
||||
*
|
||||
* @param name
|
||||
* The name of the parameter to retrieve. This name is case-sensitive.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable List of all values of the HTTP parameter with the
|
||||
* given name, or an empty List if there is no such parameter.
|
||||
*/
|
||||
public List<String> getParameters(String name) {
|
||||
return parameters.getOrDefault(name, Collections.emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Set of the names of all HTTP parameters present
|
||||
* on the request. If there are no parameters, this set will be empty.
|
||||
* Parameter names are case-sensitive, and the returned Set will perform
|
||||
* lookups in a case-sensitive manner.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Set of the names of all HTTP parameters present on
|
||||
* the request.
|
||||
*/
|
||||
public Set<String> getParameterNames() {
|
||||
return parameters.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable Map of all values of all HTTP parameters on the
|
||||
* request, where each Map key is a parameter name. Each Map value is an
|
||||
* unmodifiable List of all values provided for the associated parameter and
|
||||
* will contain at least one value. Parameter names are case-sensitive, and
|
||||
* the returned map will perform lookups in a case-sensitive manner.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable Map of all values of all HTTP parameters on the
|
||||
* request.
|
||||
*/
|
||||
public Map<String, List<String>> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unmodifiable List of all cookies in the request. If no cookies
|
||||
* are present, the returned List will be empty.
|
||||
*
|
||||
* @return
|
||||
* An unmodifiable List of all cookies in the request, which may an
|
||||
* empty List.
|
||||
*/
|
||||
public List<Cookie> getCookies() {
|
||||
return cookies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HttpSession associated with the request, if any.
|
||||
* <p>
|
||||
* <strong>NOTE: Guacamole itself does not use the HttpSession.</strong>
|
||||
* The extension subsystem does not provide access to the session object
|
||||
* used by Guacamole, which is considered internal. Access to an HttpSession
|
||||
* is only of use if you have another application in place that
|
||||
* <em>does</em> use HttpSession and needs to be considered.
|
||||
*
|
||||
* @return
|
||||
* The HttpSession associated with the request, or null if there is
|
||||
* no HttpSession.
|
||||
*/
|
||||
public HttpSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the client that sent the associated request.
|
||||
*
|
||||
* @return
|
||||
* The address of the client that sent the request.
|
||||
*/
|
||||
public String getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname of the client that sent the associated request, if
|
||||
* known. If the hostname of the client cannot be determined, the address
|
||||
* will be returned instead.
|
||||
*
|
||||
* @return
|
||||
* The hostname or address of the client that sent the request.
|
||||
*/
|
||||
public String getRemoteHostname() {
|
||||
return remoteHostname;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
|
||||
/**
|
||||
* Base implementation of an ActiveConnection, providing storage and simply
|
||||
* getters/setters for its main properties.
|
||||
*/
|
||||
public abstract class AbstractActiveConnection extends AbstractIdentifiable
|
||||
implements ActiveConnection {
|
||||
|
||||
/**
|
||||
* The identifier of the associated connection.
|
||||
*/
|
||||
private String connectionIdentifier;
|
||||
|
||||
/**
|
||||
* The identifier of the associated sharing profile.
|
||||
*/
|
||||
private String sharingProfileIdentifier;
|
||||
|
||||
/**
|
||||
* The date and time this active connection began.
|
||||
*/
|
||||
private Date startDate;
|
||||
|
||||
/**
|
||||
* The remote host that initiated this connection.
|
||||
*/
|
||||
private String remoteHost;
|
||||
|
||||
/**
|
||||
* The username of the user that initiated this connection.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* The underlying GuacamoleTunnel.
|
||||
*/
|
||||
private GuacamoleTunnel tunnel;
|
||||
|
||||
@Override
|
||||
public String getConnectionIdentifier() {
|
||||
return connectionIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionIdentifier(String connnectionIdentifier) {
|
||||
this.connectionIdentifier = connnectionIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSharingProfileIdentifier() {
|
||||
return sharingProfileIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSharingProfileIdentifier(String sharingProfileIdentifier) {
|
||||
this.sharingProfileIdentifier = sharingProfileIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDate(Date startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemoteHost(String remoteHost) {
|
||||
this.remoteHost = remoteHost;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel getTunnel() {
|
||||
return tunnel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTunnel(GuacamoleTunnel tunnel) {
|
||||
this.tunnel = tunnel;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* Base implementation of an ActivityLog, providing storage and simple
|
||||
* getters/setters for its main properties.
|
||||
*/
|
||||
public abstract class AbstractActivityLog implements ActivityLog {
|
||||
|
||||
/**
|
||||
* The type of this ActivityLog.
|
||||
*/
|
||||
private final Type type;
|
||||
|
||||
/**
|
||||
* A human-readable description of this log.
|
||||
*/
|
||||
private final TranslatableMessage description;
|
||||
|
||||
/**
|
||||
* Creates a new AbstractActivityLog having the given type and
|
||||
* human-readable description.
|
||||
*
|
||||
* @param type
|
||||
* The type of this ActivityLog.
|
||||
*
|
||||
* @param description
|
||||
* A human-readable message that describes this log.
|
||||
*/
|
||||
public AbstractActivityLog(Type type, TranslatableMessage description) {
|
||||
this.type = type;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TranslatableMessage getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.environment.Environment;
|
||||
import org.apache.guacamole.environment.LocalEnvironment;
|
||||
|
||||
/**
|
||||
* Basic implementation of an AuthenticatedUser which uses the username to
|
||||
* determine equality. Username comparison is case-sensitive.
|
||||
*/
|
||||
public abstract class AbstractAuthenticatedUser extends AbstractIdentifiable
|
||||
implements AuthenticatedUser {
|
||||
|
||||
/**
|
||||
* Creates a new AbstractAuthenticatedUser that considers usernames to be
|
||||
* case-sensitive or case-insensitive based on the provided case sensitivity
|
||||
* flag.
|
||||
*
|
||||
* @param caseSensitive
|
||||
* true if usernames should be considered case-sensitive, false
|
||||
* otherwise.
|
||||
*/
|
||||
public AbstractAuthenticatedUser(boolean caseSensitive) {
|
||||
super(caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractAuthenticatedUser that considers usernames to be
|
||||
* case-sensitive or case-insensitive based on the case sensitivity setting
|
||||
* of the provided {@link Environment}, as returned by
|
||||
* {@link Environment#getCaseSensitivity()}.
|
||||
*
|
||||
* @param environment
|
||||
* The Environment that should determine whether this
|
||||
* AbstractAuthenticatedUser considers usernames to be case-sensitive.
|
||||
*/
|
||||
public AbstractAuthenticatedUser(Environment environment) {
|
||||
this(environment.getCaseSensitivity().caseSensitiveUsernames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractAuthenticatedUser that considers usernames to be
|
||||
* case-sensitive or case-insensitive based on the case sensitivity setting
|
||||
* of an instance of {@link LocalEnvironment}, as returned by
|
||||
* {@link LocalEnvironment#getCaseSensitivity()}.
|
||||
*/
|
||||
public AbstractAuthenticatedUser() {
|
||||
this(LocalEnvironment.getInstance());
|
||||
}
|
||||
|
||||
// Prior functionality now resides within AbstractIdentifiable
|
||||
|
||||
@Override
|
||||
public Set<String> getEffectiveUserGroups() {
|
||||
return Collections.<String>emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
// Nothing to invalidate
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Base implementation of AuthenticationProvider which provides default
|
||||
* implementations of most functions. Implementations must provide their
|
||||
* own {@link #getIdentifier()}, but otherwise need only override an implemented
|
||||
* function if they wish to actually implement the functionality defined for
|
||||
* that function by the AuthenticationProvider interface.
|
||||
*/
|
||||
public abstract class AbstractAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns {@code null}. Implementations that
|
||||
* wish to expose REST resources which are not specific to a user's session
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Object getResource() throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns the provided {@code credentials}
|
||||
* without performing any updates. Implementations that wish to perform
|
||||
* credential updates for in-progress authentication requests should
|
||||
* override this function.
|
||||
*/
|
||||
@Override
|
||||
public Credentials updateCredentials(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation performs no authentication whatsoever, ignoring
|
||||
* the provided {@code credentials} and simply returning {@code null}. Any
|
||||
* authentication attempt will thus fall through to other
|
||||
* {@link AuthenticationProvider} implementations, perhaps within other
|
||||
* installed extensions, with this {@code AuthenticationProvider} making no
|
||||
* claim regarding the user's identity nor whether the user should be
|
||||
* allowed or disallowed from accessing Guacamole. Implementations that wish
|
||||
* to authenticate users should override this function.
|
||||
*/
|
||||
@Override
|
||||
public AuthenticatedUser authenticateUser(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns the provided
|
||||
* {@code authenticatedUser} without modification. Implementations that
|
||||
* wish to update a user's {@link AuthenticatedUser} object with respect to
|
||||
* new {@link Credentials} received in requests which follow the initial,
|
||||
* successful authentication attempt should override this function.
|
||||
*/
|
||||
@Override
|
||||
public AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException {
|
||||
return authenticatedUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns {@code null}, effectively allowing
|
||||
* authentication to continue but refusing to provide data for the given
|
||||
* user. Implementations that wish to veto the authentication results of
|
||||
* other {@link AuthenticationProvider} implementations or provide data for
|
||||
* authenticated users should override this function.
|
||||
*/
|
||||
@Override
|
||||
public UserContext getUserContext(AuthenticatedUser authenticatedUser)
|
||||
throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns the provided {@code context}
|
||||
* without modification. Implementations that wish to update a user's
|
||||
* {@link UserContext} object with respect to newly-updated
|
||||
* {@link AuthenticatedUser} or {@link Credentials} (such as those received
|
||||
* in requests which follow the initial, successful authentication attempt)
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public UserContext updateUserContext(UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns the provided {@code context}
|
||||
* without performing any decoration. Implementations that wish to augment
|
||||
* the functionality or data provided by other
|
||||
* {@link AuthenticationProvider} implementations should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public UserContext decorate(UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException {
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply invokes
|
||||
* {@link #decorate(UserContext,AuthenticatedUser,Credentials)} with the
|
||||
* provided {@code context}, {@code authenticatedUser}, and
|
||||
* {@code credentials}. Implementations which override
|
||||
* {@link #decorate(UserContext,AuthenticatedUser,Credentials)} and which
|
||||
* need to update their existing decorated object following possible
|
||||
* updates to the {@link UserContext} or {@link AuthenticatedUser} (rather
|
||||
* than generate an entirely new decorated object) should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public UserContext redecorate(UserContext decorated, UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException {
|
||||
return decorate(context, authenticatedUser, credentials);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation does nothing. Implementations that wish to perform
|
||||
* cleanup tasks when the {@link AuthenticationProvider} is being unloaded
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public void shutdown() {
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
* Basic implementation of a Guacamole connection.
|
||||
*/
|
||||
public abstract class AbstractConnection extends AbstractIdentifiable
|
||||
implements Connection {
|
||||
|
||||
/**
|
||||
* The name associated with this connection.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
/**
|
||||
* The unique identifier of the parent ConnectionGroup for
|
||||
* this Connection.
|
||||
*/
|
||||
private String parentIdentifier;
|
||||
|
||||
/**
|
||||
* The GuacamoleConfiguration associated with this connection.
|
||||
*/
|
||||
private GuacamoleConfiguration configuration;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentIdentifier() {
|
||||
return parentIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentIdentifier(String parentIdentifier) {
|
||||
this.parentIdentifier = parentIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleConfiguration getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration(GuacamoleConfiguration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSharingProfileIdentifiers()
|
||||
throws GuacamoleException {
|
||||
return Collections.<String>emptySet();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* Basic implementation of a Guacamole connection group.
|
||||
*/
|
||||
public abstract class AbstractConnectionGroup extends AbstractIdentifiable
|
||||
implements ConnectionGroup {
|
||||
|
||||
/**
|
||||
* The name associated with this connection group.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The unique identifier of the parent connection group for
|
||||
* this connection group.
|
||||
*/
|
||||
private String parentIdentifier;
|
||||
|
||||
/**
|
||||
* The type of this connection group.
|
||||
*/
|
||||
private ConnectionGroup.Type type;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentIdentifier() {
|
||||
return parentIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentIdentifier(String parentIdentifier) {
|
||||
this.parentIdentifier = parentIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionGroup.Type getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(ConnectionGroup.Type type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.properties.CaseSensitivity;
|
||||
|
||||
/**
|
||||
* Abstract implementation of Identifiable which provides equals() and
|
||||
* hashCode() implementations which use the identifier to determine equality.
|
||||
* The identifier comparison is case-sensitive unless configured otherwise via
|
||||
* the {@link AbstractIdentifiable#AbstractIdentifiable(boolean)} constructor.
|
||||
*
|
||||
* If using case-insensitive identifiers, any identifiers that are retrieved
|
||||
* from or assigned to this object will first be canonicalized to a
|
||||
* case-insensitive form using {@link CaseSensitivity#canonicalize(java.lang.String, boolean)}.
|
||||
*/
|
||||
public abstract class AbstractIdentifiable implements Identifiable {
|
||||
|
||||
/**
|
||||
* The unique string which identifies this object.
|
||||
*/
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* Whether this object's identifier should be compared in a case-sensitive
|
||||
* manner. If NOT case-sensitive, the identifier will be transformed into a
|
||||
* canonical, case-insensitive form before use, including during assignment
|
||||
* and retrieval. This affects the behavior of getIdentifier() and
|
||||
* setIdentifier().
|
||||
*/
|
||||
private final boolean caseSensitive;
|
||||
|
||||
/**
|
||||
* Creates a new AbstractIdentifiable that compares identifiers according
|
||||
* to the provided case sensitivity flag. If using case-insensitive
|
||||
* identifiers, any identifiers that are retrieved from or assigned to this
|
||||
* object will first be canonicalized to a case-insensitive form using
|
||||
* {@link CaseSensitivity#canonicalize(java.lang.String, boolean)}.
|
||||
*
|
||||
* @param caseSensitive
|
||||
* true if identifiers should be compared in a case-sensitive manner,
|
||||
* false otherwise.
|
||||
*/
|
||||
public AbstractIdentifiable(boolean caseSensitive) {
|
||||
this.caseSensitive = caseSensitive;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractIdentifiable that compares identifiers in a
|
||||
* case-sensitive manner. This is equivalent to invoking {@link #AbstractIdentifiable(boolean)}
|
||||
* with the case sensitivity flag set to true.
|
||||
*/
|
||||
public AbstractIdentifiable() {
|
||||
this(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return CaseSensitivity.canonicalize(identifier, caseSensitive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = CaseSensitivity.canonicalize(identifier, caseSensitive);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
String thisIdentifier = getIdentifier();
|
||||
if (thisIdentifier == null)
|
||||
return 0;
|
||||
|
||||
return thisIdentifier.hashCode();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
|
||||
// Not equal if null or not the same type of object
|
||||
if (other == null || getClass() != other.getClass())
|
||||
return false;
|
||||
|
||||
// Get identifiers of objects being compared
|
||||
String thisIdentifier = getIdentifier();
|
||||
String otherIdentifier = ((AbstractIdentifiable) other).getIdentifier();
|
||||
|
||||
// If null, equal only if this identifier is null
|
||||
if (otherIdentifier == null)
|
||||
return thisIdentifier == null;
|
||||
|
||||
// Otherwise, equal only if strings are identical
|
||||
return otherIdentifier.equals(thisIdentifier);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Base implementation of a sharing profile which can be used to share a
|
||||
* Guacamole connection.
|
||||
*/
|
||||
public abstract class AbstractSharingProfile implements SharingProfile {
|
||||
|
||||
/**
|
||||
* The human-readable name of this sharing profile.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The unique identifier associated with this sharing profile.
|
||||
*/
|
||||
private String identifier;
|
||||
|
||||
/**
|
||||
* The identifier of the primary connection that this sharing profile can
|
||||
* be used to share.
|
||||
*/
|
||||
private String primaryConnectionIdentifier;
|
||||
|
||||
/**
|
||||
* All connection parameters with this sharing profile.
|
||||
*/
|
||||
private final Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryConnectionIdentifier() {
|
||||
return primaryConnectionIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryConnectionIdentifier(String primaryConnectionIdentifier) {
|
||||
this.primaryConnectionIdentifier = primaryConnectionIdentifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters.clear();
|
||||
this.parameters.putAll(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (identifier == null) return 0;
|
||||
return identifier.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
// Not equal if null or not an SharingProfile
|
||||
if (obj == null) return false;
|
||||
if (!(obj instanceof AbstractSharingProfile)) return false;
|
||||
|
||||
// Get identifier
|
||||
String objIdentifier = ((AbstractSharingProfile) obj).identifier;
|
||||
|
||||
// If null, equal only if this identifier is null
|
||||
if (objIdentifier == null) return identifier == null;
|
||||
|
||||
// Otherwise, equal only if strings are identical
|
||||
return objIdentifier.equals(identifier);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.environment.Environment;
|
||||
import org.apache.guacamole.environment.LocalEnvironment;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
|
||||
/**
|
||||
* Base implementation of User which provides default implementations of
|
||||
* most functions.
|
||||
*/
|
||||
public abstract class AbstractUser extends AbstractIdentifiable
|
||||
implements User {
|
||||
|
||||
/**
|
||||
* This user's password. Note that while this provides a means for the
|
||||
* password to be set, the data stored in this String is not necessarily
|
||||
* the user's actual password. It may be hashed, it may be arbitrary.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUser that considers usernames to be case-sensitive
|
||||
* or case-insensitive based on the provided case sensitivity flag.
|
||||
*
|
||||
* @param caseSensitive
|
||||
* true if usernames should be considered case-sensitive, false
|
||||
* otherwise.
|
||||
*/
|
||||
public AbstractUser(boolean caseSensitive) {
|
||||
super(caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUser that considers usernames to be case-sensitive
|
||||
* or case-insensitive based on the case sensitivity setting of the provided
|
||||
* {@link Environment}, as returned by {@link Environment#getCaseSensitivity()}.
|
||||
*
|
||||
* @param environment
|
||||
* The Environment that should determine whether this AbstractUser
|
||||
* considers usernames to be case-sensitive.
|
||||
*/
|
||||
public AbstractUser(Environment environment) {
|
||||
this(environment.getCaseSensitivity().caseSensitiveUsernames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUser that considers usernames to be case-sensitive
|
||||
* or case-insensitive based on the case sensitivity setting of an instance
|
||||
* of {@link LocalEnvironment}, as returned by @link LocalEnvironment#getCaseSensitivity()}.
|
||||
*/
|
||||
public AbstractUser() {
|
||||
this(LocalEnvironment.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty map. Implementations
|
||||
* that wish to expose custom attributes should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply ignores all attributes given.
|
||||
* Implementations that wish to support modification of custom attributes
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
// Ignore all attributes by default
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns {@code null}. Implementations that
|
||||
* wish to expose the date and time that a user was last active should
|
||||
* override this function.
|
||||
*/
|
||||
@Override
|
||||
public Date getLastActive() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public SystemPermissionSet getSystemPermissions()
|
||||
throws GuacamoleException {
|
||||
return SystemPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getUserPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getUserGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getSharingProfilePermissions() {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty related object set.
|
||||
* Implementations that wish to expose group membership should override
|
||||
* this function.
|
||||
*/
|
||||
@Override
|
||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||
return RelatedObjectSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns {@code this}. Implementations that
|
||||
* wish to expose permissions which apply indirectly (such as through
|
||||
* group inheritance) should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Permissions getEffectivePermissions() throws GuacamoleException {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,269 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.form.Form;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleActivityRecordSet;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleConnectionGroup;
|
||||
import org.apache.guacamole.net.auth.simple.SimpleDirectory;
|
||||
|
||||
/**
|
||||
* Base implementation of UserContext which provides default implementations of
|
||||
* most functions. Implementations must provide their own {@link #self()} and
|
||||
* {@link #getAuthenticationProvider()}, but otherwise need only override an
|
||||
* implemented function if they wish to actually implement the functionality
|
||||
* defined for that function by the UserContext interface.
|
||||
*/
|
||||
public abstract class AbstractUserContext implements UserContext {
|
||||
|
||||
/**
|
||||
* The unique identifier that will be used for the root connection group if
|
||||
* {@link #getRootConnectionGroup()} is not overridden.
|
||||
*/
|
||||
protected static final String DEFAULT_ROOT_CONNECTION_GROUP = "ROOT";
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns {@code null}. Implementations that
|
||||
* wish to expose REST resources specific to a user's session should
|
||||
* override this function.
|
||||
*/
|
||||
@Override
|
||||
public Object getResource() throws GuacamoleException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation returns a {@link Directory} which contains only
|
||||
* the {@link User} returned by {@link #self()} (the current user
|
||||
* associated with this {@link UserContext}. Implementations that wish to
|
||||
* expose the existence of other users should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Directory<User> getUserDirectory() throws GuacamoleException {
|
||||
return new SimpleDirectory<User>(self());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Directory}.
|
||||
* Implementations that wish to expose user groups should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public Directory<UserGroup> getUserGroupDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<UserGroup>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Directory}.
|
||||
* Implementations that wish to expose connections should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public Directory<Connection> getConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<Connection>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation returns a {@link Directory} which contains only
|
||||
* the root connection group returned by {@link #getRootConnectionGroup()}.
|
||||
* Implementations that wish to provide a structured connection hierarchy
|
||||
* should override this function. If only a flat list of connections will
|
||||
* be used, only {@link #getConnectionDirectory()} needs to be overridden.
|
||||
*/
|
||||
@Override
|
||||
public Directory<ConnectionGroup> getConnectionGroupDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<ConnectionGroup>(getRootConnectionGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Directory}.
|
||||
* Implementations that wish to expose the status of active connections
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Directory<ActiveConnection> getActiveConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<ActiveConnection>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Directory}.
|
||||
* Implementations that wish to provide screen sharing functionality
|
||||
* through the use of sharing profiles should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Directory<SharingProfile> getSharingProfileDirectory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleDirectory<SharingProfile>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link ActivityRecordSet}.
|
||||
* Implementations that wish to expose connection usage history should
|
||||
* override this function.
|
||||
*/
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleActivityRecordSet<ConnectionRecord>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link ActivityRecordSet}.
|
||||
* Implementations that wish to expose user login/logout history should
|
||||
* override this function.
|
||||
*/
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
return new SimpleActivityRecordSet<ActivityRecord>();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation returns a new {@link ConnectionGroup} with the
|
||||
* identifier defined by {@link #DEFAULT_ROOT_CONNECTION_GROUP} and
|
||||
* containing all connections exposed by the {@link Directory} returned by
|
||||
* {@link #getConnectionDirectory()}. Implementations that wish to provide
|
||||
* a structured connection hierarchy should override this function. If only
|
||||
* a flat list of connections will be used, only
|
||||
* {@link #getConnectionDirectory()} needs to be overridden.
|
||||
*/
|
||||
@Override
|
||||
public ConnectionGroup getRootConnectionGroup()
|
||||
throws GuacamoleException {
|
||||
return new SimpleConnectionGroup(
|
||||
DEFAULT_ROOT_CONNECTION_GROUP,
|
||||
DEFAULT_ROOT_CONNECTION_GROUP,
|
||||
getConnectionDirectory().getIdentifiers(),
|
||||
Collections.<String>emptySet()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Collection}.
|
||||
* Implementations that wish to expose custom user attributes as fields
|
||||
* within user edit screens should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Form> getUserAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Collection}.
|
||||
* Implementations that wish to expose custom user group attributes as
|
||||
* fields within user group edit screens should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Form> getUserGroupAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Collection}.
|
||||
* Implementations that wish to expose custom connection attributes as
|
||||
* fields within connection edit screens should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Form> getConnectionAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Collection}.
|
||||
* Implementations that wish to expose custom connection group attributes
|
||||
* as fields within connection group edit screens should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Form> getConnectionGroupAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns an empty {@link Collection}.
|
||||
* Implementations that wish to expose custom sharing profile attributes as
|
||||
* fields within sharing profile edit screens should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Collection<Form> getSharingProfileAttributes() {
|
||||
return Collections.<Form>emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation does nothing. Implementations that wish to perform
|
||||
* cleanup tasks when the user associated with this {@link UserContext} is
|
||||
* being logged out should override this function.
|
||||
*/
|
||||
@Override
|
||||
public void invalidate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply returns <code>this</code>. Implementations
|
||||
* that wish to provide additional privileges to extensions requesting
|
||||
* privileged access should override this function.
|
||||
*/
|
||||
@Override
|
||||
public UserContext getPrivileged() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,222 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.environment.Environment;
|
||||
import org.apache.guacamole.environment.LocalEnvironment;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
|
||||
/**
|
||||
* Base implementation of UserGroup which provides default implementations of
|
||||
* most functions.
|
||||
*/
|
||||
public abstract class AbstractUserGroup extends AbstractIdentifiable implements UserGroup {
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUserGroup that considers group names to be
|
||||
* case-sensitive or case-insensitive based on the provided case
|
||||
* sensitivity flag.
|
||||
*
|
||||
* @param caseSensitive
|
||||
* true if group names should be considered case-sensitive, false
|
||||
* otherwise.
|
||||
*/
|
||||
public AbstractUserGroup(boolean caseSensitive) {
|
||||
super(caseSensitive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUserGroup that considers group names to be
|
||||
* case-sensitive or case-insensitive based on the case sensitivity setting
|
||||
* of the provided {@link Environment}, as returned by
|
||||
* {@link Environment#getCaseSensitivity()}.
|
||||
*
|
||||
* @param environment
|
||||
* The Environment that should determine whether this AbstractUserGroup
|
||||
* considers group names to be case-sensitive.
|
||||
*/
|
||||
public AbstractUserGroup(Environment environment) {
|
||||
this(environment.getCaseSensitivity().caseSensitiveGroupNames());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AbstractUserGroup that considers group names to be
|
||||
* case-sensitive or case-insensitive based on the case sensitivity setting
|
||||
* of an instance of {@link LocalEnvironment}, as returned by
|
||||
* {@link LocalEnvironment#getCaseSensitivity()}.
|
||||
*/
|
||||
public AbstractUserGroup() {
|
||||
this(LocalEnvironment.getInstance());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty map. Implementations
|
||||
* that wish to expose custom attributes should override this function.
|
||||
*/
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply ignores all attributes given.
|
||||
* Implementations that wish to support modification of custom attributes
|
||||
* should override this function.
|
||||
*/
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
// Ignore all attributes by default
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public SystemPermissionSet getSystemPermissions()
|
||||
throws GuacamoleException {
|
||||
return SystemPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getUserPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getUserGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty permission set.
|
||||
* Implementations that wish to expose permissions should override this
|
||||
* function.
|
||||
*/
|
||||
@Override
|
||||
public ObjectPermissionSet getSharingProfilePermissions() {
|
||||
return ObjectPermissionSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty related object set.
|
||||
* Implementations that wish to expose group membership should override
|
||||
* this function.
|
||||
*/
|
||||
@Override
|
||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||
return RelatedObjectSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty related object set.
|
||||
* Implementations that wish to expose group membership should override
|
||||
* this function.
|
||||
*/
|
||||
@Override
|
||||
public RelatedObjectSet getMemberUsers() throws GuacamoleException {
|
||||
return RelatedObjectSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>This implementation simply an immutable, empty related object set.
|
||||
* Implementations that wish to expose group membership should override
|
||||
* this function.
|
||||
*/
|
||||
@Override
|
||||
public RelatedObjectSet getMemberUserGroups() throws GuacamoleException {
|
||||
return RelatedObjectSet.EMPTY_SET;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleSecurityException;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
|
||||
/**
|
||||
* A pairing of username and GuacamoleTunnel representing an active usage of a
|
||||
* particular connection.
|
||||
*/
|
||||
public interface ActiveConnection extends Identifiable, Connectable,
|
||||
Shareable<SharingProfile> {
|
||||
|
||||
/**
|
||||
* Returns the identifier of the connection being actively used. Unlike the
|
||||
* other information stored in this object, the connection identifier must
|
||||
* be present and MAY NOT be null.
|
||||
*
|
||||
* @return
|
||||
* The identifier of the connection being actively used.
|
||||
*/
|
||||
String getConnectionIdentifier();
|
||||
|
||||
/**
|
||||
* Sets the identifier of the connection being actively used.
|
||||
*
|
||||
* @param connnectionIdentifier
|
||||
* The identifier of the connection being actively used.
|
||||
*/
|
||||
void setConnectionIdentifier(String connnectionIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the identifier of the sharing profile being actively used. If
|
||||
* the connection is being accessed directly, this will be null.
|
||||
*
|
||||
* @return
|
||||
* The identifier of the sharing profile being actively used.
|
||||
*/
|
||||
String getSharingProfileIdentifier();
|
||||
|
||||
/**
|
||||
* Sets the identifier of the sharing profile being actively used.
|
||||
*
|
||||
* @param sharingProfileIdentifier
|
||||
* The identifier of the sharing profile being actively used.
|
||||
*/
|
||||
void setSharingProfileIdentifier(String sharingProfileIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the date and time the connection began.
|
||||
*
|
||||
* @return
|
||||
* The date and time the connection began, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
Date getStartDate();
|
||||
|
||||
/**
|
||||
* Sets the date and time the connection began.
|
||||
*
|
||||
* @param startDate
|
||||
* The date and time the connection began, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
void setStartDate(Date startDate);
|
||||
|
||||
/**
|
||||
* Returns the hostname or IP address of the remote host that initiated the
|
||||
* connection, if known. If the hostname or IP address is not known, null
|
||||
* is returned.
|
||||
*
|
||||
* @return
|
||||
* The hostname or IP address of the remote host, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
String getRemoteHost();
|
||||
|
||||
/**
|
||||
* Sets the hostname or IP address of the remote host that initiated the
|
||||
* connection.
|
||||
*
|
||||
* @param remoteHost
|
||||
* The hostname or IP address of the remote host, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
void setRemoteHost(String remoteHost);
|
||||
|
||||
/**
|
||||
* Returns the name of the user who is using this connection.
|
||||
*
|
||||
* @return
|
||||
* The name of the user who is using this connection, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
String getUsername();
|
||||
|
||||
/**
|
||||
* Sets the name of the user who is using this connection.
|
||||
*
|
||||
* @param username
|
||||
* The name of the user who is using this connection, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
void setUsername(String username);
|
||||
|
||||
/**
|
||||
* Returns the connected GuacamoleTunnel being used. This may be null if
|
||||
* access to the underlying tunnel is denied.
|
||||
*
|
||||
* @return
|
||||
* The connected GuacamoleTunnel, or null if permission is denied.
|
||||
*/
|
||||
GuacamoleTunnel getTunnel();
|
||||
|
||||
/**
|
||||
* Sets the connected GuacamoleTunnel being used.
|
||||
*
|
||||
* @param tunnel
|
||||
* The connected GuacamoleTunnel, or null if permission is denied.
|
||||
*/
|
||||
void setTunnel(GuacamoleTunnel tunnel);
|
||||
|
||||
/**
|
||||
* Returns whether this ActiveConnection may be joined through a call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)}
|
||||
* by the user that retrieved this ActiveConnection.
|
||||
*
|
||||
* @return
|
||||
* true if the user that retrieved this ActiveConnection may join the
|
||||
* ActiveConnection through a call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)},
|
||||
* false otherwise.
|
||||
*/
|
||||
default boolean isConnectable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
default GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
throw new GuacamoleSecurityException("Permission denied.");
|
||||
}
|
||||
|
||||
@Override
|
||||
default int getActiveConnections() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.io.InputStream;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* An arbitrary log of an activity whose content may be exposed to a user with
|
||||
* sufficient privileges. Types of content that might be exposed in this way
|
||||
* include textual server logs, Guacamole session recordings, and typescripts.
|
||||
*/
|
||||
public interface ActivityLog {
|
||||
|
||||
/**
|
||||
* The value returned by {@link #getSize()} if the number of available
|
||||
* bytes within {@link #getContent()} is unknown.
|
||||
*/
|
||||
public static final long UNKNOWN_SIZE = -1;
|
||||
|
||||
/**
|
||||
* All possible types of {@link ActivityLog}.
|
||||
*/
|
||||
enum Type {
|
||||
|
||||
/**
|
||||
* A Guacamole session recording in the form of a Guacamole protocol
|
||||
* dump.
|
||||
*/
|
||||
GUACAMOLE_SESSION_RECORDING("application/octet-stream"),
|
||||
|
||||
/**
|
||||
* A text log from a server-side process, such as the Guacamole web
|
||||
* application or guacd.
|
||||
*/
|
||||
SERVER_LOG("text/plain"),
|
||||
|
||||
/**
|
||||
* A text session recording in the form of a standard typescript.
|
||||
*/
|
||||
TYPESCRIPT("application/octet-stream"),
|
||||
|
||||
/**
|
||||
* The timing file related to a typescript.
|
||||
*/
|
||||
TYPESCRIPT_TIMING("text/plain");
|
||||
|
||||
/**
|
||||
* The MIME type of the content of an activity log of this type.
|
||||
*/
|
||||
private final String contentType;
|
||||
|
||||
/**
|
||||
* Creates a new Type that may be associated with content having the
|
||||
* given MIME type.
|
||||
*
|
||||
* @param contentType
|
||||
* The MIME type of the content of an activity log of this type.
|
||||
*/
|
||||
Type(String contentType) {
|
||||
this.contentType = contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the MIME type of the content of an activity log of this
|
||||
* type, as might be sent via the HTTP "Content-Type" header.
|
||||
*
|
||||
* @return
|
||||
* The MIME type of the content of an activity log of this type.
|
||||
*/
|
||||
public String getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of this activity log. The type of an activity log
|
||||
* dictates how its content should be interpreted or exposed.
|
||||
*
|
||||
* @return
|
||||
* The type of this activity log.
|
||||
*/
|
||||
Type getType();
|
||||
|
||||
/**
|
||||
* Returns a human-readable message that describes this log. This message
|
||||
* should provide sufficient information for a user with access to this
|
||||
* log to understand its context and/or purpose.
|
||||
*
|
||||
* @return
|
||||
* A human-readable message that describes this log.
|
||||
*/
|
||||
TranslatableMessage getDescription();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes available for reading within the content of
|
||||
* this log. If this value is unknown, -1 ({@link #UNKNOWN_SIZE}) should be
|
||||
* returned.
|
||||
*
|
||||
* @return
|
||||
* The number of bytes available for reading within the content of
|
||||
* this log, or -1 ({@link #UNKNOWN_SIZE}) if this value is unknown.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the size of the content of this log cannot be determined due to
|
||||
* an error.
|
||||
*/
|
||||
long getSize() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns an InputStream that allows the content of this log to be read.
|
||||
* Multiple instances of this InputStream may be open at any given time. It
|
||||
* is the responsibility of the caller to close the returned InputStream.
|
||||
*
|
||||
* @return
|
||||
* An InputStream that allows the content of this log to be read.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the content of this log cannot be read due to an error.
|
||||
*/
|
||||
InputStream getContent() throws GuacamoleException;
|
||||
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* A logging record describing when a user started and ended a particular
|
||||
* activity.
|
||||
*/
|
||||
public interface ActivityRecord extends ReadableAttributes {
|
||||
|
||||
/**
|
||||
* Returns the date and time the activity began.
|
||||
*
|
||||
* @return
|
||||
* The date and time the activity began.
|
||||
*/
|
||||
public Date getStartDate();
|
||||
|
||||
/**
|
||||
* Returns the date and time the activity ended, if applicable.
|
||||
*
|
||||
* @return
|
||||
* The date and time the activity ended, or null if the activity is
|
||||
* still ongoing or if the end time is unknown.
|
||||
*/
|
||||
public Date getEndDate();
|
||||
|
||||
/**
|
||||
* Returns the hostname or IP address of the remote host that performed the
|
||||
* activity associated with this record, if known. If the hostname or IP
|
||||
* address is not known, null is returned.
|
||||
*
|
||||
* @return
|
||||
* The hostname or IP address of the remote host, or null if this
|
||||
* information is not available.
|
||||
*/
|
||||
public String getRemoteHost();
|
||||
|
||||
/**
|
||||
* Returns the name of the user who performed or is performing the activity
|
||||
* at the times given by this record.
|
||||
*
|
||||
* @return
|
||||
* The name of the user who performed or is performing the associated
|
||||
* activity.
|
||||
*/
|
||||
public String getUsername();
|
||||
|
||||
/**
|
||||
* Returns whether the activity associated with this record is still
|
||||
* ongoing.
|
||||
*
|
||||
* @return
|
||||
* true if the activity associated with this record is still ongoing,
|
||||
* false otherwise.
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/**
|
||||
* Returns the unique identifier assigned to this record, if any. If this
|
||||
* record is not uniquely identifiable, this may be null. If provided, this
|
||||
* unique identifier MUST be unique across all {@link ActivityRecord}
|
||||
* objects within the same {@link ActivityRecordSet}.
|
||||
*
|
||||
* @return
|
||||
* The unique identifier assigned to this record, or null if this
|
||||
* record has no such identifier.
|
||||
*/
|
||||
public default String getIdentifier() {
|
||||
UUID uuid = getUUID();
|
||||
return uuid != null ? uuid.toString() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a UUID that uniquely identifies this record. If provided, this
|
||||
* UUID MUST be deterministic and unique across all {@link ActivityRecord}
|
||||
* objects within the same {@link ActivityRecordSet}, and SHOULD be unique
|
||||
* across all {@link ActivityRecord} objects.
|
||||
*
|
||||
* @return
|
||||
* A UUID that uniquely identifies this record, or null if no such
|
||||
* unique identifier exists.
|
||||
*/
|
||||
public default UUID getUUID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Map of logs related to this record and accessible by the
|
||||
* current user, such as Guacamole session recordings. Each log is
|
||||
* associated with a corresponding, arbitrary, unique name. If the user
|
||||
* does not have access to any logs, or if no logs are available, this may
|
||||
* be an empty map.
|
||||
*
|
||||
* @return
|
||||
* A Map of logs related to this record.
|
||||
*/
|
||||
public default Map<String, ActivityLog> getLogs() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public default Map<String, String> getAttributes() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* A set of all available records related to a type of activity which has a
|
||||
* defined start and end time, such as a user being logged in or connected, or a
|
||||
* subset of those records.
|
||||
*
|
||||
* @param <RecordType>
|
||||
* The type of ActivityRecord contained within this set.
|
||||
*/
|
||||
public interface ActivityRecordSet<RecordType extends ActivityRecord> {
|
||||
|
||||
/**
|
||||
* All properties of activity records which can be used as sorting
|
||||
* criteria.
|
||||
*/
|
||||
enum SortableProperty {
|
||||
|
||||
/**
|
||||
* The date and time when the activity associated with the record
|
||||
* began.
|
||||
*/
|
||||
START_DATE
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns all records within this set as a standard Collection.
|
||||
*
|
||||
* @return
|
||||
* A collection containing all records within this set.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the records within this set.
|
||||
*/
|
||||
Collection<RecordType> asCollection() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the record having the given unique identifier, if records within
|
||||
* this set have unique identifiers. If records within this set do not have
|
||||
* defined unique identifiers, this function has no effect.
|
||||
*
|
||||
* @param identifier
|
||||
* The unique identifier of the record to retrieve.
|
||||
*
|
||||
* @return
|
||||
* The record having the given unique identifier, or null if there is
|
||||
* no such record.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the record.
|
||||
*/
|
||||
default RecordType get(String identifier) throws GuacamoleException {
|
||||
return asCollection().stream()
|
||||
.filter((record) -> {
|
||||
String recordIdentifier = record.getIdentifier();
|
||||
return recordIdentifier != null && recordIdentifier.equals(identifier);
|
||||
})
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subset of records which contain the given value. The
|
||||
* properties and semantics involved with determining whether a particular
|
||||
* record "contains" the given value is implementation dependent. This
|
||||
* function may affect the contents of the current ActivityRecordSet. The
|
||||
* contents of the current ActivityRecordSet should NOT be relied upon
|
||||
* after this function is called.
|
||||
*
|
||||
* @param value
|
||||
* The value which all records within the resulting subset should
|
||||
* contain.
|
||||
*
|
||||
* @return
|
||||
* The subset of records which contain the specified value.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while restricting the current subset.
|
||||
*/
|
||||
ActivityRecordSet<RecordType> contains(String value)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the subset of records containing only the first
|
||||
* <code>limit</code> records. If the subset has fewer than
|
||||
* <code>limit</code> records, then this function has no effect. This
|
||||
* function may also affect the contents of the current ActivityRecordSet.
|
||||
* The contents of the current ActivityRecordSet should NOT be relied upon
|
||||
* after this function is called.
|
||||
*
|
||||
* @param limit
|
||||
* The maximum number of records that the new subset should contain.
|
||||
*
|
||||
* @return
|
||||
* The subset of records that containing only the first
|
||||
* <code>limit</code> records.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while limiting the current subset.
|
||||
*/
|
||||
ActivityRecordSet<RecordType> limit(int limit) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns a ActivityRecordSet containing identically the records within
|
||||
* this set, sorted according to the specified criteria. The sort operation
|
||||
* performed is guaranteed to be stable with respect to any past call to
|
||||
* sort(). This function may also affect the contents of the current
|
||||
* ActivityRecordSet. The contents of the current ActivityRecordSet
|
||||
* should NOT be relied upon after this function is called.
|
||||
*
|
||||
* @param property
|
||||
* The property by which the records within the resulting set should be
|
||||
* sorted.
|
||||
*
|
||||
* @param desc
|
||||
* Whether the records should be sorted according to the specified
|
||||
* property in descending order. If false, records will be sorted
|
||||
* according to the specified property in ascending order.
|
||||
*
|
||||
* @return
|
||||
* The ActivityRecordSet, sorted according to the specified criteria.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while sorting the current subset, or if the given
|
||||
* property is not supported by the implementation.
|
||||
*/
|
||||
ActivityRecordSet<RecordType> sort(SortableProperty property, boolean desc)
|
||||
throws GuacamoleException;
|
||||
|
||||
}
|
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* An operation that should be attempted atomically when passed to
|
||||
* {@link Directory#tryAtomically}, if atomic operations are supported by
|
||||
* the Directory.
|
||||
*/
|
||||
public interface AtomicDirectoryOperation<ObjectType extends Identifiable> {
|
||||
|
||||
/**
|
||||
* Attempt the operation atomically. If the Directory does not support
|
||||
* atomic operations, the atomic flag will be set to false. If the atomic
|
||||
* flag is set to true, the provided directory is guaranteed to perform
|
||||
* the operations within this function atomically. Atomicity of the
|
||||
* provided directory outside this function, or of the directory invoking
|
||||
* this function are not guaranteed.
|
||||
*
|
||||
* <p>NOTE: If atomicity is required for this operation, a
|
||||
* GuacamoleException may be thrown by this function before any changes are
|
||||
* made, ensuring the operation will only ever be performed atomically.
|
||||
*
|
||||
* @param atomic
|
||||
* True if the provided directory is guaranteed to perform the operation
|
||||
* atomically within the context of this function.
|
||||
*
|
||||
* @param directory
|
||||
* A directory that will perform the operation atomically if the atomic
|
||||
* flag is set to true. If the flag is false, the directory may still
|
||||
* be used, though atomicity is not guaranteed.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an issue occurs during the operation.
|
||||
*/
|
||||
void executeOperation(boolean atomic, Directory<ObjectType> directory)
|
||||
throws GuacamoleException;
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An object which is associated with a set of arbitrary attributes that may
|
||||
* be modifiable, defined as name/value pairs.
|
||||
*/
|
||||
public interface Attributes extends ReadableAttributes {
|
||||
|
||||
/**
|
||||
* Sets the given attributes. If an attribute within the map is not
|
||||
* supported, it will simply be dropped. Any attributes not within the given
|
||||
* map will be left untouched. Attributes which are not declared within the
|
||||
* associated UserContext MUST NOT be submitted, but other extensions may
|
||||
* manipulate the declared attributes through decorate() and redecorate().
|
||||
*
|
||||
* Implementations may optionally allow storage of unsupported attributes.
|
||||
* Extensions which rely on other extensions to store their attribute
|
||||
* values should verify that such storage is supported by first testing
|
||||
* that the attribute value is retrievable via getAttributes() after being
|
||||
* set.
|
||||
*
|
||||
* @param attributes
|
||||
* A map of all attribute identifiers to their corresponding values.
|
||||
*/
|
||||
void setAttributes(Map<String, String> attributes);
|
||||
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A user of the Guacamole web application who has been authenticated by an
|
||||
* AuthenticationProvider.
|
||||
*/
|
||||
public interface AuthenticatedUser extends Identifiable {
|
||||
|
||||
/**
|
||||
* The identifier reserved for representing a user that has authenticated
|
||||
* anonymously.
|
||||
*/
|
||||
public static final String ANONYMOUS_IDENTIFIER = "";
|
||||
|
||||
/**
|
||||
* Returns the AuthenticationProvider that authenticated this user.
|
||||
*
|
||||
* @return
|
||||
* The AuthenticationProvider that authenticated this user.
|
||||
*/
|
||||
AuthenticationProvider getAuthenticationProvider();
|
||||
|
||||
/**
|
||||
* Returns the credentials that the user provided when they successfully
|
||||
* authenticated.
|
||||
*
|
||||
* @return
|
||||
* The credentials provided by the user when they authenticated.
|
||||
*/
|
||||
Credentials getCredentials();
|
||||
|
||||
/**
|
||||
* Returns a read-only set of the identifiers of all user groups which
|
||||
* apply to this authenticated user. The exact semantics of what user
|
||||
* groups apply are up to the implementation, and the user groups within
|
||||
* this set may be implied, derived dynamically, inherited through multiple
|
||||
* levels of group membership, etc.
|
||||
*
|
||||
* Note that, as with user identifiers, user group identifiers form the
|
||||
* basis of identity which applies across authentication providers. It is
|
||||
* expected that any two user groups having the same identifier represent
|
||||
* the same group, even if defined by different authentication providers.
|
||||
*
|
||||
* @return
|
||||
* A read-only set of the identifiers of all user groups which apply
|
||||
* to this authenticated user.
|
||||
*/
|
||||
Set<String> getEffectiveUserGroups();
|
||||
|
||||
/**
|
||||
* Invalidates this authenticated user and their associated token such that
|
||||
* they are no longer logged in. This function will be automatically
|
||||
* invoked when the user logs out, or when their session expires.
|
||||
*/
|
||||
void invalidate();
|
||||
|
||||
}
|
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Provides means of authorizing users and for accessing and managing data
|
||||
* associated with those users. Access to such data is limited according to the
|
||||
* AuthenticationProvider implementation.
|
||||
*/
|
||||
public interface AuthenticationProvider {
|
||||
|
||||
/**
|
||||
* Returns the identifier which uniquely and consistently identifies this
|
||||
* AuthenticationProvider implementation. This identifier may not be null
|
||||
* and must be unique across all AuthenticationProviders loaded by the
|
||||
* Guacamole web application.
|
||||
*
|
||||
* @return
|
||||
* The unique identifier assigned to this AuthenticationProvider, which
|
||||
* may not be null.
|
||||
*/
|
||||
String getIdentifier();
|
||||
|
||||
/**
|
||||
* Returns an arbitrary REST resource representing this
|
||||
* AuthenticationProvider. The REST resource returned must be properly
|
||||
* annotated with JSR-311 annotations, and may serve as the root resource
|
||||
* for any number of subresources. The returned resource is ultimately
|
||||
* exposed at ".../api/ext/IDENTIFIER/", where IDENTIFIER is the identifier
|
||||
* of this AuthenticationProvider.
|
||||
*
|
||||
* REST resources returned by this function will be reachable by all users,
|
||||
* regardless of whether they have authenticated. REST resources which
|
||||
* must only be accessible by authenticated users should instead be returned
|
||||
* from UserContext.getResource().
|
||||
*
|
||||
* @return
|
||||
* An arbitrary REST resource, annotated with JSR-311 annotations, or
|
||||
* null if no such resource is defined.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the REST resource cannot be returned due to an error.
|
||||
*/
|
||||
Object getResource() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given the set of credentials that a user has submitted during
|
||||
* authentication but has not yet been provided to the
|
||||
* {@link #authenticateUser(org.apache.guacamole.net.auth.Credentials)} or
|
||||
* {@link #updateAuthenticatedUser(org.apache.guacamole.net.auth.AuthenticatedUser, org.apache.guacamole.net.auth.Credentials)}
|
||||
* functions of installed AuthenticationProviders, returns the set of
|
||||
* credentials that should be used instead. The returned credentials may
|
||||
* be the original credentials, with or without modifications, or may be an
|
||||
* entirely new {@link Credentials} object.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials provided by a user during authentication.
|
||||
*
|
||||
* @return
|
||||
* The set of credentials that should be provided to all
|
||||
* AuthenticationProviders, including this AuthenticationProvider. This
|
||||
* set of credentials may optionally be entirely new or may have been
|
||||
* modified.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while updating the provided credentials.
|
||||
*/
|
||||
default Credentials updateCredentials(Credentials credentials)
|
||||
throws GuacamoleException {
|
||||
return credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an AuthenticatedUser representing the user authenticated by the
|
||||
* given credentials, if any.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials to use for authentication.
|
||||
*
|
||||
* @return
|
||||
* An AuthenticatedUser representing the user authenticated by the
|
||||
* given credentials, if any, or null if the credentials are invalid.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while authenticating the user, or if access is
|
||||
* temporarily, permanently, or conditionally denied, such as if the
|
||||
* supplied credentials are insufficient or invalid.
|
||||
*/
|
||||
AuthenticatedUser authenticateUser(Credentials credentials)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns a new or updated AuthenticatedUser for the given credentials
|
||||
* already having produced the given AuthenticatedUser. Note that because
|
||||
* this function will be called for all future requests after initial
|
||||
* authentication, including tunnel requests, care must be taken to avoid
|
||||
* using functions of HttpServletRequest which invalidate the entire request
|
||||
* body, such as getParameter(). Doing otherwise may cause the
|
||||
* GuacamoleHTTPTunnelServlet to fail.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials to use for authentication.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* An AuthenticatedUser object representing the user authenticated by
|
||||
* an arbitrary set of credentials. The AuthenticatedUser may come from
|
||||
* this AuthenticationProvider or any other installed
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @return
|
||||
* An updated AuthenticatedUser representing the user authenticated by
|
||||
* the given credentials, if any, or null if the credentials are
|
||||
* invalid.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while updating the AuthenticatedUser.
|
||||
*/
|
||||
AuthenticatedUser updateAuthenticatedUser(AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the UserContext of the user authenticated by the given
|
||||
* credentials.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* An AuthenticatedUser object representing the user authenticated by
|
||||
* an arbitrary set of credentials. The AuthenticatedUser may come from
|
||||
* this AuthenticationProvider or any other installed
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @return
|
||||
* A UserContext describing the permissions, connection, connection
|
||||
* groups, etc. accessible or associated with the given authenticated
|
||||
* user, or null if this AuthenticationProvider refuses to provide any
|
||||
* such data.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while creating the UserContext.
|
||||
*/
|
||||
UserContext getUserContext(AuthenticatedUser authenticatedUser)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns a new or updated UserContext for the given AuthenticatedUser
|
||||
* already having the given UserContext. Note that because this function
|
||||
* will be called for all future requests after initial authentication,
|
||||
* including tunnel requests, care must be taken to avoid using functions
|
||||
* of HttpServletRequest which invalidate the entire request body, such as
|
||||
* getParameter(). Doing otherwise may cause the GuacamoleHTTPTunnelServlet
|
||||
* to fail.
|
||||
*
|
||||
* @param context
|
||||
* The existing UserContext belonging to the user in question.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* An AuthenticatedUser object representing the user authenticated by
|
||||
* an arbitrary set of credentials. The AuthenticatedUser may come from
|
||||
* this AuthenticationProvider or any other installed
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials which were most recently submitted. These are not
|
||||
* guaranteed to be the same as the credentials associated with the
|
||||
* AuthenticatedUser when they originally authenticated.
|
||||
*
|
||||
* @return
|
||||
* An updated UserContext describing the permissions, connection,
|
||||
* connection groups, etc. accessible or associated with the given
|
||||
* authenticated user, or null if this AuthenticationProvider refuses
|
||||
* to provide any such data.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while updating the UserContext.
|
||||
*/
|
||||
UserContext updateUserContext(UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given a UserContext returned from getUserContext() of a different
|
||||
* AuthenticationProvider, returns a UserContext instance which decorates
|
||||
* (wraps) that UserContext, delegating and overriding implemented
|
||||
* functions as necessary. Each UserContext created via getUserContext()
|
||||
* will be passed to the decorate() functions of all other
|
||||
* AuthenticationProviders, allowing those AuthenticationProviders to
|
||||
* augment (or perhaps even limit) the functionality or data provided.
|
||||
*
|
||||
* @param context
|
||||
* An existing UserContext generated by getUserContext() of a different
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* The AuthenticatedUser object representing the user associated with
|
||||
* the given UserContext.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials which were most recently submitted for the given
|
||||
* AuthenticatedUser. These are not guaranteed to be the same as the
|
||||
* credentials associated with the AuthenticatedUser object, which are
|
||||
* the credentials provided when the user originally authenticated.
|
||||
*
|
||||
* @return
|
||||
* A decorated (wrapped) UserContext object, or the original,
|
||||
* undecorated UserContext.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the UserContext cannot be decorated due to an error.
|
||||
*/
|
||||
UserContext decorate(UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given a UserContext returned by updateUserContext() of a different
|
||||
* AuthenticationProvider, returns a UserContext instance which decorates
|
||||
* (wraps) that UserContext, delegating and overriding implemented
|
||||
* functions as necessary. Each UserContext created via updateUserContext()
|
||||
* will be passed to the decorate() functions of all other
|
||||
* AuthenticationProviders, allowing those AuthenticationProviders to
|
||||
* augment (or perhaps even limit) the functionality or data provided.
|
||||
*
|
||||
* @param decorated
|
||||
* The UserContext returned when decorate() was invoked on this
|
||||
* AuthenticationProvider for the UserContext which was just updated
|
||||
* via a call to updateUserContext().
|
||||
*
|
||||
* @param context
|
||||
* An existing UserContext generated by updateUserContext() of a
|
||||
* different AuthenticationProvider.
|
||||
*
|
||||
* @param authenticatedUser
|
||||
* The AuthenticatedUser object representing the user associated with
|
||||
* the given UserContext.
|
||||
*
|
||||
* @param credentials
|
||||
* The credentials which were most recently submitted for the given
|
||||
* AuthenticatedUser. These are not guaranteed to be the same as the
|
||||
* credentials associated with the AuthenticatedUser object, which are
|
||||
* the credentials provided when the user originally authenticated.
|
||||
*
|
||||
* @return
|
||||
* A decorated (wrapped) UserContext object, or the original,
|
||||
* undecorated UserContext.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the UserContext cannot be decorated due to an error.
|
||||
*/
|
||||
UserContext redecorate(UserContext decorated, UserContext context,
|
||||
AuthenticatedUser authenticatedUser,
|
||||
Credentials credentials) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Frees all resources associated with this AuthenticationProvider. This
|
||||
* function will be automatically invoked when the Guacamole server is
|
||||
* shutting down.
|
||||
*/
|
||||
void shutdown();
|
||||
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* Representation of an in-progress authentication attempt.
|
||||
*/
|
||||
public class AuthenticationSession {
|
||||
|
||||
/**
|
||||
* The absolute point in time after which this authentication session is
|
||||
* invalid. This value is a UNIX epoch timestamp, as may be returned by
|
||||
* {@link System#currentTimeMillis()}.
|
||||
*/
|
||||
private final long expirationTimestamp;
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationSession representing an in-progress
|
||||
* authentication attempt.
|
||||
*
|
||||
* @param expires
|
||||
* The number of milliseconds that may elapse before this session must
|
||||
* be considered invalid.
|
||||
*/
|
||||
public AuthenticationSession(long expires) {
|
||||
this.expirationTimestamp = System.currentTimeMillis() + expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this authentication session is still valid (has not yet
|
||||
* expired).
|
||||
*
|
||||
* @return
|
||||
* true if this authentication session is still valid, false if it has
|
||||
* expired.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return System.currentTimeMillis() < expirationTimestamp;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Manager service that temporarily stores a user's authentication status while
|
||||
* the authentication flow is underway. Authentication attempts are represented
|
||||
* as temporary authentication sessions, allowing authentication attempts to
|
||||
* span multiple requests, redirects, etc. Invalid or stale authentication
|
||||
* sessions are automatically purged from storage.
|
||||
*
|
||||
* @param <T>
|
||||
* The type of sessions managed by this session manager.
|
||||
*/
|
||||
public abstract class AuthenticationSessionManager<T extends AuthenticationSession> {
|
||||
|
||||
/**
|
||||
* Map of authentication session identifiers to their associated
|
||||
* {@link AuthenticationSession}.
|
||||
*/
|
||||
private final ConcurrentMap<String, T> sessions = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Set of identifiers of all sessions that are in a pending state, meaning
|
||||
* that the session was successfully created, but the overall auth result
|
||||
* has not yet been determined.
|
||||
*
|
||||
* Exposed as a ConcurrentMap instead of a Set because there is no
|
||||
* ConcurrentSet class offering the required atomic operations.
|
||||
*/
|
||||
private final ConcurrentMap<String, Boolean> pendingSessions = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Executor service which runs the periodic cleanup task
|
||||
*/
|
||||
private final ScheduledExecutorService executor =
|
||||
Executors.newScheduledThreadPool(1);
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationSessionManager that manages in-progress
|
||||
* authentication attempts. Invalid, stale sessions are automatically
|
||||
* cleaned up.
|
||||
*/
|
||||
public AuthenticationSessionManager() {
|
||||
executor.scheduleAtFixedRate(() -> {
|
||||
|
||||
// Invalidate any stale sessions
|
||||
for (Map.Entry<String, T> entry : sessions.entrySet()) {
|
||||
if (!entry.getValue().isValid())
|
||||
invalidateSession(entry.getKey());
|
||||
}
|
||||
|
||||
}, 1, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a cryptographically-secure value identical in form to the
|
||||
* session tokens generated by {@link #defer(org.apache.guacamole.auth.sso.AuthenticationSession)}
|
||||
* but invalid. The returned value is indistinguishable from a valid token,
|
||||
* but is not a valid token.
|
||||
*
|
||||
* @return
|
||||
* An invalid token value that is indistinguishable from a valid
|
||||
* token.
|
||||
*/
|
||||
public String generateInvalid() {
|
||||
return IdentifierGenerator.generateIdentifier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the session associated with the given identifier, if any, from the
|
||||
* map of sessions, and the set of pending sessions.
|
||||
*
|
||||
* @param identifier
|
||||
* The identifier of the session to remove, if one exists.
|
||||
*/
|
||||
public void invalidateSession(String identifier) {
|
||||
|
||||
// Do not attempt to remove a null identifier
|
||||
if (identifier == null)
|
||||
return;
|
||||
|
||||
// Remove from the overall list of sessions
|
||||
sessions.remove(identifier);
|
||||
|
||||
// Remove from the set of pending sessions
|
||||
pendingSessions.remove(identifier);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reactivate (remove from pending) the session associated with the given
|
||||
* session identifier, if any. After calling this method, any session with
|
||||
* the given identifier will be ready to be resumed again.
|
||||
*
|
||||
* @param identifier
|
||||
* The identifier of the session to reactivate, if one exists.
|
||||
*/
|
||||
public void reactivateSession(String identifier) {
|
||||
|
||||
// Remove from the set of pending sessions to reactivate
|
||||
if (identifier != null)
|
||||
pendingSessions.remove(identifier);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resumes the Guacamole side of the authentication process that was
|
||||
* previously deferred through a call to defer(). Once invoked, the
|
||||
* provided value ceases to be valid for future calls to resume().
|
||||
*
|
||||
* @param identifier
|
||||
* The unique string returned by the call to defer(). For convenience,
|
||||
* this value may safely be null.
|
||||
*
|
||||
* @return
|
||||
* The {@link AuthenticationSession} originally provided when defer()
|
||||
* was invoked, or null if the session is no longer valid or no such
|
||||
* value was returned by defer().
|
||||
*/
|
||||
public T resume(String identifier) {
|
||||
if (identifier != null) {
|
||||
|
||||
T session = sessions.get(identifier);
|
||||
|
||||
// Mark the session as pending. NOTE: Unless explicitly removed
|
||||
// from pending status via a call to reactivateSession(),
|
||||
// the next attempt to resume this session will fail
|
||||
if (pendingSessions.putIfAbsent(identifier, true) != null) {
|
||||
|
||||
// If the session was already marked as pending, invalidate it
|
||||
invalidateSession(identifier);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
if (session != null && session.isValid())
|
||||
return session;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Defers the Guacamole side of authentication for the user having the
|
||||
* given authentication session such that it may be later resumed through a
|
||||
* call to resume(). If authentication is never resumed, the session will
|
||||
* automatically be cleaned up after it ceases to be valid.
|
||||
*
|
||||
* This method will automatically generate a new identifier.
|
||||
*
|
||||
* @param session
|
||||
* The {@link AuthenticationSession} representing the in-progress
|
||||
* authentication attempt.
|
||||
*
|
||||
* @return
|
||||
* A unique and unpredictable string that may be used to represent the
|
||||
* given session when calling resume().
|
||||
*/
|
||||
public String defer(T session) {
|
||||
String identifier = IdentifierGenerator.generateIdentifier();
|
||||
sessions.put(identifier, session);
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defers the Guacamole side of authentication for the user having the
|
||||
* given authentication session such that it may be later resumed through a
|
||||
* call to resume(). If authentication is never resumed, the session will
|
||||
* automatically be cleaned up after it ceases to be valid.
|
||||
*
|
||||
* This method accepts an externally generated ID, which should be a UUID
|
||||
* or similar unique identifier.
|
||||
*
|
||||
* @param session
|
||||
* The {@link AuthenticationSession} representing the in-progress
|
||||
* authentication attempt.
|
||||
*
|
||||
* @param identifier
|
||||
* A unique and unpredictable string that may be used to represent the
|
||||
* given session when calling resume().
|
||||
*/
|
||||
public void defer(T session, String identifier) {
|
||||
sessions.put(identifier, session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shuts down the executor service that periodically removes all invalid
|
||||
* authentication sessions. This must be invoked when the auth extension is
|
||||
* shut down in order to avoid resource leaks.
|
||||
*/
|
||||
public void shutdown() {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
|
||||
/**
|
||||
* An object which Guacamole can connect to.
|
||||
*/
|
||||
public interface Connectable {
|
||||
|
||||
/*
|
||||
* IMPORTANT:
|
||||
* ----------
|
||||
* The web application (guacamole) defines its own version of this
|
||||
* interface containing defaults which allow backwards compatibility with
|
||||
* 1.0.0. Any changes to this interface MUST be properly reflected in that
|
||||
* copy of the interface such that they are binary compatible.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Establishes a connection to guacd using the information associated with
|
||||
* this object. The connection will be provided the given client
|
||||
* information.
|
||||
*
|
||||
* @deprecated
|
||||
* This function has been deprecated in favor of
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)},
|
||||
* which allows for connection parameter tokens to be injected and
|
||||
* applied by cooperating extensions, replacing the functionality
|
||||
* previously provided through the {@link org.apache.guacamole.token.StandardTokens}
|
||||
* class. It continues to be defined on this interface for
|
||||
* compatibility. <strong>New implementations should instead implement
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation, java.util.Map)}.</strong>
|
||||
*
|
||||
* @param info
|
||||
* Information associated with the connecting client.
|
||||
*
|
||||
* @return
|
||||
* A fully-established GuacamoleTunnel.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while connecting to guacd, or if permission to
|
||||
* connect is denied.
|
||||
*/
|
||||
@Deprecated
|
||||
default GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
return this.connect(info, Collections.emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Establishes a connection to guacd using the information associated with
|
||||
* this object. The connection will be provided the given client
|
||||
* information. Implementations which support parameter tokens should
|
||||
* apply the given tokens when configuring the connection, such as with a
|
||||
* {@link org.apache.guacamole.token.TokenFilter}.
|
||||
*
|
||||
* @see <a href="http://guacamole.apache.org/doc/gug/configuring-guacamole.html#parameter-tokens">Parameter Tokens</a>
|
||||
*
|
||||
* @param info
|
||||
* Information associated with the connecting client.
|
||||
*
|
||||
* @param tokens
|
||||
* A Map containing the token names and corresponding values to be
|
||||
* applied as parameter tokens when establishing the connection. If the
|
||||
* implementation does not support parameter tokens, this Map may be
|
||||
* ignored.
|
||||
*
|
||||
* @return
|
||||
* A fully-established GuacamoleTunnel.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while connecting to guacd, or if permission to
|
||||
* connect is denied.
|
||||
*/
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the number of active connections associated with this object.
|
||||
* Implementations may simply return 0 if this value is not tracked.
|
||||
*
|
||||
* @return
|
||||
* The number of active connections associated with this object.
|
||||
*/
|
||||
public int getActiveConnections();
|
||||
|
||||
}
|
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
* Represents a pairing of a GuacamoleConfiguration with a unique,
|
||||
* human-readable identifier, and abstracts the connection process. The
|
||||
* backing GuacamoleConfiguration may be intentionally obfuscated or tokenized
|
||||
* to protect sensitive configuration information.
|
||||
*/
|
||||
public interface Connection extends Identifiable, Connectable, Attributes, Nameable {
|
||||
|
||||
/**
|
||||
* Returns the unique identifier of the parent ConnectionGroup for
|
||||
* this Connection.
|
||||
*
|
||||
* @return The unique identifier of the parent ConnectionGroup for
|
||||
* this Connection.
|
||||
*/
|
||||
public String getParentIdentifier();
|
||||
|
||||
/**
|
||||
* Sets the unique identifier of the parent ConnectionGroup for
|
||||
* this Connection.
|
||||
*
|
||||
* @param parentIdentifier The unique identifier of the parent
|
||||
* ConnectionGroup for this Connection.
|
||||
*/
|
||||
public void setParentIdentifier(String parentIdentifier);
|
||||
|
||||
/**
|
||||
* Returns the GuacamoleConfiguration associated with this Connection. Note
|
||||
* that because configurations may contain sensitive information, some data
|
||||
* in this configuration may be omitted or tokenized.
|
||||
*
|
||||
* @return The GuacamoleConfiguration associated with this Connection.
|
||||
*/
|
||||
public GuacamoleConfiguration getConfiguration();
|
||||
|
||||
/**
|
||||
* Sets the GuacamoleConfiguration associated with this Connection.
|
||||
*
|
||||
* @param config The GuacamoleConfiguration to associate with this
|
||||
* Connection.
|
||||
*/
|
||||
public void setConfiguration(GuacamoleConfiguration config);
|
||||
|
||||
/**
|
||||
* Returns the date and time that this connection was last used. If the
|
||||
* connection was never used, the time that the connection was last used is
|
||||
* unknown, or this information is not visible to the current user, this
|
||||
* may be null.
|
||||
*
|
||||
* @return
|
||||
* The date and time this connection was last used, or null if this
|
||||
* information is unavailable or inapplicable.
|
||||
*/
|
||||
Date getLastActive();
|
||||
|
||||
/**
|
||||
* Returns a list of ConnectionRecords representing the usage history
|
||||
* of this Connection, including any active users. ConnectionRecords
|
||||
* in this list will be sorted in descending order of end time (active
|
||||
* connections are first), and then in descending order of start time
|
||||
* (newer connections are first). If connection history tracking is
|
||||
* not implemented this method should throw GuacamoleUnsupportedException.
|
||||
*
|
||||
* @deprecated
|
||||
* This function has been deprecated in favor of
|
||||
* {@link getConnectionHistory}, which returns the connection history
|
||||
* as an ActivityRecordSet that can be easily sorted and filtered.
|
||||
* While the getHistory() method is provided for API compatibility,
|
||||
* new implementations should avoid use of this method and, instead,
|
||||
* implement the getConnectionHistory() method.
|
||||
*
|
||||
* @return
|
||||
* A list of ConnectionRecrods representing the usage history of this
|
||||
* Connection.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this connection, or if permission is
|
||||
* denied.
|
||||
*/
|
||||
@Deprecated
|
||||
default List<? extends ConnectionRecord> getHistory()
|
||||
throws GuacamoleException {
|
||||
return Collections.unmodifiableList(new ArrayList<>(getConnectionHistory().asCollection()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an ActivityRecordSet containing ConnectionRecords that
|
||||
* represent the usage history of this Connection, including any active
|
||||
* users. ConnectionRecords in this list will be sorted in descending order
|
||||
* of end time (active connections are first), and then in descending order
|
||||
* of start time (newer connections are first). If connection history
|
||||
* tracking has not been implemented, or has been implemented using the
|
||||
* deprecated {@link getHistory} method, this function should throw
|
||||
* GuacamoleUnsupportedExpcetion.
|
||||
*
|
||||
* @return
|
||||
* An ActivityRecordSet containing ConnectionRecords representing the
|
||||
* usage history of this Connection.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If history tracking is not implemented, if an error occurs while
|
||||
* reading the history of this connection, or if permission is
|
||||
* denied.
|
||||
*/
|
||||
default ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
throw new GuacamoleUnsupportedException("This implementation of Connection does not provide connection history.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns identifiers of all readable sharing profiles that can be used to
|
||||
* join this connection when it is active. The level of access granted to a
|
||||
* joining user is dictated by the connection parameters associated with
|
||||
* the sharing profile, not necessarily the parameters of the primary
|
||||
* connection being joined.
|
||||
*
|
||||
* @return
|
||||
* A Set of identifiers representing the sharing profiles for this
|
||||
* connection.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while fetching the sharing profiles for this
|
||||
* connection.
|
||||
*/
|
||||
public Set<String> getSharingProfileIdentifiers() throws GuacamoleException;
|
||||
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Represents a connection group, which can contain both other connection groups
|
||||
* as well as connections.
|
||||
*/
|
||||
public interface ConnectionGroup extends Identifiable, Connectable, Attributes, Nameable {
|
||||
|
||||
/**
|
||||
* All legal types of connection group.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* A connection group that purely organizes other connections or
|
||||
* connection groups, serving only as a container. An organizational
|
||||
* connection group is analogous to a directory or folder in a
|
||||
* filesystem.
|
||||
*/
|
||||
ORGANIZATIONAL,
|
||||
|
||||
/**
|
||||
* A connection group that acts as a load balancer. A balancing
|
||||
* connection group can be connected to in the same manner as a
|
||||
* connection, and will transparently route to the least-used
|
||||
* underlying connection.
|
||||
*/
|
||||
BALANCING
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the unique identifier of the parent ConnectionGroup for
|
||||
* this ConnectionGroup.
|
||||
*
|
||||
* @return The unique identifier of the parent ConnectionGroup for
|
||||
* this ConnectionGroup.
|
||||
*/
|
||||
public String getParentIdentifier();
|
||||
|
||||
/**
|
||||
* Sets the unique identifier of the parent ConnectionGroup for
|
||||
* this ConnectionGroup.
|
||||
*
|
||||
* @param parentIdentifier The unique identifier of the parent
|
||||
* ConnectionGroup for this ConnectionGroup.
|
||||
*/
|
||||
public void setParentIdentifier(String parentIdentifier);
|
||||
|
||||
/**
|
||||
* Set the type of this ConnectionGroup.
|
||||
*
|
||||
* @param type The type of this ConnectionGroup.
|
||||
*/
|
||||
public void setType(Type type);
|
||||
|
||||
/**
|
||||
* Returns the type of this connection.
|
||||
* @return the type of this connection.
|
||||
*/
|
||||
public Type getType();
|
||||
|
||||
/**
|
||||
* Returns the identifiers of all readable connections that are children
|
||||
* of this connection group.
|
||||
*
|
||||
* @return
|
||||
* The set of identifiers of all readable connections that are children
|
||||
* of this connection group.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the identifiers.
|
||||
*/
|
||||
public Set<String> getConnectionIdentifiers() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the identifiers of all readable connection groups that are
|
||||
* children of this connection group.
|
||||
*
|
||||
* @return
|
||||
* The set of identifiers of all readable connection groups that are
|
||||
* children of this connection group.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the identifiers.
|
||||
*/
|
||||
|
||||
public Set<String> getConnectionGroupIdentifiers()
|
||||
throws GuacamoleException;
|
||||
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
|
||||
/**
|
||||
* A logging record describing when a user started and ended usage of a
|
||||
* particular connection.
|
||||
*/
|
||||
public interface ConnectionRecord extends ActivityRecord {
|
||||
|
||||
/**
|
||||
* Returns the identifier of the connection associated with this
|
||||
* connection record.
|
||||
*
|
||||
* @return
|
||||
* The identifier of the connection associated with this connection
|
||||
* record.
|
||||
*/
|
||||
public String getConnectionIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the name of the connection associated with this connection
|
||||
* record.
|
||||
*
|
||||
* @return
|
||||
* The name of the connection associated with this connection record.
|
||||
*/
|
||||
public String getConnectionName();
|
||||
|
||||
/**
|
||||
* Returns the identifier of the sharing profile that was used to access the
|
||||
* connection associated with this connection record. If the connection was
|
||||
* accessed directly (without involving a sharing profile), this will be
|
||||
* null.
|
||||
*
|
||||
* @return
|
||||
* The identifier of the sharing profile used to access the connection
|
||||
* associated with this connection record, or null if the connection
|
||||
* was accessed directly.
|
||||
*/
|
||||
public String getSharingProfileIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the name of the sharing profile that was used to access the
|
||||
* connection associated with this connection record. If the connection was
|
||||
* accessed directly (without involving a sharing profile), this will be
|
||||
* null.
|
||||
*
|
||||
* @return
|
||||
* The name of the sharing profile used to access the connection
|
||||
* associated with this connection record, or null if the connection
|
||||
* was accessed directly.
|
||||
*/
|
||||
public String getSharingProfileName();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>If implemented, this UUID SHOULD be identical to the UUID of the
|
||||
* {@link GuacamoleTunnel} originally returned when the connection was
|
||||
* established to allow extensions and/or the web application to
|
||||
* automatically associate connection information with corresponding
|
||||
* history records, such as log messages and session recordings.
|
||||
*/
|
||||
@Override
|
||||
public default UUID getUUID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* The set of all available connection records, or a subset of those records.
|
||||
*
|
||||
* @deprecated
|
||||
* Use {@link ActivityRecordSet}<{@link ConnectionRecord}> instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ConnectionRecordSet
|
||||
extends ActivityRecordSet<ConnectionRecord> {
|
||||
}
|
@@ -0,0 +1,404 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.net.RequestDetails;
|
||||
import java.io.Serializable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* Simple arbitrary set of credentials, including a username/password pair and
|
||||
* a copy of the details of the HTTP request received for authentication.
|
||||
* <p>
|
||||
* This class is used along with AuthenticationProvider to provide arbitrary
|
||||
* HTTP-based authentication for Guacamole.
|
||||
*/
|
||||
public class Credentials implements Serializable {
|
||||
|
||||
/**
|
||||
* Unique identifier associated with this specific version of Credentials.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* An arbitrary username.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* An arbitrary password.
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* The details of the HTTP request that provided these Credentials.
|
||||
*/
|
||||
private transient RequestDetails requestDetails;
|
||||
|
||||
/**
|
||||
* The HttpServletRequest carrying additional credentials, if any.
|
||||
*/
|
||||
private transient HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* Creates a new Credentials object with the given username, password,
|
||||
* and HTTP request. The details of the request are copied for later
|
||||
* reference and can be retrieved with {@link #getRequestDetails()}.
|
||||
*
|
||||
* @param username
|
||||
* The username that was provided for authentication.
|
||||
*
|
||||
* @param password
|
||||
* The password that was provided for authentication.
|
||||
*
|
||||
* @param request
|
||||
* The HTTP request associated with the authentication
|
||||
* request.
|
||||
*/
|
||||
public Credentials(String username, String password, HttpServletRequest request) {
|
||||
this(username, password, new RequestDetails(request));
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Credentials object with the given username, password,
|
||||
* and general HTTP request details.
|
||||
*
|
||||
* @param username
|
||||
* The username that was provided for authentication.
|
||||
*
|
||||
* @param password
|
||||
* The password that was provided for authentication.
|
||||
*
|
||||
* @param requestDetails
|
||||
* The details of the HTTP request associated with the authentication
|
||||
* request.
|
||||
*/
|
||||
public Credentials(String username, String password, RequestDetails requestDetails) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.requestDetails = requestDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the password associated with this set of credentials.
|
||||
*
|
||||
* @return
|
||||
* The password associated with this username/password pair, or null
|
||||
* if no password has been set.
|
||||
*/
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the password associated with this set of credentials.
|
||||
*
|
||||
* @param password
|
||||
* The password to associate with this username/password pair.
|
||||
*/
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the username associated with this set of credentials.
|
||||
*
|
||||
* @return
|
||||
* The username associated with this username/password pair, or null
|
||||
* if no username has been set.
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username associated with this set of credentials.
|
||||
*
|
||||
* @param username
|
||||
* The username to associate with this username/password pair.
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HttpServletRequest associated with this set of credentials.
|
||||
*
|
||||
* @deprecated
|
||||
* It is not reliable to reference an HttpServletRequest outside the
|
||||
* scope of the specific request that created it. Use
|
||||
* {@link #getRequestDetails()} instead.
|
||||
*
|
||||
* @return
|
||||
* The HttpServletRequest associated with this set of credentials,
|
||||
* or null if no such request exists.
|
||||
*/
|
||||
@Deprecated
|
||||
public HttpServletRequest getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HttpServletRequest associated with this set of credentials.
|
||||
*
|
||||
* @deprecated
|
||||
* It is not reliable to reference an HttpServletRequest outside the
|
||||
* scope of the specific request that created it. Use
|
||||
* {@link #setRequestDetails(org.apache.guacamole.net.RequestDetails)}
|
||||
* instead.
|
||||
*
|
||||
* @param request
|
||||
* The HttpServletRequest to associated with this set of credentials.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRequest(HttpServletRequest request) {
|
||||
setRequestDetails(new RequestDetails(request));
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the details of the HTTP request related to these Credentials.
|
||||
*
|
||||
* @return
|
||||
* The details of the HTTP request related to these Credentials.
|
||||
*/
|
||||
public RequestDetails getRequestDetails() {
|
||||
return requestDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the current HTTP request details of these Credentials with the
|
||||
* given details.
|
||||
*
|
||||
* @param requestDetails
|
||||
* The details of the HTTP request that should replace the established
|
||||
* details within these Credentials.
|
||||
*/
|
||||
public void setRequestDetails(RequestDetails requestDetails) {
|
||||
this.requestDetails = requestDetails;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HttpSession associated with this set of credentials.
|
||||
* <p>
|
||||
* This is a convenience function that is equivalent to invoking
|
||||
* {@link RequestDetails#getSession()} on the {@link RequestDetails}
|
||||
* returned by {@link #getRequestDetails()}.
|
||||
* <p>
|
||||
* <strong>NOTE: Guacamole itself does not use the HttpSession.</strong>
|
||||
* The extension subsystem does not provide access to the session object
|
||||
* used by Guacamole, which is considered internal. Access to an HttpSession
|
||||
* is only of use if you have another application in place that
|
||||
* <em>does</em> use HttpSession and needs to be considered.
|
||||
*
|
||||
* @return
|
||||
* The HttpSession associated with this set of credentials, or null if
|
||||
* there is no HttpSession.
|
||||
*/
|
||||
public HttpSession getSession() {
|
||||
return requestDetails.getSession();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the HttpSession associated with this set of credentials.
|
||||
*
|
||||
* @deprecated
|
||||
* Since 1.6.0, the HttpSession that may be associated with a
|
||||
* Credentials object is tied to the RequestDetails. If the HttpSession
|
||||
* is part of a Credentials and truly needs to be replaced by another
|
||||
* HttpSession, use {@link #setRequestDetails(org.apache.guacamole.net.RequestDetails)}
|
||||
* to override the underlying {@link RequestDetails} instead.
|
||||
*
|
||||
* @param session
|
||||
* The HttpSession to associated with this set of credentials.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setSession(HttpSession session) {
|
||||
setRequestDetails(new RequestDetails(getRequestDetails()) {
|
||||
|
||||
@Override
|
||||
public HttpSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the HTTP header having the given name from the
|
||||
* original details of the HTTP request that is related to these
|
||||
* credentials. Header names are case-insensitive. If no such header was
|
||||
* present, null is returned. If the header had multiple values, the first
|
||||
* value is returned.
|
||||
* <p>
|
||||
* For access to all values of a header, as well as other details of the
|
||||
* request, see {@link #getRequestDetails()}. This is a convenience
|
||||
* function that is equivalent to invoking {@link RequestDetails#getHeader(java.lang.String)}.
|
||||
*
|
||||
* @param name
|
||||
* The name of the header to retrieve. This name is case-insensitive.
|
||||
*
|
||||
* @return
|
||||
* The first value of the HTTP header with the given name, or null if
|
||||
* there is no such header.
|
||||
*/
|
||||
public String getHeader(String name) {
|
||||
return getRequestDetails().getHeader(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of the HTTP parameter having the given name from the
|
||||
* original details of the HTTP request that is related to these
|
||||
* credentials. Parameter names are case-sensitive. If no such parameter was
|
||||
* present, null is returned. If the parameter had multiple values, the
|
||||
* first value is returned.
|
||||
* <p>
|
||||
* For access to all values of a parameter, as well as other details of the
|
||||
* request, see {@link #getRequestDetails()}. This is a convenience
|
||||
* function that is equivalent to invoking {@link RequestDetails#getParameter(java.lang.String)}.
|
||||
*
|
||||
* @param name
|
||||
* The name of the parameter to retrieve. This name is case-sensitive.
|
||||
*
|
||||
* @return
|
||||
* The first value of the HTTP parameter with the given name, or null
|
||||
* if there is no such parameter.
|
||||
*/
|
||||
public String getParameter(String name) {
|
||||
return getRequestDetails().getParameter(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the address of the client end of the connection which provided
|
||||
* these credentials, if known.
|
||||
* <p>
|
||||
* This is a convenience function that is equivalent to invoking
|
||||
* {@link RequestDetails#getRemoteAddress()} on the
|
||||
* {@link RequestDetails} returned by {@link #getRequestDetails()}.
|
||||
*
|
||||
* @return
|
||||
* The address of the client end of the connection which provided these
|
||||
* credentials, or null if the address is not known.
|
||||
*/
|
||||
public String getRemoteAddress() {
|
||||
return getRequestDetails().getRemoteAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the address of the client end of the connection which provided
|
||||
* these credentials.
|
||||
*
|
||||
* @deprecated
|
||||
* Since 1.6.0, the address that may be associated with a Credentials
|
||||
* object is tied to the RequestDetails. If the address truly needs to
|
||||
* be replaced, use {@link #setRequestDetails(org.apache.guacamole.net.RequestDetails)}
|
||||
* to override the underlying {@link RequestDetails} instead.
|
||||
*
|
||||
* @param remoteAddress
|
||||
* The address of the client end of the connection which provided these
|
||||
* credentials, or null if the address is not known.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRemoteAddress(String remoteAddress) {
|
||||
setRequestDetails(new RequestDetails(getRequestDetails()) {
|
||||
|
||||
@Override
|
||||
public String getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname of the client end of the connection which provided
|
||||
* these credentials, if known. If the hostname of the client cannot be
|
||||
* determined, but the address is known, the address may be returned
|
||||
* instead.
|
||||
* <p>
|
||||
* This is a convenience function that is equivalent to invoking
|
||||
* {@link RequestDetails#getRemoteHostname()} on the
|
||||
* {@link RequestDetails} returned by {@link #getRequestDetails()}.
|
||||
*
|
||||
* @return
|
||||
* The hostname or address of the client end of the connection which
|
||||
* provided these credentials, or null if the hostname is not known.
|
||||
*/
|
||||
public String getRemoteHostname() {
|
||||
return getRequestDetails().getRemoteHostname();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the hostname of the client end of the connection which provided
|
||||
* these credentials, if known. If the hostname of the client cannot be
|
||||
* determined, but the address is known, the address may be specified
|
||||
* instead.
|
||||
*
|
||||
* @deprecated
|
||||
* Since 1.6.0, the hostname that may be associated with a Credentials
|
||||
* object is tied to the RequestDetails. If the hostname truly needs to
|
||||
* be replaced, use {@link #setRequestDetails(org.apache.guacamole.net.RequestDetails)}
|
||||
* to override the underlying {@link RequestDetails} instead.
|
||||
*
|
||||
* @param remoteHostname
|
||||
* The hostname or address of the client end of the connection which
|
||||
* provided these credentials, or null if the hostname is not known.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setRemoteHostname(String remoteHostname) {
|
||||
setRequestDetails(new RequestDetails(getRequestDetails()) {
|
||||
|
||||
@Override
|
||||
public String getRemoteHostname() {
|
||||
return remoteHostname;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether this Credentials object does not contain any specific
|
||||
* authentication parameters, including HTTP parameters and the HTTP header
|
||||
* used for the authentication token. An authentication request that
|
||||
* contains no parameters whatsoever will tend to be the first, anonymous,
|
||||
* credential-less authentication attempt that results in the initial login
|
||||
* screen rendering.
|
||||
*
|
||||
* @return
|
||||
* true if this Credentials object contains no authentication
|
||||
* parameters whatsoever, false otherwise.
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
|
||||
// An authentication request that contains an explicit username or
|
||||
// password (even if blank) is non-empty, regardless of how the values
|
||||
// were passed
|
||||
if (getUsername() != null || getPassword() != null)
|
||||
return false;
|
||||
|
||||
// An authentication request is non-empty if it contains any HTTP
|
||||
// parameters at all or contains an authentication token
|
||||
return getRequestDetails().getParameterNames().isEmpty() && getHeader("Guacamole-Token") == null;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* ActivityRecordSet implementation which simplifies decorating the records
|
||||
* within an underlying ActivityRecordSet. The decorate() function must be
|
||||
* implemented to define how each record is decorated. As ActivityRecordSets
|
||||
* are read-only, there is no need to define an undecorate() function as
|
||||
* required by {@link DecoratingDirectory}.
|
||||
*
|
||||
* @param <RecordType>
|
||||
* The type of records stored within this ActivityRecordSet.
|
||||
*/
|
||||
public abstract class DecoratingActivityRecordSet<RecordType extends ActivityRecord>
|
||||
extends DelegatingActivityRecordSet<RecordType> {
|
||||
|
||||
/**
|
||||
* Creates a new DecoratingActivityRecordSet which decorates the records
|
||||
* within the given set.
|
||||
*
|
||||
* @param recordSet
|
||||
* The ActivityRecordSet whose records are being decorated.
|
||||
*/
|
||||
public DecoratingActivityRecordSet(ActivityRecordSet<RecordType> recordSet) {
|
||||
super(recordSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a record retrieved from a ActivityRecordSet which originates from
|
||||
* a different AuthenticationProvider, returns an identical type of record
|
||||
* optionally wrapped with additional information, functionality, etc. If
|
||||
* this record set chooses to decorate the record provided, it is up to the
|
||||
* implementation of that decorated record to properly pass through
|
||||
* operations as appropriate. All records retrieved from this
|
||||
* DecoratingActivityRecordSet will first be passed through this function.
|
||||
*
|
||||
* @param record
|
||||
* A record from a ActivityRecordSet which originates from a different
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @return
|
||||
* A record which may have been decorated by this
|
||||
* DecoratingActivityRecordSet. If the record was not decorated, the
|
||||
* original, unmodified record may be returned instead.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the provided record cannot be decorated due to an error.
|
||||
*/
|
||||
protected abstract RecordType decorate(RecordType record)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given an ActivityRecordSet which originates from a different
|
||||
* AuthenticationProvider, returns an identical type of record set
|
||||
* optionally wrapped with additional information, functionality, etc. If
|
||||
* this record set chooses to decorate the record set provided, it is up to
|
||||
* the implementation of that decorated record set to properly pass through
|
||||
* operations as appropriate. All record sets retrieved from this
|
||||
* DecoratingActivityRecordSet will first be passed through this function,
|
||||
* such as those returned by {@link #limit(int)} and similar functions.
|
||||
* <p>
|
||||
* By default, this function will wrap any provided ActivityRecordSet in a
|
||||
* simple, anonymous instance of DecoratingActivityRecordSet that delegates
|
||||
* to the decorate() implementations of this DecoratingActivityRecordSet.
|
||||
* <strong>This default behavior may need to be overridden if the
|
||||
* DecoratingActivityRecordSet implementation maintains any internal
|
||||
* state.</strong>
|
||||
*
|
||||
* @param recordSet
|
||||
* An ActivityRecordSet which originates from a different
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @return
|
||||
* A record set which may have been decorated by this
|
||||
* DecoratingActivityRecordSet. If the record set was not decorated, the
|
||||
* original, unmodified record set may be returned instead, however
|
||||
* beware that this may result in records within the set no longer
|
||||
* being decorated.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the provided record set cannot be decorated due to an error.
|
||||
*/
|
||||
protected ActivityRecordSet<RecordType> decorate(ActivityRecordSet<RecordType> recordSet)
|
||||
throws GuacamoleException {
|
||||
final DecoratingActivityRecordSet<RecordType> decorator = this;
|
||||
return new DecoratingActivityRecordSet<RecordType>(recordSet) {
|
||||
|
||||
@Override
|
||||
protected RecordType decorate(RecordType record) throws GuacamoleException {
|
||||
return decorator.decorate(record);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ActivityRecordSet<RecordType> decorate(ActivityRecordSet<RecordType> recordSet)
|
||||
throws GuacamoleException {
|
||||
return decorator.decorate(recordSet);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordType get(String string) throws GuacamoleException {
|
||||
|
||||
RecordType record = super.get(string);
|
||||
if (record != null)
|
||||
return decorate(record);
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> sort(SortableProperty property,
|
||||
boolean desc) throws GuacamoleException {
|
||||
return decorate(super.sort(property, desc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> limit(int limit) throws GuacamoleException {
|
||||
return decorate(super.limit(limit));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> contains(String value) throws GuacamoleException {
|
||||
return decorate(super.contains(value));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RecordType> asCollection() throws GuacamoleException {
|
||||
|
||||
Collection<RecordType> records = super.asCollection();
|
||||
|
||||
List<RecordType> decoratedRecords = new ArrayList<>(records.size());
|
||||
for (RecordType record : records)
|
||||
decoratedRecords.add(decorate(record));
|
||||
|
||||
return decoratedRecords;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Directory implementation which simplifies decorating the objects within an
|
||||
* underlying Directory. The decorate() and undecorate() functions must be
|
||||
* implemented to define how each object is decorated, and how that decoration
|
||||
* may be removed.
|
||||
*
|
||||
* @param <ObjectType>
|
||||
* The type of objects stored within this Directory.
|
||||
*/
|
||||
public abstract class DecoratingDirectory<ObjectType extends Identifiable>
|
||||
extends DelegatingDirectory<ObjectType> {
|
||||
|
||||
/**
|
||||
* Creates a new DecoratingDirectory which decorates the objects within
|
||||
* the given directory.
|
||||
*
|
||||
* @param directory
|
||||
* The Directory whose objects are being decorated.
|
||||
*/
|
||||
public DecoratingDirectory(Directory<ObjectType> directory) {
|
||||
super(directory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given an object retrieved from a Directory which originates from a
|
||||
* different AuthenticationProvider, returns an identical type of object
|
||||
* optionally wrapped with additional information, functionality, etc. If
|
||||
* this directory chooses to decorate the object provided, it is up to the
|
||||
* implementation of that decorated object to properly pass through
|
||||
* operations as appropriate, as well as provide for an eventual
|
||||
* undecorate() operation. All objects retrieved from this
|
||||
* DecoratingDirectory will first be passed through this function.
|
||||
*
|
||||
* @param object
|
||||
* An object from a Directory which originates from a different
|
||||
* AuthenticationProvider.
|
||||
*
|
||||
* @return
|
||||
* An object which may have been decorated by this
|
||||
* DecoratingDirectory. If the object was not decorated, the original,
|
||||
* unmodified object may be returned instead.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the provided object cannot be decorated due to an error.
|
||||
*/
|
||||
protected abstract ObjectType decorate(ObjectType object)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Given an object originally returned from a call to this
|
||||
* DecoratingDirectory's decorate() function, reverses the decoration
|
||||
* operation, returning the original object. This function is effectively
|
||||
* the exact inverse of the decorate() function. The return value of
|
||||
* undecorate(decorate(X)) must be identically X. All objects given to this
|
||||
* DecoratingDirectory via add() or update() will first be passed through
|
||||
* this function.
|
||||
*
|
||||
* @param object
|
||||
* An object which was originally returned by a call to this
|
||||
* DecoratingDirectory's decorate() function.
|
||||
*
|
||||
* @return
|
||||
* The original object which was provided to this DecoratingDirectory's
|
||||
* decorate() function.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If the provided object cannot be undecorated due to an error.
|
||||
*/
|
||||
protected abstract ObjectType undecorate(ObjectType object)
|
||||
throws GuacamoleException;
|
||||
|
||||
@Override
|
||||
public ObjectType get(String identifier) throws GuacamoleException {
|
||||
|
||||
// Decorate only if object exists
|
||||
ObjectType object = super.get(identifier);
|
||||
if (object != null)
|
||||
return decorate(object);
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ObjectType> getAll(Collection<String> identifiers)
|
||||
throws GuacamoleException {
|
||||
|
||||
Collection<ObjectType> objects = super.getAll(identifiers);
|
||||
|
||||
// Decorate all retrieved objects, if any
|
||||
Collection<ObjectType> decorated = new ArrayList<ObjectType>(objects.size());
|
||||
for (ObjectType object : objects)
|
||||
decorated.add(decorate(object));
|
||||
|
||||
return decorated;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ObjectType object) throws GuacamoleException {
|
||||
super.add(decorate(object));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ObjectType object) throws GuacamoleException {
|
||||
super.update(undecorate(object));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ActivityRecord implementation which simply delegates all function calls to an
|
||||
* underlying ActivityRecord.
|
||||
*/
|
||||
public class DelegatingActivityRecord implements ActivityRecord {
|
||||
|
||||
/**
|
||||
* The wrapped ActivityRecord.
|
||||
*/
|
||||
private final ActivityRecord record;
|
||||
|
||||
/**
|
||||
* Wraps the given ActivityRecord such that all function calls against this
|
||||
* DelegatingActivityRecord will be delegated to it.
|
||||
*
|
||||
* @param record
|
||||
* The record to wrap.
|
||||
*/
|
||||
public DelegatingActivityRecord(ActivityRecord record) {
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying ActivityRecord wrapped by this
|
||||
* DelegatingActivityRecord.
|
||||
*
|
||||
* @return
|
||||
* The ActivityRecord wrapped by this DelegatingActivityRecord.
|
||||
*/
|
||||
protected ActivityRecord getDelegateActivityRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getStartDate() {
|
||||
return record.getStartDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getEndDate() {
|
||||
return record.getEndDate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRemoteHost() {
|
||||
return record.getRemoteHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return record.getUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return record.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return record.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return record.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ActivityLog> getLogs() {
|
||||
return record.getLogs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return record.getAttributes();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* ActivityRecordSet implementation which simply delegates all function calls
|
||||
* to an underlying ActivityRecordSet.
|
||||
*
|
||||
* @param <RecordType>
|
||||
* The type of ActivityRecord contained within this set.
|
||||
*/
|
||||
public class DelegatingActivityRecordSet<RecordType extends ActivityRecord>
|
||||
implements ActivityRecordSet<RecordType> {
|
||||
|
||||
/**
|
||||
* The wrapped ActivityRecordSet.
|
||||
*/
|
||||
private final ActivityRecordSet<RecordType> recordSet;
|
||||
|
||||
/**
|
||||
* Wraps the given ActivityRecordSet such that all function calls against this
|
||||
* DelegatingActivityRecordSet will be delegated to it.
|
||||
*
|
||||
* @param recordSet
|
||||
* The ActivityRecordSet to wrap.
|
||||
*/
|
||||
public DelegatingActivityRecordSet(ActivityRecordSet<RecordType> recordSet) {
|
||||
this.recordSet = recordSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying ActivityRecordSet wrapped by this
|
||||
* DelegatingActivityRecordSet.
|
||||
*
|
||||
* @return
|
||||
* The ActivityRecordSet wrapped by this DelegatingActivityRecordSet.
|
||||
*/
|
||||
protected ActivityRecordSet<RecordType> getDelegateActivityRecordSet() {
|
||||
return recordSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecordType get(String identifier) throws GuacamoleException {
|
||||
return recordSet.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<RecordType> asCollection() throws GuacamoleException {
|
||||
return recordSet.asCollection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> contains(String value) throws GuacamoleException {
|
||||
return recordSet.contains(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> limit(int limit) throws GuacamoleException {
|
||||
return recordSet.limit(limit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<RecordType> sort(SortableProperty property,
|
||||
boolean desc) throws GuacamoleException {
|
||||
return recordSet.sort(property, desc);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,184 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
import org.apache.guacamole.protocol.GuacamoleConfiguration;
|
||||
|
||||
/**
|
||||
* Connection implementation which simply delegates all function calls to an
|
||||
* underlying Connection.
|
||||
*/
|
||||
public class DelegatingConnection implements Connection {
|
||||
|
||||
/**
|
||||
* The wrapped Connection.
|
||||
*/
|
||||
private final Connection connection;
|
||||
|
||||
/**
|
||||
* The tokens which should apply strictly to the next call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}.
|
||||
* This storage is intended as a temporary bridge allowing the old version
|
||||
* of connect() to be overridden while still resulting in the same behavior
|
||||
* as older versions of DelegatingConnection. <strong>This storage should be
|
||||
* removed once support for the old, deprecated connect() is removed.</strong>
|
||||
*/
|
||||
private final ThreadLocal<Map<String, String>> currentTokens =
|
||||
new ThreadLocal<Map<String, String>>() {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> initialValue() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the given Connection such that all function calls against this
|
||||
* DelegatingConnection will be delegated to it.
|
||||
*
|
||||
* @param connection
|
||||
* The Connection to wrap.
|
||||
*/
|
||||
public DelegatingConnection(Connection connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying Connection wrapped by this DelegatingConnection.
|
||||
*
|
||||
* @return
|
||||
* The Connection wrapped by this DelegatingConnection.
|
||||
*/
|
||||
protected Connection getDelegateConnection() {
|
||||
return connection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return connection.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
connection.setIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return connection.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
connection.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentIdentifier() {
|
||||
return connection.getParentIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentIdentifier(String parentIdentifier) {
|
||||
connection.setParentIdentifier(parentIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleConfiguration getConfiguration() {
|
||||
return connection.getConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfiguration(GuacamoleConfiguration config) {
|
||||
connection.setConfiguration(config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return connection.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
connection.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastActive() {
|
||||
return connection.getLastActive();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ConnectionRecord> getHistory()
|
||||
throws GuacamoleException {
|
||||
return connection.getHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
return connection.getConnectionHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSharingProfileIdentifiers()
|
||||
throws GuacamoleException {
|
||||
return connection.getSharingProfileIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
return connection.connect(info, currentTokens.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
|
||||
// Make received tokens available within the legacy connect() strictly
|
||||
// in context of the current connect() call
|
||||
try {
|
||||
currentTokens.set(tokens);
|
||||
return connect(info);
|
||||
}
|
||||
finally {
|
||||
currentTokens.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return connection.getActiveConnections();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.GuacamoleTunnel;
|
||||
import org.apache.guacamole.protocol.GuacamoleClientInformation;
|
||||
|
||||
/**
|
||||
* ConnectionGroup implementation which simply delegates all function calls to
|
||||
* an underlying ConnectionGroup.
|
||||
*/
|
||||
public class DelegatingConnectionGroup implements ConnectionGroup {
|
||||
|
||||
/**
|
||||
* The wrapped ConnectionGroup.
|
||||
*/
|
||||
private final ConnectionGroup connectionGroup;
|
||||
|
||||
/**
|
||||
* The tokens which should apply strictly to the next call to
|
||||
* {@link #connect(org.apache.guacamole.protocol.GuacamoleClientInformation)}.
|
||||
* This storage is intended as a temporary bridge allowing the old version
|
||||
* of connect() to be overridden while still resulting in the same behavior
|
||||
* as older versions of DelegatingConnectionGroup. <strong>This storage
|
||||
* should be removed once support for the old, deprecated connect() is
|
||||
* removed.</strong>
|
||||
*/
|
||||
private final ThreadLocal<Map<String, String>> currentTokens =
|
||||
new ThreadLocal<Map<String, String>>() {
|
||||
|
||||
@Override
|
||||
protected Map<String, String> initialValue() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Wraps the given ConnectionGroup such that all function calls against this
|
||||
* DelegatingConnectionGroup will be delegated to it.
|
||||
*
|
||||
* @param connectionGroup
|
||||
* The ConnectionGroup to wrap.
|
||||
*/
|
||||
public DelegatingConnectionGroup(ConnectionGroup connectionGroup) {
|
||||
this.connectionGroup = connectionGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying ConnectionGroup wrapped by this
|
||||
* DelegatingConnectionGroup.
|
||||
*
|
||||
* @return
|
||||
* The ConnectionGroup wrapped by this DelegatingConnectionGroup.
|
||||
*/
|
||||
protected ConnectionGroup getDelegateConnectionGroup() {
|
||||
return connectionGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return connectionGroup.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
connectionGroup.setIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return connectionGroup.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
connectionGroup.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentIdentifier() {
|
||||
return connectionGroup.getParentIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentIdentifier(String parentIdentifier) {
|
||||
connectionGroup.setParentIdentifier(parentIdentifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(Type type) {
|
||||
connectionGroup.setType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getType() {
|
||||
return connectionGroup.getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getConnectionIdentifiers() throws GuacamoleException {
|
||||
return connectionGroup.getConnectionIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getConnectionGroupIdentifiers() throws GuacamoleException {
|
||||
return connectionGroup.getConnectionGroupIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return connectionGroup.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
connectionGroup.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info)
|
||||
throws GuacamoleException {
|
||||
return connectionGroup.connect(info, currentTokens.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuacamoleTunnel connect(GuacamoleClientInformation info,
|
||||
Map<String, String> tokens) throws GuacamoleException {
|
||||
|
||||
// Make received tokens available within the legacy connect() strictly
|
||||
// in context of the current connect() call
|
||||
try {
|
||||
currentTokens.set(tokens);
|
||||
return connect(info);
|
||||
}
|
||||
finally {
|
||||
currentTokens.remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveConnections() {
|
||||
return connectionGroup.getActiveConnections();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* ConnectionRecord implementation which simply delegates all function calls to
|
||||
* an underlying ConnectionRecord.
|
||||
*/
|
||||
public class DelegatingConnectionRecord extends DelegatingActivityRecord
|
||||
implements ConnectionRecord {
|
||||
|
||||
/**
|
||||
* The wrapped ConnectionRecord.
|
||||
*/
|
||||
private final ConnectionRecord record;
|
||||
|
||||
/**
|
||||
* Wraps the given ConnectionRecord such that all function calls against
|
||||
* this DelegatingConnectionRecord will be delegated to it.
|
||||
*
|
||||
* @param record
|
||||
* The record to wrap.
|
||||
*/
|
||||
public DelegatingConnectionRecord(ConnectionRecord record) {
|
||||
super(record);
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying ConnectionRecord wrapped by this
|
||||
* DelegatingConnectionRecord.
|
||||
*
|
||||
* @return
|
||||
* The ConnectionRecord wrapped by this DelegatingConnectionRecord.
|
||||
*/
|
||||
protected ConnectionRecord getDelegateConnectionRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConnectionIdentifier() {
|
||||
return record.getConnectionIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getConnectionName() {
|
||||
return record.getConnectionName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSharingProfileIdentifier() {
|
||||
return record.getSharingProfileIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSharingProfileName() {
|
||||
return record.getSharingProfileName();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Directory implementation which simply delegates all function calls to an
|
||||
* underlying Directory.
|
||||
*
|
||||
* @param <ObjectType>
|
||||
* The type of objects stored within this Directory.
|
||||
*/
|
||||
public class DelegatingDirectory<ObjectType extends Identifiable>
|
||||
implements Directory<ObjectType> {
|
||||
|
||||
/**
|
||||
* The wrapped Directory.
|
||||
*/
|
||||
private final Directory<ObjectType> directory;
|
||||
|
||||
/**
|
||||
* Wraps the given Directory such that all function calls against this
|
||||
* DelegatingDirectory will be delegated to it.
|
||||
*
|
||||
* @param directory
|
||||
* The directory to wrap.
|
||||
*/
|
||||
public DelegatingDirectory(Directory<ObjectType> directory) {
|
||||
this.directory = directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying Directory wrapped by this DelegatingDirectory.
|
||||
*
|
||||
* @return
|
||||
* The Directory wrapped by this DelegatingDirectory.
|
||||
*/
|
||||
protected Directory<ObjectType> getDelegateDirectory() {
|
||||
return directory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectType get(String identifier) throws GuacamoleException {
|
||||
return directory.get(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ObjectType> getAll(Collection<String> identifiers)
|
||||
throws GuacamoleException {
|
||||
return directory.getAll(identifiers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getIdentifiers() throws GuacamoleException {
|
||||
return directory.getIdentifiers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(ObjectType object) throws GuacamoleException {
|
||||
directory.add(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(ObjectType object) throws GuacamoleException {
|
||||
directory.update(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(String identifier) throws GuacamoleException {
|
||||
directory.remove(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)
|
||||
throws GuacamoleException {
|
||||
directory.tryAtomically(operation);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* SharingProfile implementation which simply delegates all function calls to an
|
||||
* underlying SharingProfile.
|
||||
*/
|
||||
public class DelegatingSharingProfile implements SharingProfile {
|
||||
|
||||
/**
|
||||
* The wrapped SharingProfile.
|
||||
*/
|
||||
private final SharingProfile sharingProfile;
|
||||
|
||||
/**
|
||||
* Wraps the given SharingProfile such that all function calls against this
|
||||
* DelegatingSharingProfile will be delegated to it.
|
||||
*
|
||||
* @param sharingProfile
|
||||
* The SharingProfile to wrap.
|
||||
*/
|
||||
public DelegatingSharingProfile(SharingProfile sharingProfile) {
|
||||
this.sharingProfile = sharingProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying SharingProfile wrapped by this
|
||||
* DelegatingSharingProfile.
|
||||
*
|
||||
* @return
|
||||
* The SharingProfile wrapped by this DelegatingSharingProfile.
|
||||
*/
|
||||
protected SharingProfile getDelegateSharingProfile() {
|
||||
return sharingProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return sharingProfile.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
sharingProfile.setIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sharingProfile.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
sharingProfile.setName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrimaryConnectionIdentifier() {
|
||||
return sharingProfile.getPrimaryConnectionIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrimaryConnectionIdentifier(String identifier) {
|
||||
sharingProfile.setPrimaryConnectionIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getParameters() {
|
||||
return sharingProfile.getParameters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
sharingProfile.setParameters(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return sharingProfile.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
sharingProfile.setAttributes(attributes);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
|
||||
/**
|
||||
* User implementation which simply delegates all function calls to an
|
||||
* underlying User.
|
||||
*/
|
||||
public class DelegatingUser implements User {
|
||||
|
||||
/**
|
||||
* The wrapped User.
|
||||
*/
|
||||
private final User user;
|
||||
|
||||
/**
|
||||
* Wraps the given User such that all function calls against this
|
||||
* DelegatingUser will be delegated to it.
|
||||
*
|
||||
* @param user
|
||||
* The User to wrap.
|
||||
*/
|
||||
public DelegatingUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying User wrapped by this DelegatingUser.
|
||||
*
|
||||
* @return
|
||||
* The User wrapped by this DelegatingUser.
|
||||
*/
|
||||
protected User getDelegateUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return user.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
user.setIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
user.setPassword(password);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return user.isDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
user.setDisabled(disabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return user.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
user.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getLastActive() {
|
||||
return user.getLastActive();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public List<? extends ActivityRecord> getHistory()
|
||||
throws GuacamoleException {
|
||||
return user.getHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
return user.getUserHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemPermissionSet getSystemPermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getSystemPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getConnectionPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getConnectionGroupPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getSharingProfilePermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getSharingProfilePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getActiveConnectionPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getUserPermissions() throws GuacamoleException {
|
||||
return user.getUserPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getUserGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return user.getUserGroupPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||
return user.getUserGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Permissions getEffectivePermissions() throws GuacamoleException {
|
||||
return user.getEffectivePermissions();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.form.Form;
|
||||
|
||||
/**
|
||||
* UserContext implementation which simply delegates all function calls to
|
||||
* an underlying UserContext.
|
||||
*/
|
||||
public class DelegatingUserContext implements UserContext {
|
||||
|
||||
/**
|
||||
* The wrapped UserContext.
|
||||
*/
|
||||
private final UserContext userContext;
|
||||
|
||||
/**
|
||||
* Wraps the given UserContext such that all function calls against this
|
||||
* DelegatingUserContext will be delegated to it.
|
||||
*
|
||||
* @param userContext
|
||||
* The UserContext to wrap.
|
||||
*/
|
||||
public DelegatingUserContext(UserContext userContext) {
|
||||
this.userContext = userContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying UserContext wrapped by this
|
||||
* DelegatingUserContext.
|
||||
*
|
||||
* @return
|
||||
* The UserContext wrapped by this DelegatingUserContext.
|
||||
*/
|
||||
protected UserContext getDelegateUserContext() {
|
||||
return userContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User self() {
|
||||
return userContext.self();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getResource() throws GuacamoleException {
|
||||
return userContext.getResource();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthenticationProvider getAuthenticationProvider() {
|
||||
return userContext.getAuthenticationProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<User> getUserDirectory() throws GuacamoleException {
|
||||
return userContext.getUserDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<UserGroup> getUserGroupDirectory() throws GuacamoleException {
|
||||
return userContext.getUserGroupDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<Connection> getConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getConnectionDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<ConnectionGroup> getConnectionGroupDirectory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getConnectionGroupDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<ActiveConnection> getActiveConnectionDirectory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getActiveConnectionDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Directory<SharingProfile> getSharingProfileDirectory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getSharingProfileDirectory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ConnectionRecord> getConnectionHistory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getConnectionHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivityRecordSet<ActivityRecord> getUserHistory()
|
||||
throws GuacamoleException {
|
||||
return userContext.getUserHistory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConnectionGroup getRootConnectionGroup() throws GuacamoleException {
|
||||
return userContext.getRootConnectionGroup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getUserAttributes() {
|
||||
return userContext.getUserAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getUserPreferenceAttributes() {
|
||||
return userContext.getUserPreferenceAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getUserGroupAttributes() {
|
||||
return userContext.getUserGroupAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getConnectionAttributes() {
|
||||
return userContext.getConnectionAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getConnectionGroupAttributes() {
|
||||
return userContext.getConnectionGroupAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Form> getSharingProfileAttributes() {
|
||||
return userContext.getSharingProfileAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
userContext.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserContext getPrivileged() {
|
||||
return userContext.getPrivileged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return userContext.isValid();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,145 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
|
||||
/**
|
||||
* UserGroup implementation which simply delegates all function calls to an
|
||||
* underlying UserGroup.
|
||||
*/
|
||||
public class DelegatingUserGroup implements UserGroup {
|
||||
|
||||
/**
|
||||
* The wrapped UserGroup.
|
||||
*/
|
||||
private final UserGroup userGroup;
|
||||
|
||||
/**
|
||||
* Wraps the given UserGroup such that all function calls against this
|
||||
* DelegatingUserGroup will be delegated to it.
|
||||
*
|
||||
* @param userGroup
|
||||
* The UserGroup to wrap.
|
||||
*/
|
||||
public DelegatingUserGroup(UserGroup userGroup) {
|
||||
this.userGroup = userGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the underlying UserGroup wrapped by this DelegatingUserGroup.
|
||||
*
|
||||
* @return
|
||||
* The UserGroup wrapped by this DelegatingUserGroup.
|
||||
*/
|
||||
protected UserGroup getDelegateUserGroupGroup() {
|
||||
return userGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return userGroup.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIdentifier(String identifier) {
|
||||
userGroup.setIdentifier(identifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
return userGroup.isDisabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisabled(boolean disabled) {
|
||||
userGroup.setDisabled(disabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAttributes() {
|
||||
return userGroup.getAttributes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, String> attributes) {
|
||||
userGroup.setAttributes(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SystemPermissionSet getSystemPermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getSystemPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getConnectionPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getConnectionGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getConnectionGroupPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getSharingProfilePermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getSharingProfilePermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getActiveConnectionPermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getActiveConnectionPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getUserPermissions() throws GuacamoleException {
|
||||
return userGroup.getUserPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectPermissionSet getUserGroupPermissions()
|
||||
throws GuacamoleException {
|
||||
return userGroup.getUserGroupPermissions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelatedObjectSet getUserGroups() throws GuacamoleException {
|
||||
return userGroup.getUserGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelatedObjectSet getMemberUsers() throws GuacamoleException {
|
||||
return userGroup.getMemberUsers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RelatedObjectSet getMemberUserGroups() throws GuacamoleException {
|
||||
return userGroup.getMemberUserGroups();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,243 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
|
||||
/**
|
||||
* Provides access to a collection of all objects with associated identifiers,
|
||||
* and allows user manipulation and removal. Objects returned by a Directory
|
||||
* are not necessarily backed by the stored objects, thus updating an object
|
||||
* always requires calling the update() function.
|
||||
*
|
||||
* @param <ObjectType>
|
||||
* The type of objects stored within this Directory.
|
||||
*/
|
||||
public interface Directory<ObjectType extends Identifiable> {
|
||||
|
||||
/**
|
||||
* All Directory types that may be found on the {@link UserContext}
|
||||
* interface.
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link ActiveConnection}
|
||||
* objects.
|
||||
*/
|
||||
ACTIVE_CONNECTION(ActiveConnection.class),
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link Connection}
|
||||
* objects.
|
||||
*/
|
||||
CONNECTION(Connection.class),
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link ConnectionGroup}
|
||||
* objects.
|
||||
*/
|
||||
CONNECTION_GROUP(ConnectionGroup.class),
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link SharingProfile}
|
||||
* objects.
|
||||
*/
|
||||
SHARING_PROFILE(SharingProfile.class),
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link User} objects.
|
||||
*/
|
||||
USER(User.class),
|
||||
|
||||
/**
|
||||
* The type of a Directory that contains {@link UserGroup}
|
||||
* objects.
|
||||
*/
|
||||
USER_GROUP(UserGroup.class);
|
||||
|
||||
/**
|
||||
* The base class of the type of object stored within the type of
|
||||
* Directory represented by this Directory.Type.
|
||||
*/
|
||||
private final Class<? extends Identifiable> objectType;
|
||||
|
||||
/**
|
||||
* Creates a new Directory.Type representing the type of a Directory
|
||||
* that contains only subclasses of the given class.
|
||||
*
|
||||
* @param objectType
|
||||
* The base class of the type of object stored within the type of
|
||||
* Directory represented by this Directory.Type.
|
||||
*/
|
||||
private Type(Class<? extends Identifiable> objectType) {
|
||||
this.objectType = objectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base class of the type of object stored within a
|
||||
* {@link Directory} of this type.
|
||||
*
|
||||
* @return
|
||||
* The base class of the type of object stored within a
|
||||
* {@link Directory} of this type.
|
||||
*/
|
||||
public Class<? extends Identifiable> getObjectType() {
|
||||
return objectType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Directory.Type representing the type of a Directory that
|
||||
* could contain an object having the given class. The class may be a
|
||||
* subclass of the overall base class of the objects stored within the
|
||||
* Directory.
|
||||
*
|
||||
* @param objectType
|
||||
* The class to determine the Directory.Type of.
|
||||
*
|
||||
* @return
|
||||
* The Directory.Type representing the type of a Directory that
|
||||
* could contain an object having the given class, or null if there
|
||||
* is no such Directory available via the UserContext interface.
|
||||
*/
|
||||
public static Type of(Class<? extends Identifiable> objectType) {
|
||||
|
||||
for (Type type : Type.values()) {
|
||||
if (type.getObjectType().isAssignableFrom(objectType))
|
||||
return type;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the object having the given identifier. Note that changes to
|
||||
* the object returned will not necessarily affect the object stored within
|
||||
* the Directory. To update an object stored within an
|
||||
* Directory such that future calls to get() will return the updated
|
||||
* object, you must call update() on the object after modification.
|
||||
*
|
||||
* @param identifier The identifier to use when locating the object to
|
||||
* return.
|
||||
* @return The object having the given identifier, or null if no such object
|
||||
* exists.
|
||||
*
|
||||
* @throws GuacamoleException If an error occurs while retrieving the
|
||||
* object, or if permission for retrieving the
|
||||
* object is denied.
|
||||
*/
|
||||
ObjectType get(String identifier) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns the objects having the given identifiers. Note that changes to
|
||||
* any object returned will not necessarily affect the object stored within
|
||||
* the Directory. To update an object stored within a
|
||||
* Directory such that future calls to get() will return the updated
|
||||
* object, you must call update() on the object after modification.
|
||||
*
|
||||
* @param identifiers
|
||||
* The identifiers to use when locating the objects to return.
|
||||
*
|
||||
* @return
|
||||
* The objects having the given identifiers. If any identifiers do not
|
||||
* correspond to accessible objects, those identifiers will be ignored.
|
||||
* If no objects correspond to any of the given identifiers, the
|
||||
* returned collection will be empty.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving the objects, or if permission
|
||||
* to retrieve the requested objects is denied.
|
||||
*/
|
||||
Collection<ObjectType> getAll(Collection<String> identifiers)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns a Set containing all identifiers for all objects within this
|
||||
* Directory.
|
||||
*
|
||||
* @return A Set of all identifiers.
|
||||
* @throws GuacamoleException If an error occurs while retrieving
|
||||
* the identifiers.
|
||||
*/
|
||||
Set<String> getIdentifiers() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Adds the given object to the overall set. If a new identifier is
|
||||
* created for the added object, that identifier will be automatically
|
||||
* assigned via setIdentifier().
|
||||
*
|
||||
* @param object
|
||||
* The object to add.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while adding the object, or if adding the object
|
||||
* is not allowed.
|
||||
*/
|
||||
void add(ObjectType object)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Updates the stored object with the data contained in the given object.
|
||||
*
|
||||
* @param object The object which will supply the data for the update.
|
||||
*
|
||||
* @throws GuacamoleException If an error occurs while updating the object,
|
||||
* or if updating the object is not allowed.
|
||||
*/
|
||||
void update(ObjectType object)
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Removes the object with the given identifier from the overall set.
|
||||
*
|
||||
* @param identifier The identifier of the object to remove.
|
||||
*
|
||||
* @throws GuacamoleException If an error occurs while removing the object,
|
||||
* or if removing the object is not allowed.
|
||||
*/
|
||||
void remove(String identifier) throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Attempt to perform the provided operation atomically if possible. If the
|
||||
* operation can be performed atomically, the atomic flag will be set to
|
||||
* true, and the directory passed to the provided operation callback will
|
||||
* peform directory operations atomically within the operation callback.
|
||||
*
|
||||
* @param operation
|
||||
* The directory operation that should be performed atomically.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs during execution of the provided operation.
|
||||
*/
|
||||
default void tryAtomically(AtomicDirectoryOperation<ObjectType> operation)
|
||||
throws GuacamoleException {
|
||||
|
||||
// By default, perform the operation non-atomically. If atomic operation
|
||||
// is supported by an implementation, it must be implemented there.
|
||||
operation.executeOperation(false, this);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* An interface that defines items that can be enabled or disabled.
|
||||
*/
|
||||
public interface Disableable {
|
||||
|
||||
/**
|
||||
* Returns true if this object is disabled, otherwise false.
|
||||
*
|
||||
* @return
|
||||
* True if this object is disabled, otherwise false.
|
||||
*/
|
||||
default public boolean isDisabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the disabled status of this object to the boolean value provided,
|
||||
* true if the object should be disabled, otherwise false.
|
||||
*
|
||||
* @param disabled
|
||||
* True if the object should be disabled, otherwise false.
|
||||
*/
|
||||
default public void setDisabled(boolean disabled) {
|
||||
// Default implementation takes no action.
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleResourceNotFoundException;
|
||||
import org.apache.guacamole.language.TranslatableMessage;
|
||||
|
||||
/**
|
||||
* ActivityLog implementation that exposes the content of a local file.
|
||||
*/
|
||||
public class FileActivityLog extends AbstractActivityLog {
|
||||
|
||||
/**
|
||||
* The File providing the content of this log.
|
||||
*/
|
||||
private final File content;
|
||||
|
||||
/**
|
||||
* Creates a new FileActivityLog that exposes the content of the given
|
||||
* local file as an {@link ActivityLog}.
|
||||
*
|
||||
* @param type
|
||||
* The type of this ActivityLog.
|
||||
*
|
||||
* @param description
|
||||
* A human-readable message that describes this log.
|
||||
*
|
||||
* @param content
|
||||
* The File that should be used to provide the content of this log.
|
||||
*/
|
||||
public FileActivityLog(Type type, TranslatableMessage description, File content) {
|
||||
super(type, description);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSize() throws GuacamoleException {
|
||||
return content.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getContent() throws GuacamoleException {
|
||||
try {
|
||||
return new FileInputStream(content);
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
throw new GuacamoleResourceNotFoundException("Associated file "
|
||||
+ "does not exist or cannot be read.", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* Information which describes how the connection to guacd should be
|
||||
* established. This includes the hostname and port which guacd is listening on,
|
||||
* as well as the type of encryption required, if any.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public class GuacamoleProxyConfiguration {
|
||||
|
||||
/**
|
||||
* All possible types of encryption used by guacd.
|
||||
*/
|
||||
public enum EncryptionMethod {
|
||||
|
||||
/**
|
||||
* Unencrypted (plaintext).
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* Encrypted with SSL or TLS.
|
||||
*/
|
||||
SSL
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The hostname or address of the machine where guacd is running.
|
||||
*/
|
||||
private final String hostname;
|
||||
|
||||
/**
|
||||
* The port that guacd is listening on.
|
||||
*/
|
||||
private final int port;
|
||||
|
||||
/**
|
||||
* The type of encryption required by guacd.
|
||||
*/
|
||||
private final EncryptionMethod encryptionMethod;
|
||||
|
||||
/**
|
||||
* Creates a new GuacamoleProxyConfiguration having the given hostname,
|
||||
* port, and encryption method.
|
||||
*
|
||||
* @param hostname
|
||||
* The hostname or address of the machine where guacd is running.
|
||||
*
|
||||
* @param port
|
||||
* The port that guacd is listening on.
|
||||
*
|
||||
* @param encryptionMethod
|
||||
* The type of encryption required by the instance of guacd running at
|
||||
* the given hostname and port.
|
||||
*/
|
||||
public GuacamoleProxyConfiguration(String hostname, int port,
|
||||
EncryptionMethod encryptionMethod) {
|
||||
this.hostname = hostname;
|
||||
this.port = port;
|
||||
this.encryptionMethod = encryptionMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new GuacamoleProxyConfiguration having the given hostname and
|
||||
* port, with encryption method being restricted to either NONE or SSL.
|
||||
*
|
||||
* @param hostname
|
||||
* The hostname or address of the machine where guacd is running.
|
||||
*
|
||||
* @param port
|
||||
* The port that guacd is listening on.
|
||||
*
|
||||
* @param ssl
|
||||
* true if guacd requires SSL/TLS encryption, false if communication
|
||||
* with guacd should be unencrypted.
|
||||
*/
|
||||
public GuacamoleProxyConfiguration(String hostname, int port, boolean ssl) {
|
||||
this(hostname, port, ssl ? EncryptionMethod.SSL : EncryptionMethod.NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hostname or address of the machine where guacd is running.
|
||||
*
|
||||
* @return
|
||||
* The hostname or address of the machine where guacd is running.
|
||||
*/
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port that guacd is listening on.
|
||||
*
|
||||
* @return
|
||||
* The port that guacd is listening on.
|
||||
*/
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type of encryption required by guacd.
|
||||
*
|
||||
* @return
|
||||
* The type of encryption required by guacd.
|
||||
*/
|
||||
public EncryptionMethod getEncryptionMethod() {
|
||||
return encryptionMethod;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* An object which has a deterministic, unique identifier, which may not be
|
||||
* null.
|
||||
*/
|
||||
public interface Identifiable {
|
||||
|
||||
/**
|
||||
* Returns the unique identifier assigned to this object. All identifiable
|
||||
* objects must have a deterministic, unique identifier which may not be
|
||||
* null.
|
||||
*
|
||||
* @return
|
||||
* The unique identifier assigned to this object, which may not be
|
||||
* null.
|
||||
*/
|
||||
public String getIdentifier();
|
||||
|
||||
/**
|
||||
* Sets the identifier assigned to this object.
|
||||
*
|
||||
* @param identifier
|
||||
* The identifier to assign.
|
||||
*/
|
||||
public void setIdentifier(String identifier);
|
||||
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import com.google.common.io.BaseEncoding;
|
||||
import java.math.BigInteger;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
/**
|
||||
* Generator of unique and unpredictable identifiers. Each generated identifier
|
||||
* is an arbitrary, random string produced using a cryptographically-secure
|
||||
* random number generator.
|
||||
*/
|
||||
public class IdentifierGenerator {
|
||||
|
||||
/**
|
||||
* Cryptographically-secure random number generator for generating unique
|
||||
* identifiers.
|
||||
*/
|
||||
private static final SecureRandom secureRandom = new SecureRandom();
|
||||
|
||||
/**
|
||||
* IdentifierGenerator is a utility class that is not intended to be
|
||||
* separately instantiated.
|
||||
*/
|
||||
private IdentifierGenerator() {}
|
||||
|
||||
/**
|
||||
* Generates a unique and unpredictable identifier. Each identifier is at
|
||||
* least 256-bit and produced using a cryptographically-secure random
|
||||
* number generator. The identifier may contain characters that differ only
|
||||
* in case.
|
||||
*
|
||||
* @return
|
||||
* A unique and unpredictable identifier with at least 256 bits of
|
||||
* entropy.
|
||||
*/
|
||||
public static String generateIdentifier() {
|
||||
return generateIdentifier(256);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique and unpredictable identifier having at least the
|
||||
* given number of bits of entropy. The resulting identifier may have more
|
||||
* than the number of bits required. The identifier may contain characters
|
||||
* that differ only in case.
|
||||
*
|
||||
* @param minBits
|
||||
* The number of bits of entropy that the identifier should contain.
|
||||
*
|
||||
* @return
|
||||
* A unique and unpredictable identifier with at least the given number
|
||||
* of bits of entropy.
|
||||
*/
|
||||
public static String generateIdentifier(int minBits) {
|
||||
return generateIdentifier(minBits, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique and unpredictable identifier having at least the
|
||||
* given number of bits of entropy. The resulting identifier may have more
|
||||
* than the number of bits required. The identifier may contain characters
|
||||
* that differ only in case.
|
||||
*
|
||||
* @param minBits
|
||||
* The number of bits of entropy that the identifier should contain.
|
||||
*
|
||||
* @param caseSensitive
|
||||
* Whether identifiers are permitted to contain characters that vary
|
||||
* by case. If false, all characters that may vary by case will be
|
||||
* lowercase, and the generated identifier will be longer.
|
||||
*
|
||||
* @return
|
||||
* A unique and unpredictable identifier with at least the given number
|
||||
* of bits of entropy.
|
||||
*/
|
||||
public static String generateIdentifier(int minBits, boolean caseSensitive) {
|
||||
|
||||
// Generate a base64 identifier if we're allowed to vary by case
|
||||
if (caseSensitive) {
|
||||
int minBytes = (minBits + 23) / 24 * 3; // Round up to nearest multiple of 3 bytes, as base64 encodes blocks of 3 bytes at a time
|
||||
byte[] bytes = new byte[minBytes];
|
||||
secureRandom.nextBytes(bytes);
|
||||
return BaseEncoding.base64().encode(bytes);
|
||||
}
|
||||
|
||||
// Generate base32 identifiers if we cannot vary by case
|
||||
minBits = (minBits + 4) / 5 * 5; // Round up to nearest multiple of 5 bits, as base32 encodes 5 bits at a time
|
||||
return new BigInteger(minBits, secureRandom).toString(32);
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
/**
|
||||
* An object which has a human-readable, arbitrary name. No requirement is
|
||||
* imposed by this interface regarding whether this name must be unique,
|
||||
* however implementations are free to impose such restrictions.
|
||||
*/
|
||||
public interface Nameable {
|
||||
|
||||
/**
|
||||
* Returns the human-readable name assigned to this object.
|
||||
*
|
||||
* @return
|
||||
* The name assigned to this object.
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Sets the human-readable name assigned to this object.
|
||||
*
|
||||
* @param name
|
||||
* The name to assign.
|
||||
*/
|
||||
void setName(String name);
|
||||
|
||||
}
|
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.net.auth.permission.ObjectPermissionSet;
|
||||
import org.apache.guacamole.net.auth.permission.SystemPermissionSet;
|
||||
|
||||
/**
|
||||
* An object which may be granted permissions to access/manipulate various
|
||||
* other objects or aspects of the system. The permissions granted are exposed
|
||||
* through subclasses of PermissionSet, and may be mutable depending on the
|
||||
* access level of the current user.
|
||||
*/
|
||||
public interface Permissions {
|
||||
|
||||
/**
|
||||
* Returns all permissions given to this object regarding currently-active
|
||||
* connections.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all active connection permissions granted
|
||||
* to this object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getActiveConnectionPermissions()
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all connection group permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all connection group permissions granted
|
||||
* to this object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getConnectionGroupPermissions()
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all connection permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all connection permissions granted to this
|
||||
* object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getConnectionPermissions() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all sharing profile permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all sharing profile permissions granted to
|
||||
* this object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getSharingProfilePermissions()
|
||||
throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all system-level permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* A SystemPermissionSet of all system-level permissions granted to
|
||||
* this object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
SystemPermissionSet getSystemPermissions() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all user permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all user permissions granted to this
|
||||
* object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getUserPermissions() throws GuacamoleException;
|
||||
|
||||
/**
|
||||
* Returns all user group permissions given to this object.
|
||||
*
|
||||
* @return
|
||||
* An ObjectPermissionSet of all user group permissions granted to this
|
||||
* object.
|
||||
*
|
||||
* @throws GuacamoleException
|
||||
* If an error occurs while retrieving permissions, or if reading all
|
||||
* permissions is not allowed.
|
||||
*/
|
||||
ObjectPermissionSet getUserGroupPermissions() throws GuacamoleException;
|
||||
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.net.auth;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An object which is associated with a set of arbitrary attributes, defined
|
||||
* as name/value pairs.
|
||||
*/
|
||||
public interface ReadableAttributes {
|
||||
|
||||
/**
|
||||
* Returns all attributes associated with this object. The returned map
|
||||
* may not be modifiable.
|
||||
*
|
||||
* @return
|
||||
* A map of all attribute identifiers to their corresponding values,
|
||||
* for all attributes associated with this object, which may not be
|
||||
* modifiable.
|
||||
*/
|
||||
Map<String, String> getAttributes();
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user