From cfac865807e59d026d8bf3daa84d4fcfde9fedf4 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Tue, 19 Jul 2016 13:59:47 -0700 Subject: [PATCH] GUACAMOLE-5: Map sharing profile model objects to database schema. --- .../JDBCAuthenticationProviderModule.java | 10 +- ...er.java => ConnectionParameterMapper.java} | 6 +- ...del.java => ConnectionParameterModel.java} | 2 +- .../jdbc/connection/ConnectionService.java | 14 +- .../SharingProfilePermissionMapper.java | 28 ++++ .../sharingprofile/SharingProfileMapper.java | 91 +++++++++++ .../sharingprofile/SharingProfileModel.java | 112 ++++++++++++++ .../SharingProfileParameterMapper.java | 72 +++++++++ .../SharingProfileParameterModel.java | 108 +++++++++++++ .../AbstractGuacamoleTunnelService.java | 10 +- ...pper.xml => ConnectionParameterMapper.xml} | 6 +- .../SharingProfilePermissionMapper.xml | 117 ++++++++++++++ .../sharingprofile/SharingProfileMapper.xml | 145 ++++++++++++++++++ .../SharingProfileParameterMapper.xml | 68 ++++++++ ...pper.xml => ConnectionParameterMapper.xml} | 6 +- .../SharingProfilePermissionMapper.xml | 117 ++++++++++++++ .../sharingprofile/SharingProfileMapper.xml | 145 ++++++++++++++++++ .../SharingProfileParameterMapper.xml | 68 ++++++++ 18 files changed, 1101 insertions(+), 24 deletions(-) rename extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/{ParameterMapper.java => ConnectionParameterMapper.java} (90%) rename extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/{ParameterModel.java => ConnectionParameterModel.java} (98%) create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.java create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.java create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileModel.java create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.java create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterModel.java rename extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/{ParameterMapper.xml => ConnectionParameterMapper.xml} (93%) create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml rename extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/{ParameterMapper.xml => ConnectionParameterMapper.xml} (93%) create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml create mode 100644 extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCAuthenticationProviderModule.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCAuthenticationProviderModule.java index 76725a6b8..35b15affe 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCAuthenticationProviderModule.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/JDBCAuthenticationProviderModule.java @@ -32,7 +32,6 @@ import org.apache.guacamole.auth.jdbc.user.UserDirectory; import org.apache.guacamole.auth.jdbc.connectiongroup.ConnectionGroupMapper; import org.apache.guacamole.auth.jdbc.connection.ConnectionMapper; import org.apache.guacamole.auth.jdbc.connection.ConnectionRecordMapper; -import org.apache.guacamole.auth.jdbc.connection.ParameterMapper; import org.apache.guacamole.auth.jdbc.permission.SystemPermissionMapper; import org.apache.guacamole.auth.jdbc.user.UserMapper; import org.apache.guacamole.auth.jdbc.connectiongroup.ConnectionGroupService; @@ -59,6 +58,10 @@ import org.apache.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermissio import org.apache.guacamole.auth.jdbc.activeconnection.ActiveConnectionPermissionSet; import org.apache.guacamole.auth.jdbc.activeconnection.ActiveConnectionService; import org.apache.guacamole.auth.jdbc.activeconnection.TrackedActiveConnection; +import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper; +import org.apache.guacamole.auth.jdbc.permission.SharingProfilePermissionMapper; +import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileMapper; +import org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterMapper; import org.apache.guacamole.auth.jdbc.tunnel.RestrictedGuacamoleTunnelService; import org.apache.guacamole.net.auth.AuthenticationProvider; import org.mybatis.guice.MyBatisModule; @@ -118,8 +121,11 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule { addMapperClass(ConnectionGroupPermissionMapper.class); addMapperClass(ConnectionPermissionMapper.class); addMapperClass(ConnectionRecordMapper.class); - addMapperClass(ParameterMapper.class); + addMapperClass(ConnectionParameterMapper.class); addMapperClass(SystemPermissionMapper.class); + addMapperClass(SharingProfileMapper.class); + addMapperClass(SharingProfileParameterMapper.class); + addMapperClass(SharingProfilePermissionMapper.class); addMapperClass(UserMapper.class); addMapperClass(UserPermissionMapper.class); diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.java similarity index 90% rename from extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.java rename to extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.java index d152e600e..8ba3e24c8 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.java @@ -27,7 +27,7 @@ import org.apache.ibatis.annotations.Param; * * @author Michael Jumper */ -public interface ParameterMapper { +public interface ConnectionParameterMapper { /** * Returns a collection of all parameters associated with the connection @@ -42,7 +42,7 @@ public interface ParameterMapper { * having the given identifier. This collection will be empty if no * such connection exists. */ - Collection select(@Param("identifier") String identifier); + Collection select(@Param("identifier") String identifier); /** * Inserts each of the parameter model objects in the given collection as @@ -54,7 +54,7 @@ public interface ParameterMapper { * @return * The number of rows inserted. */ - int insert(@Param("parameters") Collection parameters); + int insert(@Param("parameters") Collection parameters); /** * Deletes all parameters associated with the connection having the given diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterModel.java similarity index 98% rename from extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterModel.java rename to extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterModel.java index f4cff99f3..4750de296 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ParameterModel.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterModel.java @@ -24,7 +24,7 @@ package org.apache.guacamole.auth.jdbc.connection; * * @author Michael Jumper */ -public class ParameterModel { +public class ConnectionParameterModel { /** * The identifier of the connection associated with this parameter. diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java index 7195b4714..70bffbb98 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/connection/ConnectionService.java @@ -70,7 +70,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService getParameterModels(ModeledConnection connection) { + private Collection getParameterModels(ModeledConnection connection) { Map parameters = connection.getConfiguration().getParameters(); // Convert parameters to model objects - Collection parameterModels = new ArrayList(parameters.size()); + Collection parameterModels = new ArrayList(parameters.size()); for (Map.Entry parameterEntry : parameters.entrySet()) { // Get parameter name and value @@ -214,7 +214,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService parameterModels = getParameterModels(connection); + Collection parameterModels = getParameterModels(connection); if (!parameterModels.isEmpty()) parameterMapper.insert(parameterModels); @@ -253,7 +253,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService parameterModels = getParameterModels(object); + Collection parameterModels = getParameterModels(object); parameterMapper.delete(object.getIdentifier()); if (!parameterModels.isEmpty()) parameterMapper.insert(parameterModels); @@ -332,7 +332,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService { + + /** + * Selects the identifiers of all sharing profiles associated with the given + * primary connection, regardless of whether they are readable by any + * particular user. This should only be called on behalf of a system + * administrator. If identifiers are needed by a non-administrative user who + * must have explicit read rights, use selectReadableIdentifiersWithin() + * instead. + * + * @param primaryConnectionIdentifier + * The identifier of the primary connection. + * + * @return + * A Set containing all identifiers of all objects. + */ + Set selectIdentifiersWithin( + @Param("primaryConnectionIdentifier") String primaryConnectionIdentifier); + + /** + * Selects the identifiers of all sharing profiles associated with the given + * primary connection that are explicitly readable by the given user. If + * identifiers are needed by a system administrator (who, by definition, + * does not need explicit read rights), use selectIdentifiersWithin() + * instead. + * + * @param user + * The user whose permissions should determine whether an identifier + * is returned. + * + * @param primaryConnectionIdentifier + * The identifier of the primary connection. + * + * @return + * A Set containing all identifiers of all readable objects. + */ + Set selectReadableIdentifiersWithin(@Param("user") UserModel user, + @Param("primaryConnectionIdentifier") String primaryConnectionIdentifier); + + /** + * Selects the sharing profile associated with the given primary connection + * and having the given name. If no such sharing profile exists, null is + * returned. + * + * @param primaryConnectionIdentifier + * The identifier of the primary connection to search against. + * + * @param name + * The name of the sharing profile to find. + * + * @return + * The sharing profile having the given name and associated with the + * given primary connection, or null if no such sharing profile exists. + */ + SharingProfileModel selectOneByName( + @Param("primaryConnectionIdentifier") String primaryConnectionIdentifier, + @Param("name") String name); + +} \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileModel.java new file mode 100644 index 000000000..939884b6d --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileModel.java @@ -0,0 +1,112 @@ +/* + * 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.jdbc.sharingprofile; + +import org.apache.guacamole.auth.jdbc.base.ObjectModel; + +/** + * Object representation of a Guacamole sharing profile, as represented in the + * database. + * + * @author Michael Jumper + */ +public class SharingProfileModel extends ObjectModel { + + /** + * The human-readable name associated with this sharing profile. + */ + private String name; + + /** + * The identifier of the primary connection associated with this + * sharing profile. + */ + private String primaryConnectionIdentifier; + + /** + * Creates a new, empty sharing profile. + */ + public SharingProfileModel() { + } + + /** + * Returns the name associated with this sharing profile. + * + * @return + * The name associated with this sharing profile. + */ + public String getName() { + return name; + } + + /** + * Sets the name associated with this sharing profile. + * + * @param name + * The name to associate with this sharing profile. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the identifier of the primary connection associated with this + * sharing profile. + * + * @return + * The identifier of the primary connection associated with this + * sharing profile. + */ + public String getPrimaryConnectionIdentifier() { + return primaryConnectionIdentifier; + } + + /** + * Sets the identifier of the primary connection associated with this + * sharing profile. + * + * @param primaryConnectionIdentifier + * The identifier of the primary connection associated with this + * sharing profile. + */ + public void setPrimaryConnectionIdentifier(String primaryConnectionIdentifier) { + this.primaryConnectionIdentifier = primaryConnectionIdentifier; + } + + @Override + public String getIdentifier() { + + // If no associated ID, then no associated identifier + Integer id = getObjectID(); + if (id == null) + return null; + + // Otherwise, the identifier is the ID as a string + return id.toString(); + + } + + @Override + public void setIdentifier(String identifier) { + throw new UnsupportedOperationException("Sharing profile identifiers " + + "are derived from IDs. They cannot be set."); + } + +} diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.java new file mode 100644 index 000000000..14dacaf2b --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.java @@ -0,0 +1,72 @@ +/* + * 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.jdbc.sharingprofile; + +import java.util.Collection; +import org.apache.ibatis.annotations.Param; + +/** + * Mapper for sharing profile parameter objects. + * + * @author Michael Jumper + */ +public interface SharingProfileParameterMapper { + + /** + * Returns a collection of all parameters associated with the sharing + * profile having the given identifier. + * + * @param identifier + * The identifier of the sharing profile whose parameters are to be + * retrieved. + * + * @return + * A collection of all parameters associated with the sharing profile + * having the given identifier. This collection will be empty if no + * such sharing profile exists. + */ + Collection select(@Param("identifier") String identifier); + + /** + * Inserts each of the parameter model objects in the given collection as + * new sharing profile parameters. + * + * @param parameters + * The sharing profile parameters to insert. + * + * @return + * The number of rows inserted. + */ + int insert(@Param("parameters") Collection parameters); + + /** + * Deletes all parameters associated with the sharing profile having the + * given identifier. + * + * @param identifier + * The identifier of the sharing profile whose parameters should be + * deleted. + * + * @return + * The number of rows deleted. + */ + int delete(@Param("identifier") String identifier); + +} diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterModel.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterModel.java new file mode 100644 index 000000000..0332b03f9 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterModel.java @@ -0,0 +1,108 @@ +/* + * 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.jdbc.sharingprofile; + +/** + * A single parameter name/value pair belonging to a sharing profile. + * + * @author Michael Jumper + */ +public class SharingProfileParameterModel { + + /** + * The identifier of the sharing profile associated with this parameter. + */ + private String sharingProfileIdentifier; + + /** + * The name of the parameter. + */ + private String name; + + /** + * The value the parameter is set to. + */ + private String value; + + /** + * Returns the identifier of the sharing profile associated with this + * parameter. + * + * @return + * The identifier of the sharing profile associated with this + * parameter. + */ + public String getSharingProfileIdentifier() { + return sharingProfileIdentifier; + } + + /** + * Sets the identifier of the sharing profile associated with this + * parameter. + * + * @param sharingProfileIdentifier + * The identifier of the sharing profile to associate with this + * parameter. + */ + public void setSharingProfileIdentifier(String sharingProfileIdentifier) { + this.sharingProfileIdentifier = sharingProfileIdentifier; + } + + /** + * Returns the name of this parameter. + * + * @return + * The name of this parameter. + */ + public String getName() { + return name; + } + + /** + * Sets the name of this parameter. + * + * @param name + * The name of this parameter. + */ + public void setName(String name) { + this.name = name; + } + + /** + * Returns the value of this parameter. + * + * @return + * The value of this parameter. + */ + public String getValue() { + return value; + } + + /** + * Sets the value of this parameter. + * + * @param value + * The value of this parameter. + */ + public void setValue(String value) { + this.value = value; + } + +} diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java index 1b65ab823..82af02db9 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/tunnel/AbstractGuacamoleTunnelService.java @@ -35,10 +35,9 @@ import org.apache.guacamole.auth.jdbc.user.AuthenticatedUser; import org.apache.guacamole.auth.jdbc.connection.ModeledConnection; import org.apache.guacamole.auth.jdbc.connectiongroup.ModeledConnectionGroup; import org.apache.guacamole.auth.jdbc.connection.ConnectionRecordMapper; -import org.apache.guacamole.auth.jdbc.connection.ParameterMapper; import org.apache.guacamole.auth.jdbc.connection.ConnectionModel; import org.apache.guacamole.auth.jdbc.connection.ConnectionRecordModel; -import org.apache.guacamole.auth.jdbc.connection.ParameterModel; +import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterModel; import org.apache.guacamole.auth.jdbc.user.UserModel; import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleSecurityException; @@ -55,6 +54,7 @@ import org.apache.guacamole.protocol.GuacamoleConfiguration; import org.apache.guacamole.token.StandardTokens; import org.apache.guacamole.token.TokenFilter; import org.mybatis.guice.transactional.Transactional; +import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper; /** @@ -88,7 +88,7 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS * Mapper for accessing connection parameters. */ @Inject - private ParameterMapper parameterMapper; + private ConnectionParameterMapper parameterMapper; /** * Mapper for accessing connection history. @@ -217,8 +217,8 @@ public abstract class AbstractGuacamoleTunnelService implements GuacamoleTunnelS config.setProtocol(model.getProtocol()); // Set parameters from associated data - Collection parameters = parameterMapper.select(connection.getIdentifier()); - for (ParameterModel parameter : parameters) + Collection parameters = parameterMapper.select(connection.getIdentifier()); + for (ConnectionParameterModel parameter : parameters) config.setParameter(parameter.getName(), parameter.getValue()); // Build token filter containing credential tokens diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml similarity index 93% rename from extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml rename to extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml index 11db08931..ac128ff13 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml @@ -21,10 +21,10 @@ under the License. --> - + - + @@ -48,7 +48,7 @@ - + INSERT INTO guacamole_connection_parameter ( connection_id, diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml new file mode 100644 index 000000000..e7c1d88a8 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile_permission + WHERE (user_id, permission, sharing_profile_id) IN + + (#{permission.userID,jdbcType=INTEGER}, + #{permission.type,jdbcType=VARCHAR}, + #{permission.objectIdentifier,jdbcType=VARCHAR}) + + + + + + + + INSERT IGNORE INTO guacamole_sharing_profile_permission ( + user_id, + permission, + sharing_profile_id + ) + VALUES + + (#{permission.userID,jdbcType=INTEGER}, + #{permission.type,jdbcType=VARCHAR}, + #{permission.objectIdentifier,jdbcType=VARCHAR}) + + + + + \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml new file mode 100644 index 000000000..8b8727fe9 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile + WHERE sharing_profile_id = #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_sharing_profile ( + sharing_profile_name, + primary_connection_id + ) + VALUES ( + #{object.name,jdbcType=VARCHAR}, + #{object.primaryConnectionIdentifier,jdbcType=VARCHAR}, + ) + + + + + + UPDATE guacamole_sharing_profile + SET sharing_profile_name = #{object.name,jdbcType=VARCHAR}, + primary_connection_id = #{object.primaryConnectionIdentifier,jdbcType=VARCHAR} + WHERE sharing_profile_id = #{object.objectID,jdbcType=INTEGER} + + + \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml new file mode 100644 index 000000000..65c309fdf --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-mysql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile_parameter + WHERE sharing_profile_id = #{identifier,jdbcType=VARCHAR} + + + + + + INSERT INTO guacamole_sharing_profile_parameter ( + sharing_profile_id, + parameter_name, + parameter_value + ) + VALUES + + (#{parameter.sharingProfileIdentifier,jdbcType=VARCHAR}, + #{parameter.name,jdbcType=VARCHAR}, + #{parameter.value,jdbcType=VARCHAR}) + + + + + + \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml similarity index 93% rename from extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml rename to extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml index 2039e8a24..3f3af752d 100644 --- a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ParameterMapper.xml +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/connection/ConnectionParameterMapper.xml @@ -21,10 +21,10 @@ under the License. --> - + - + @@ -48,7 +48,7 @@ - + INSERT INTO guacamole_connection_parameter ( connection_id, diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml new file mode 100644 index 000000000..6f65edb03 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/permission/SharingProfilePermissionMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile_permission + WHERE (user_id, permission, sharing_profile_id) IN + + (#{permission.userID,jdbcType=INTEGER}, + #{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type, + #{permission.objectIdentifier,jdbcType=INTEGER}::integer) + + + + + + + + INSERT INTO guacamole_sharing_profile_permission ( + user_id, + permission, + sharing_profile_id + ) + VALUES + + (#{permission.userID,jdbcType=INTEGER}, + #{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type, + #{permission.objectIdentifier,jdbcType=INTEGER}::integer) + + + + + \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml new file mode 100644 index 000000000..ca49a9913 --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileMapper.xml @@ -0,0 +1,145 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile + WHERE sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer + + + + + + INSERT INTO guacamole_sharing_profile ( + sharing_profile_name, + primary_connection_id + ) + VALUES ( + #{object.name,jdbcType=VARCHAR}, + #{object.primaryConnectionIdentifier,jdbcType=INTEGER}::integer + ) + + + + + + UPDATE guacamole_sharing_profile + SET sharing_profile_name = #{object.name,jdbcType=VARCHAR}, + primary_connection_id = #{object.primaryConnectionIdentifier,jdbcType=INTEGER}::integer + WHERE sharing_profile_id = #{object.objectID,jdbcType=INTEGER}::integer + + + \ No newline at end of file diff --git a/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml new file mode 100644 index 000000000..dc7badcde --- /dev/null +++ b/extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-postgresql/src/main/resources/org/apache/guacamole/auth/jdbc/sharingprofile/SharingProfileParameterMapper.xml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + + + + + + + DELETE FROM guacamole_sharing_profile_parameter + WHERE sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer + + + + + + INSERT INTO guacamole_sharing_profile_parameter ( + sharing_profile_id, + parameter_name, + parameter_value + ) + VALUES + + (#{parameter.sharingProfileIdentifier,jdbcType=INTEGER}::integer, + #{parameter.name,jdbcType=VARCHAR}, + #{parameter.value,jdbcType=VARCHAR}) + + + + + + \ No newline at end of file