mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-728: Migrate existing enum-based GuacamoleProperty implementations to EnumGuacamoleProperty.
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.apache.guacamole.auth.mysql;
|
||||
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/**
|
||||
* The possible JDBC drivers to use when talking to a MySQL-compatible database
|
||||
* server.
|
||||
@@ -28,10 +30,12 @@ public enum MySQLDriver {
|
||||
/**
|
||||
* MySQL driver.
|
||||
*/
|
||||
@PropertyValue("mysql")
|
||||
MYSQL,
|
||||
|
||||
/**
|
||||
* MariaDB driver.
|
||||
*/
|
||||
@PropertyValue("mariadb")
|
||||
MARIADB;
|
||||
}
|
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* 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.auth.mysql;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A property whose value is a MySQL-compatible JDBC driver. The string values
|
||||
* of either "mysql" or "mariadb" are parsed into the corresponding MySQLDriver
|
||||
* enum value. Any values that are not valid result in a parse error.
|
||||
*/
|
||||
public abstract class MySQLDriverProperty implements GuacamoleProperty<MySQLDriver> {
|
||||
|
||||
@Override
|
||||
public MySQLDriver parseValue(String value) throws GuacamoleException {
|
||||
|
||||
// If no value provided, return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// MySQL Driver
|
||||
if (value.equals("mysql"))
|
||||
return MySQLDriver.MYSQL;
|
||||
|
||||
// MariaDB Driver
|
||||
if (value.equals("mariadb"))
|
||||
return MySQLDriver.MARIADB;
|
||||
|
||||
throw new GuacamoleServerException("MySQL driver must be one of \"mysql\" or \"mariadb\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -20,6 +20,7 @@
|
||||
package org.apache.guacamole.auth.mysql;
|
||||
|
||||
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
|
||||
@@ -36,8 +37,8 @@ public class MySQLGuacamoleProperties {
|
||||
/**
|
||||
* The JDBC driver that should be used to talk to MySQL-compatible servers.
|
||||
*/
|
||||
public static final MySQLDriverProperty MYSQL_DRIVER =
|
||||
new MySQLDriverProperty() {
|
||||
public static final EnumGuacamoleProperty<MySQLDriver> MYSQL_DRIVER =
|
||||
new EnumGuacamoleProperty<MySQLDriver>(MySQLDriver.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "mysql-driver"; }
|
||||
|
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.apache.guacamole.auth.sqlserver;
|
||||
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/**
|
||||
* The possible SQL Server drivers to use when using a TDS-compatible database.
|
||||
*/
|
||||
@@ -27,20 +29,24 @@ public enum SQLServerDriver {
|
||||
/**
|
||||
* The open source jTDS driver.
|
||||
*/
|
||||
@PropertyValue("jtds")
|
||||
JTDS,
|
||||
|
||||
/**
|
||||
* The Progress DataDirect driver.
|
||||
*/
|
||||
@PropertyValue("datadirect")
|
||||
DATA_DIRECT,
|
||||
|
||||
/**
|
||||
* The Microsoft Legacy SQL Server driver.
|
||||
*/
|
||||
@PropertyValue("microsoft")
|
||||
MICROSOFT_LEGACY,
|
||||
|
||||
/**
|
||||
* The Microsoft 2005 SQL Server driver.
|
||||
*/
|
||||
@PropertyValue("microsoft2005")
|
||||
MICROSOFT_2005;
|
||||
}
|
||||
|
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* 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.auth.sqlserver;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A property whose value is a SQLServerDriver. The incoming string values of "jtds", "datadirect",
|
||||
* "microsoft", and "microsoft2005" into the corresponding SQLServerDriver enum value. Any
|
||||
* values that are not valid result in a parse error.
|
||||
*/
|
||||
public abstract class SQLServerDriverProperty implements GuacamoleProperty<SQLServerDriver> {
|
||||
|
||||
@Override
|
||||
public SQLServerDriver parseValue(String value) throws GuacamoleException {
|
||||
|
||||
// If no value provided, return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// jTDS Driver
|
||||
if (value.equals("jtds"))
|
||||
return SQLServerDriver.JTDS;
|
||||
|
||||
// Progress DataDirect Driver
|
||||
if (value.equals("datadirect"))
|
||||
return SQLServerDriver.DATA_DIRECT;
|
||||
|
||||
// Microsoft Legacy Driver
|
||||
if (value.equals("microsoft"))
|
||||
return SQLServerDriver.MICROSOFT_LEGACY;
|
||||
|
||||
// Microsoft 2005 Driver
|
||||
if (value.equals("microsoft2005"))
|
||||
return SQLServerDriver.MICROSOFT_2005;
|
||||
|
||||
throw new GuacamoleServerException("SQLServer driver must be one of \"jtds\", \"datadirect\", \"microsoft\", \"microsoft2005\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -20,6 +20,7 @@
|
||||
package org.apache.guacamole.auth.sqlserver;
|
||||
|
||||
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
|
||||
@@ -174,8 +175,8 @@ public class SQLServerGuacamoleProperties {
|
||||
/**
|
||||
* Which TDS-compatible JDBC driver should be used for the connection.
|
||||
*/
|
||||
public static final SQLServerDriverProperty
|
||||
SQLSERVER_DRIVER = new SQLServerDriverProperty() {
|
||||
public static final EnumGuacamoleProperty<SQLServerDriver>
|
||||
SQLSERVER_DRIVER = new EnumGuacamoleProperty<SQLServerDriver>(SQLServerDriver.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "sqlserver-driver"; }
|
||||
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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.auth.ldap.conf;
|
||||
|
||||
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty with a value of AliasDerefMode. The possible strings
|
||||
* "never", "searching", "finding", and "always" are mapped to their values as
|
||||
* an AliasDerefMode object. Anything else results in a parse error.
|
||||
*/
|
||||
public abstract class DereferenceAliasesProperty implements GuacamoleProperty<AliasDerefMode> {
|
||||
|
||||
@Override
|
||||
public AliasDerefMode parseValue(String value) throws GuacamoleException {
|
||||
|
||||
// No value provided, so return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// Never dereference aliases
|
||||
if (value.equals("never"))
|
||||
return AliasDerefMode.NEVER_DEREF_ALIASES;
|
||||
|
||||
// Dereference aliases during search operations, but not at base
|
||||
if (value.equals("searching"))
|
||||
return AliasDerefMode.DEREF_IN_SEARCHING;
|
||||
|
||||
// Dereference aliases to locate base, but not during searches
|
||||
if (value.equals("finding"))
|
||||
return AliasDerefMode.DEREF_FINDING_BASE_OBJ;
|
||||
|
||||
// Always dereference aliases
|
||||
if (value.equals("always"))
|
||||
return AliasDerefMode.DEREF_ALWAYS;
|
||||
|
||||
// Anything else is invalid and results in an error
|
||||
throw new GuacamoleServerException("Dereference aliases must be one of \"never\", \"searching\", \"finding\", or \"always\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.apache.guacamole.auth.ldap.conf;
|
||||
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/**
|
||||
* All possible encryption methods which may be used when connecting to an LDAP
|
||||
* server.
|
||||
@@ -29,12 +31,14 @@ public enum EncryptionMethod {
|
||||
* No encryption will be used. All data will be sent to the LDAP server in
|
||||
* plaintext. Unencrypted LDAP connections use port 389 by default.
|
||||
*/
|
||||
@PropertyValue("none")
|
||||
NONE(389),
|
||||
|
||||
/**
|
||||
* The connection to the LDAP server will be encrypted with SSL. LDAP over
|
||||
* SSL (LDAPS) will use port 636 by default.
|
||||
*/
|
||||
@PropertyValue("ssl")
|
||||
SSL(636),
|
||||
|
||||
/**
|
||||
@@ -42,6 +46,7 @@ public enum EncryptionMethod {
|
||||
* connections are negotiated over the standard LDAP port of 389 - the same
|
||||
* port used for unencrypted traffic.
|
||||
*/
|
||||
@PropertyValue("starttls")
|
||||
STARTTLS(389);
|
||||
|
||||
/**
|
||||
|
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
* 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.auth.ldap.conf;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty whose value is an EncryptionMethod. The string values
|
||||
* "none", "ssl", and "starttls" are each parsed to their corresponding values
|
||||
* within the EncryptionMethod enum. All other string values result in parse
|
||||
* errors.
|
||||
*/
|
||||
public abstract class EncryptionMethodProperty implements GuacamoleProperty<EncryptionMethod> {
|
||||
|
||||
@Override
|
||||
public EncryptionMethod parseValue(String value) throws GuacamoleException {
|
||||
|
||||
// If no value provided, return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// Plaintext (no encryption)
|
||||
if (value.equals("none"))
|
||||
return EncryptionMethod.NONE;
|
||||
|
||||
// SSL
|
||||
if (value.equals("ssl"))
|
||||
return EncryptionMethod.SSL;
|
||||
|
||||
// STARTTLS
|
||||
if (value.equals("starttls"))
|
||||
return EncryptionMethod.STARTTLS;
|
||||
|
||||
// The provided value is not legal
|
||||
throw new GuacamoleServerException("Encryption method must be one of \"none\", \"ssl\", or \"starttls\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -19,7 +19,9 @@
|
||||
|
||||
package org.apache.guacamole.auth.ldap.conf;
|
||||
|
||||
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
|
||||
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
|
||||
@@ -158,8 +160,8 @@ public class LDAPGuacamoleProperties {
|
||||
* The chosen method will also dictate the default port if not already
|
||||
* explicitly specified via LDAP_PORT.
|
||||
*/
|
||||
public static final EncryptionMethodProperty LDAP_ENCRYPTION_METHOD =
|
||||
new EncryptionMethodProperty() {
|
||||
public static final EnumGuacamoleProperty<EncryptionMethod> LDAP_ENCRYPTION_METHOD =
|
||||
new EnumGuacamoleProperty<EncryptionMethod>(EncryptionMethod.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "ldap-encryption-method"; }
|
||||
@@ -181,8 +183,13 @@ public class LDAPGuacamoleProperties {
|
||||
* Property that controls whether or not the LDAP connection follows
|
||||
* (dereferences) aliases as it searches the tree.
|
||||
*/
|
||||
public static final DereferenceAliasesProperty LDAP_DEREFERENCE_ALIASES =
|
||||
new DereferenceAliasesProperty() {
|
||||
public static final EnumGuacamoleProperty<AliasDerefMode> LDAP_DEREFERENCE_ALIASES =
|
||||
new EnumGuacamoleProperty<AliasDerefMode>(
|
||||
"never", AliasDerefMode.NEVER_DEREF_ALIASES,
|
||||
"searching", AliasDerefMode.DEREF_IN_SEARCHING,
|
||||
"finding", AliasDerefMode.DEREF_FINDING_BASE_OBJ,
|
||||
"always", AliasDerefMode.DEREF_ALWAYS
|
||||
) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "ldap-dereference-aliases"; }
|
||||
@@ -257,10 +264,10 @@ public class LDAPGuacamoleProperties {
|
||||
};
|
||||
|
||||
/**
|
||||
* Specify the type of data contained in 'ldap-member-attribute'
|
||||
* Specify the type of data contained in 'ldap-member-attribute'.
|
||||
*/
|
||||
public static final MemberAttributeTypeProperty LDAP_MEMBER_ATTRIBUTE_TYPE =
|
||||
new MemberAttributeTypeProperty() {
|
||||
public static final EnumGuacamoleProperty<MemberAttributeType> LDAP_MEMBER_ATTRIBUTE_TYPE =
|
||||
new EnumGuacamoleProperty<MemberAttributeType>(MemberAttributeType.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "ldap-member-attribute-type"; }
|
||||
|
@@ -19,20 +19,24 @@
|
||||
|
||||
package org.apache.guacamole.auth.ldap.conf;
|
||||
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/**
|
||||
* All possible means of describing membership within
|
||||
* LDAP group directory records.
|
||||
* All possible means of describing membership within LDAP group directory
|
||||
* records.
|
||||
*/
|
||||
public enum MemberAttributeType {
|
||||
|
||||
/**
|
||||
* group membership is specified by DN
|
||||
* Group membership is specified by DN.
|
||||
*/
|
||||
@PropertyValue("dn")
|
||||
DN,
|
||||
|
||||
/**
|
||||
* group membership is specified by usercode
|
||||
* Group membership is specified by usercode.
|
||||
*/
|
||||
@PropertyValue("uid")
|
||||
UID;
|
||||
|
||||
}
|
||||
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* 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.auth.ldap.conf;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty whose value is a MemberAttributeType. The possible
|
||||
* strings "dn" or "uid" are mapped to their values as a MemberAttributeType
|
||||
* enum. Anything else results in a parse error.
|
||||
*/
|
||||
public abstract class MemberAttributeTypeProperty
|
||||
implements GuacamoleProperty<MemberAttributeType> {
|
||||
|
||||
@Override
|
||||
public MemberAttributeType parseValue(String value)
|
||||
throws GuacamoleException {
|
||||
|
||||
// If no value provided, return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// dn
|
||||
if (value.equals("dn"))
|
||||
return MemberAttributeType.DN;
|
||||
|
||||
// uid
|
||||
if (value.equals("uid"))
|
||||
return MemberAttributeType.UID;
|
||||
|
||||
// The provided value is not legal
|
||||
throw new GuacamoleServerException("Member attribute type must be "
|
||||
+ "one of \"dn\" or \"uid\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -68,10 +68,10 @@ public class RadiusAuthenticationProviderModule extends AbstractModule {
|
||||
// Check for MD4 requirement
|
||||
RadiusAuthenticationProtocol authProtocol = environment.getProperty(RadiusGuacamoleProperties.RADIUS_AUTH_PROTOCOL);
|
||||
RadiusAuthenticationProtocol innerProtocol = environment.getProperty(RadiusGuacamoleProperties.RADIUS_EAP_TTLS_INNER_PROTOCOL);
|
||||
if (authProtocol == RadiusAuthenticationProtocol.MSCHAPv1
|
||||
|| authProtocol == RadiusAuthenticationProtocol.MSCHAPv2
|
||||
|| innerProtocol == RadiusAuthenticationProtocol.MSCHAPv1
|
||||
|| innerProtocol == RadiusAuthenticationProtocol.MSCHAPv2) {
|
||||
if (authProtocol == RadiusAuthenticationProtocol.MSCHAP_V1
|
||||
|| authProtocol == RadiusAuthenticationProtocol.MSCHAP_V2
|
||||
|| innerProtocol == RadiusAuthenticationProtocol.MSCHAP_V1
|
||||
|| innerProtocol == RadiusAuthenticationProtocol.MSCHAP_V2) {
|
||||
|
||||
try {
|
||||
MessageDigest.getInstance("MD4");
|
||||
|
@@ -19,6 +19,8 @@
|
||||
|
||||
package org.apache.guacamole.auth.radius.conf;
|
||||
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/**
|
||||
* This enum represents supported RADIUS authentication protocols for
|
||||
* the guacamole-auth-radius extension.
|
||||
@@ -26,93 +28,45 @@ package org.apache.guacamole.auth.radius.conf;
|
||||
public enum RadiusAuthenticationProtocol {
|
||||
|
||||
/**
|
||||
* Password Authentication Protocol (PAP)
|
||||
* Password Authentication Protocol (PAP).
|
||||
*/
|
||||
PAP("pap"),
|
||||
@PropertyValue("pap")
|
||||
PAP,
|
||||
|
||||
/**
|
||||
* Challenge-Handshake Authentication Protocol (CHAP)
|
||||
* Challenge-Handshake Authentication Protocol (CHAP).
|
||||
*/
|
||||
CHAP("chap"),
|
||||
@PropertyValue("chap")
|
||||
CHAP,
|
||||
|
||||
/**
|
||||
* Microsoft implementation of CHAP, Version 1 (MS-CHAPv1)
|
||||
* Microsoft implementation of CHAP, Version 1 (MS-CHAPv1).
|
||||
*/
|
||||
MSCHAPv1("mschapv1"),
|
||||
@PropertyValue("mschapv1")
|
||||
MSCHAP_V1,
|
||||
|
||||
/**
|
||||
* Microsoft implementation of CHAP, Version 2 (MS-CHAPv2)
|
||||
* Microsoft implementation of CHAP, Version 2 (MS-CHAPv2).
|
||||
*/
|
||||
MSCHAPv2("mschapv2"),
|
||||
@PropertyValue("mschapv2")
|
||||
MSCHAP_V2,
|
||||
|
||||
/**
|
||||
* Extensible Authentication Protocol (EAP) with MD5 Hashing (EAP-MD5)
|
||||
* Extensible Authentication Protocol (EAP) with MD5 Hashing (EAP-MD5).
|
||||
*/
|
||||
EAP_MD5("eap-md5"),
|
||||
@PropertyValue("eap-md5")
|
||||
EAP_MD5,
|
||||
|
||||
/**
|
||||
* Extensible Authentication Protocol (EAP) with TLS encryption (EAP-TLS).
|
||||
*/
|
||||
EAP_TLS("eap-tls"),
|
||||
@PropertyValue("eap-tls")
|
||||
EAP_TLS,
|
||||
|
||||
/**
|
||||
* Extensible Authentication Protocol (EAP) with Tunneled TLS (EAP-TTLS).
|
||||
*/
|
||||
EAP_TTLS("eap-ttls");
|
||||
|
||||
/**
|
||||
* This variable stores the string value of the protocol, and is also
|
||||
* used within the extension to pass to JRadius for configuring the
|
||||
* library to talk to the RADIUS server.
|
||||
*/
|
||||
private final String strValue;
|
||||
|
||||
/**
|
||||
* Create a new RadiusAuthenticationProtocol object having the
|
||||
* given string value.
|
||||
*
|
||||
* @param strValue
|
||||
* The value of the protocol to store as a string, which will be used
|
||||
* in specifying the protocol within the guacamole.properties file, and
|
||||
* will also be used by the JRadius library for its configuration.
|
||||
*/
|
||||
RadiusAuthenticationProtocol(String strValue) {
|
||||
this.strValue = strValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* <p>
|
||||
* This function returns the stored string values of the selected RADIUS
|
||||
* protocol, which is used both in Guacamole configuration and also to pass
|
||||
* on to the JRadius library for its configuration.
|
||||
*
|
||||
* @return
|
||||
* The string value stored for the selected RADIUS protocol.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return strValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* For a given String value, return the enum value that matches that string,
|
||||
* or null if no matchi is found.
|
||||
*
|
||||
* @param value
|
||||
* The string value to search for in the list of enums.
|
||||
*
|
||||
* @return
|
||||
* The RadiusAuthenticationProtocol value that is identified by the
|
||||
* provided String value.
|
||||
*/
|
||||
public static RadiusAuthenticationProtocol getEnum(String value) {
|
||||
|
||||
for (RadiusAuthenticationProtocol v : values())
|
||||
if(v.toString().equals(value))
|
||||
return v;
|
||||
|
||||
return null;
|
||||
}
|
||||
@PropertyValue("eap-ttls")
|
||||
EAP_TTLS;
|
||||
|
||||
}
|
||||
|
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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.auth.radius.conf;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty whose value is a RadiusAuthenticationProtocol.
|
||||
*/
|
||||
public abstract class RadiusAuthenticationProtocolProperty
|
||||
implements GuacamoleProperty<RadiusAuthenticationProtocol> {
|
||||
|
||||
@Override
|
||||
public RadiusAuthenticationProtocol parseValue(String value)
|
||||
throws GuacamoleException {
|
||||
|
||||
// Nothing provided, nothing returned
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// Attempt to parse the string value
|
||||
RadiusAuthenticationProtocol authProtocol =
|
||||
RadiusAuthenticationProtocol.getEnum(value);
|
||||
|
||||
// Throw an exception if nothing matched.
|
||||
if (authProtocol == null)
|
||||
throw new GuacamoleServerException(
|
||||
"Invalid or unsupported RADIUS authentication protocol.");
|
||||
|
||||
// Return the answer
|
||||
return authProtocol;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -20,6 +20,7 @@
|
||||
package org.apache.guacamole.auth.radius.conf;
|
||||
|
||||
import org.apache.guacamole.properties.BooleanGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.FileGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
@@ -81,8 +82,8 @@ public class RadiusGuacamoleProperties {
|
||||
/**
|
||||
* The authentication protocol of the RADIUS server to connect to when authenticating users.
|
||||
*/
|
||||
public static final RadiusAuthenticationProtocolProperty RADIUS_AUTH_PROTOCOL =
|
||||
new RadiusAuthenticationProtocolProperty() {
|
||||
public static final EnumGuacamoleProperty<RadiusAuthenticationProtocol> RADIUS_AUTH_PROTOCOL =
|
||||
new EnumGuacamoleProperty<RadiusAuthenticationProtocol>(RadiusAuthenticationProtocol.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "radius-auth-protocol"; }
|
||||
@@ -182,8 +183,8 @@ public class RadiusGuacamoleProperties {
|
||||
/**
|
||||
* The tunneled protocol to use inside a RADIUS EAP-TTLS connection.
|
||||
*/
|
||||
public static final RadiusAuthenticationProtocolProperty RADIUS_EAP_TTLS_INNER_PROTOCOL =
|
||||
new RadiusAuthenticationProtocolProperty() {
|
||||
public static final EnumGuacamoleProperty<RadiusAuthenticationProtocol> RADIUS_EAP_TTLS_INNER_PROTOCOL =
|
||||
new EnumGuacamoleProperty<RadiusAuthenticationProtocol>(RadiusAuthenticationProtocol.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "radius-eap-ttls-inner-protocol"; }
|
||||
|
@@ -23,6 +23,7 @@ import com.google.inject.Inject;
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.environment.Environment;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.IntegerGuacamoleProperty;
|
||||
import org.apache.guacamole.properties.StringGuacamoleProperty;
|
||||
import org.apache.guacamole.totp.TOTPGenerator;
|
||||
@@ -80,8 +81,8 @@ public class ConfigurationService {
|
||||
* default, this will be "sha1". Legal values are "sha1", "sha256", and
|
||||
* "sha512".
|
||||
*/
|
||||
private static final TOTPModeProperty TOTP_MODE =
|
||||
new TOTPModeProperty() {
|
||||
private static final EnumGuacamoleProperty<TOTPGenerator.Mode> TOTP_MODE =
|
||||
new EnumGuacamoleProperty<TOTPGenerator.Mode>(TOTPGenerator.Mode.class) {
|
||||
|
||||
@Override
|
||||
public String getName() { return "totp-mode"; }
|
||||
|
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
* 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.auth.totp.conf;
|
||||
|
||||
import org.apache.guacamole.GuacamoleException;
|
||||
import org.apache.guacamole.GuacamoleServerException;
|
||||
import org.apache.guacamole.properties.GuacamoleProperty;
|
||||
import org.apache.guacamole.totp.TOTPGenerator;
|
||||
|
||||
/**
|
||||
* A GuacamoleProperty whose value is a TOTP generation method. The string
|
||||
* values "sha1", "sha256", and "sha512" are each parsed to their corresponding
|
||||
* values within the TOTPGenerator.Mode enum. All other string values result in
|
||||
* parse errors.
|
||||
*/
|
||||
public abstract class TOTPModeProperty
|
||||
implements GuacamoleProperty<TOTPGenerator.Mode> {
|
||||
|
||||
@Override
|
||||
public TOTPGenerator.Mode parseValue(String value)
|
||||
throws GuacamoleException {
|
||||
|
||||
// If no value provided, return null.
|
||||
if (value == null)
|
||||
return null;
|
||||
|
||||
// SHA1
|
||||
if (value.equals("sha1"))
|
||||
return TOTPGenerator.Mode.SHA1;
|
||||
|
||||
// SHA256
|
||||
if (value.equals("sha256"))
|
||||
return TOTPGenerator.Mode.SHA256;
|
||||
|
||||
// SHA512
|
||||
if (value.equals("sha512"))
|
||||
return TOTPGenerator.Mode.SHA512;
|
||||
|
||||
// The provided value is not legal
|
||||
throw new GuacamoleServerException("TOTP mode must be one of "
|
||||
+ "\"sha1\", \"sha256\", or \"sha512\".");
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -25,6 +25,7 @@ import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;
|
||||
|
||||
/*
|
||||
* NOTE: This TOTP implementation is based on the TOTP reference implementation
|
||||
@@ -124,18 +125,21 @@ public class TOTPGenerator {
|
||||
* TOTP mode which generates hashes using SHA1. TOTP in SHA1 mode
|
||||
* requires 160-bit keys.
|
||||
*/
|
||||
@PropertyValue("sha1")
|
||||
SHA1("HmacSHA1", 20),
|
||||
|
||||
/**
|
||||
* TOTP mode which generates hashes using SHA256. TOTP in SHA256 mode
|
||||
* requires 256-bit keys.
|
||||
*/
|
||||
@PropertyValue("sha256")
|
||||
SHA256("HmacSHA256", 32),
|
||||
|
||||
/**
|
||||
* TOTP mode which generates hashes using SHA512. TOTP in SHA512 mode
|
||||
* requires 512-bit keys.
|
||||
*/
|
||||
@PropertyValue("sha512")
|
||||
SHA512("HmacSHA512", 64);
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user