mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUAC-1101: Remove need for old MySQLConstants.
This commit is contained in:
@@ -129,7 +129,7 @@ public class MySQLConnection implements Connection, DirectoryObject<ConnectionMo
|
|||||||
// Translate null parent to proper identifier
|
// Translate null parent to proper identifier
|
||||||
String parentIdentifier = connectionModel.getParentIdentifier();
|
String parentIdentifier = connectionModel.getParentIdentifier();
|
||||||
if (parentIdentifier == null)
|
if (parentIdentifier == null)
|
||||||
return MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER;
|
return MySQLRootConnectionGroup.IDENTIFIER;
|
||||||
|
|
||||||
return parentIdentifier;
|
return parentIdentifier;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ public class MySQLConnection implements Connection, DirectoryObject<ConnectionMo
|
|||||||
|
|
||||||
// Translate root identifier back into null
|
// Translate root identifier back into null
|
||||||
if (parentIdentifier != null
|
if (parentIdentifier != null
|
||||||
&& parentIdentifier.equals(MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER))
|
&& parentIdentifier.equals(MySQLRootConnectionGroup.IDENTIFIER))
|
||||||
parentIdentifier = null;
|
parentIdentifier = null;
|
||||||
|
|
||||||
connectionModel.setParentID(parentIdentifier);
|
connectionModel.setParentID(parentIdentifier);
|
||||||
|
@@ -1,265 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2013 Glyptodon LLC
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.sourceforge.guacamole.net.auth.mysql;
|
|
||||||
|
|
||||||
import org.glyptodon.guacamole.net.auth.ConnectionGroup;
|
|
||||||
import org.glyptodon.guacamole.net.auth.permission.ObjectPermission;
|
|
||||||
import org.glyptodon.guacamole.net.auth.permission.SystemPermission;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A set of constants that are useful for the MySQL-based authentication provider.
|
|
||||||
* @author James Muehlner
|
|
||||||
*/
|
|
||||||
public final class MySQLConstants {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class should not be instantiated.
|
|
||||||
*/
|
|
||||||
private MySQLConstants() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent READ access to a user.
|
|
||||||
*/
|
|
||||||
public static final String USER_READ = "READ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent UPDATE access to a user.
|
|
||||||
*/
|
|
||||||
public static final String USER_UPDATE = "UPDATE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent DELETE access to a user.
|
|
||||||
*/
|
|
||||||
public static final String USER_DELETE = "DELETE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent ADMINISTER access to a
|
|
||||||
* user.
|
|
||||||
*/
|
|
||||||
public static final String USER_ADMINISTER = "ADMINISTER";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent READ access to a
|
|
||||||
* connection.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_READ = "READ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent UPDATE access to a
|
|
||||||
* connection.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_UPDATE = "UPDATE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent DELETE access to a
|
|
||||||
* connection.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_DELETE = "DELETE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent ADMINISTER access to a
|
|
||||||
* connection.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_ADMINISTER = "ADMINISTER";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent READ access to a
|
|
||||||
* connection.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_READ = "READ";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent UPDATE access to a
|
|
||||||
* connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_UPDATE = "UPDATE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent DELETE access to a
|
|
||||||
* connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_DELETE = "DELETE";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent ADMINISTER access to a
|
|
||||||
* connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_ADMINISTER = "ADMINISTER";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent a BALANCING
|
|
||||||
* connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_BALANCING = "BALANCING";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent an ORGANIZATIONAL
|
|
||||||
* connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_ORGANIZATIONAL =
|
|
||||||
"ORGANIZATIONAL";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The identifier used to mark the root connection group.
|
|
||||||
*/
|
|
||||||
public static final String CONNECTION_GROUP_ROOT_IDENTIFIER = "ROOT";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent permission to create
|
|
||||||
* users.
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_USER_CREATE = "CREATE_USER";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent permission to create
|
|
||||||
* connections.
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_CONNECTION_CREATE = "CREATE_CONNECTION";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent permission to create
|
|
||||||
* connection groups.
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_CONNECTION_GROUP_CREATE = "CREATE_CONNECTION_GROUP";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The string stored in the database to represent permission to administer
|
|
||||||
* the system as a whole.
|
|
||||||
*/
|
|
||||||
public static final String SYSTEM_ADMINISTER = "ADMINISTER";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the type of a permission affecting a user, returns the MySQL
|
|
||||||
* constant representing that permission type.
|
|
||||||
*
|
|
||||||
* @param type The type of permission to look up.
|
|
||||||
* @return The MySQL constant corresponding to the given permission type.
|
|
||||||
*/
|
|
||||||
public static String getUserConstant(ObjectPermission.Type type) {
|
|
||||||
|
|
||||||
// Convert permission type to MySQL constant
|
|
||||||
switch (type) {
|
|
||||||
case READ: return USER_READ;
|
|
||||||
case UPDATE: return USER_UPDATE;
|
|
||||||
case ADMINISTER: return USER_ADMINISTER;
|
|
||||||
case DELETE: return USER_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, permission support was not properly implemented
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Unsupported permission type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the type of a permission affecting a connection, returns the MySQL
|
|
||||||
* constant representing that permission type.
|
|
||||||
*
|
|
||||||
* @param type The type of permission to look up.
|
|
||||||
* @return The MySQL constant corresponding to the given permission type.
|
|
||||||
*/
|
|
||||||
public static String getConnectionConstant(ObjectPermission.Type type) {
|
|
||||||
|
|
||||||
// Convert permission type to MySQL constant
|
|
||||||
switch (type) {
|
|
||||||
case READ: return CONNECTION_READ;
|
|
||||||
case UPDATE: return CONNECTION_UPDATE;
|
|
||||||
case ADMINISTER: return CONNECTION_ADMINISTER;
|
|
||||||
case DELETE: return CONNECTION_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, permission support was not properly implemented
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Unsupported permission type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the type of a permission affecting a connection group,
|
|
||||||
* returns the MySQL constant representing that permission type.
|
|
||||||
*
|
|
||||||
* @param type The type of permission to look up.
|
|
||||||
* @return The MySQL constant corresponding to the given permission type.
|
|
||||||
*/
|
|
||||||
public static String getConnectionGroupConstant(ObjectPermission.Type type) {
|
|
||||||
|
|
||||||
// Convert permission type to MySQL constant
|
|
||||||
switch (type) {
|
|
||||||
case READ: return CONNECTION_GROUP_READ;
|
|
||||||
case UPDATE: return CONNECTION_GROUP_UPDATE;
|
|
||||||
case ADMINISTER: return CONNECTION_GROUP_ADMINISTER;
|
|
||||||
case DELETE: return CONNECTION_GROUP_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, permission support was not properly implemented
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Unsupported permission type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the type of a connection group, returns the MySQL constant
|
|
||||||
* representing that type.
|
|
||||||
*
|
|
||||||
* @param type The connection group type to look up.
|
|
||||||
* @return The MySQL constant corresponding to the given type.
|
|
||||||
*/
|
|
||||||
public static String getConnectionGroupTypeConstant(ConnectionGroup.Type type) {
|
|
||||||
|
|
||||||
// Convert permission type to MySQL constant
|
|
||||||
switch (type) {
|
|
||||||
case ORGANIZATIONAL: return CONNECTION_GROUP_ORGANIZATIONAL;
|
|
||||||
case BALANCING: return CONNECTION_GROUP_BALANCING;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, permission support was not properly implemented
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Unsupported connection group type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Given the type of a permission affecting the system, returns the MySQL
|
|
||||||
* constant representing that permission type.
|
|
||||||
*
|
|
||||||
* @param type The type of permission to look up.
|
|
||||||
* @return The MySQL constant corresponding to the given permission type.
|
|
||||||
*/
|
|
||||||
public static String getSystemConstant(SystemPermission.Type type) {
|
|
||||||
|
|
||||||
// Convert permission type to MySQL constant
|
|
||||||
switch (type) {
|
|
||||||
case CREATE_USER: return SYSTEM_USER_CREATE;
|
|
||||||
case CREATE_CONNECTION: return SYSTEM_CONNECTION_CREATE;
|
|
||||||
case CREATE_CONNECTION_GROUP: return SYSTEM_CONNECTION_GROUP_CREATE;
|
|
||||||
case ADMINISTER: return SYSTEM_ADMINISTER;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we get here, permission support was not properly implemented
|
|
||||||
throw new UnsupportedOperationException(
|
|
||||||
"Unsupported permission type: " + type);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -40,6 +40,20 @@ import org.glyptodon.guacamole.protocol.GuacamoleClientInformation;
|
|||||||
*/
|
*/
|
||||||
public class MySQLRootConnectionGroup implements ConnectionGroup {
|
public class MySQLRootConnectionGroup implements ConnectionGroup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The identifier used to represent the root connection group. There is no
|
||||||
|
* corresponding entry in the database, thus a reserved identifier that
|
||||||
|
* cannot collide with database-generated identifiers is needed.
|
||||||
|
*/
|
||||||
|
public static final String IDENTIFIER = "ROOT";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The human-readable name of this connection group. The name of the root
|
||||||
|
* group is not normally visible, and may even be replaced by the web
|
||||||
|
* interface for the sake of translation.
|
||||||
|
*/
|
||||||
|
public static final String NAME = "ROOT";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user this group belongs to. Access is based on his/her permission
|
* The user this group belongs to. Access is based on his/her permission
|
||||||
* settings.
|
* settings.
|
||||||
@@ -71,7 +85,7 @@ public class MySQLRootConnectionGroup implements ConnectionGroup {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER;
|
return NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -113,7 +127,7 @@ public class MySQLRootConnectionGroup implements ConnectionGroup {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return MySQLConstants.CONNECTION_GROUP_ROOT_IDENTIFIER;
|
return IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user