mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-5: Map sharing profile model objects to database schema.
This commit is contained in:
@@ -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);
|
||||
|
||||
|
@@ -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<ParameterModel> select(@Param("identifier") String identifier);
|
||||
Collection<ConnectionParameterModel> 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<ParameterModel> parameters);
|
||||
int insert(@Param("parameters") Collection<ConnectionParameterModel> parameters);
|
||||
|
||||
/**
|
||||
* Deletes all parameters associated with the connection having the given
|
@@ -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.
|
@@ -70,7 +70,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
* Mapper for accessing connection parameters.
|
||||
*/
|
||||
@Inject
|
||||
private ParameterMapper parameterMapper;
|
||||
private ConnectionParameterMapper parameterMapper;
|
||||
|
||||
/**
|
||||
* Mapper for accessing connection history.
|
||||
@@ -197,12 +197,12 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
* A collection of parameter models containing the name/value pairs
|
||||
* of the given connection's parameters.
|
||||
*/
|
||||
private Collection<ParameterModel> getParameterModels(ModeledConnection connection) {
|
||||
private Collection<ConnectionParameterModel> getParameterModels(ModeledConnection connection) {
|
||||
|
||||
Map<String, String> parameters = connection.getConfiguration().getParameters();
|
||||
|
||||
// Convert parameters to model objects
|
||||
Collection<ParameterModel> parameterModels = new ArrayList<ParameterModel>(parameters.size());
|
||||
Collection<ConnectionParameterModel> parameterModels = new ArrayList<ConnectionParameterModel>(parameters.size());
|
||||
for (Map.Entry<String, String> parameterEntry : parameters.entrySet()) {
|
||||
|
||||
// Get parameter name and value
|
||||
@@ -214,7 +214,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
continue;
|
||||
|
||||
// Produce model object from parameter
|
||||
ParameterModel model = new ParameterModel();
|
||||
ConnectionParameterModel model = new ConnectionParameterModel();
|
||||
model.setConnectionIdentifier(connection.getIdentifier());
|
||||
model.setName(name);
|
||||
model.setValue(value);
|
||||
@@ -237,7 +237,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
connection.setConfiguration(object.getConfiguration());
|
||||
|
||||
// Insert new parameters, if any
|
||||
Collection<ParameterModel> parameterModels = getParameterModels(connection);
|
||||
Collection<ConnectionParameterModel> parameterModels = getParameterModels(connection);
|
||||
if (!parameterModels.isEmpty())
|
||||
parameterMapper.insert(parameterModels);
|
||||
|
||||
@@ -253,7 +253,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
super.updateObject(user, object);
|
||||
|
||||
// Replace existing parameters with new parameters, if any
|
||||
Collection<ParameterModel> parameterModels = getParameterModels(object);
|
||||
Collection<ConnectionParameterModel> parameterModels = getParameterModels(object);
|
||||
parameterMapper.delete(object.getIdentifier());
|
||||
if (!parameterModels.isEmpty())
|
||||
parameterMapper.insert(parameterModels);
|
||||
@@ -332,7 +332,7 @@ public class ConnectionService extends ModeledGroupedDirectoryObjectService<Mode
|
||||
|
||||
// Populate parameter map if we have permission to do so
|
||||
if (canRetrieveParameters) {
|
||||
for (ParameterModel parameter : parameterMapper.select(identifier))
|
||||
for (ConnectionParameterModel parameter : parameterMapper.select(identifier))
|
||||
parameterMap.put(parameter.getName(), parameter.getValue());
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* 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.permission;
|
||||
|
||||
/**
|
||||
* Mapper for sharing profile permissions.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public interface SharingProfilePermissionMapper
|
||||
extends ObjectPermissionMapper {}
|
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* 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.Set;
|
||||
import org.apache.guacamole.auth.jdbc.base.ModeledDirectoryObjectMapper;
|
||||
import org.apache.guacamole.auth.jdbc.user.UserModel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* Mapper for sharing profile objects.
|
||||
*
|
||||
* @author Michael Jumper
|
||||
*/
|
||||
public interface SharingProfileMapper
|
||||
extends ModeledDirectoryObjectMapper<SharingProfileModel> {
|
||||
|
||||
/**
|
||||
* 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<String> 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<String> 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);
|
||||
|
||||
}
|
@@ -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.");
|
||||
}
|
||||
|
||||
}
|
@@ -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<SharingProfileParameterModel> 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<SharingProfileParameterModel> 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);
|
||||
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
@@ -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<ParameterModel> parameters = parameterMapper.select(connection.getIdentifier());
|
||||
for (ParameterModel parameter : parameters)
|
||||
Collection<ConnectionParameterModel> parameters = parameterMapper.select(connection.getIdentifier());
|
||||
for (ConnectionParameterModel parameter : parameters)
|
||||
config.setParameter(parameter.getName(), parameter.getValue());
|
||||
|
||||
// Build token filter containing credential tokens
|
||||
|
@@ -21,10 +21,10 @@
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.connection.ParameterMapper">
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper">
|
||||
|
||||
<!-- Result mapper for connection parameters -->
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.connection.ParameterModel">
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterModel">
|
||||
<result column="connection_id" property="connectionIdentifier" jdbcType="INTEGER"/>
|
||||
<result column="parameter_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="parameter_value" property="value" jdbcType="VARCHAR"/>
|
||||
@@ -48,7 +48,7 @@
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given parameters -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.connection.ParameterModel">
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterModel">
|
||||
|
||||
INSERT INTO guacamole_connection_parameter (
|
||||
connection_id,
|
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.permission.SharingProfilePermissionMapper">
|
||||
|
||||
<!-- Result mapper for sharig profile permissions -->
|
||||
<resultMap id="SharingProfilePermissionResultMap" type="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
<result column="user_id" property="userID" jdbcType="INTEGER"/>
|
||||
<result column="username" property="username" jdbcType="VARCHAR"/>
|
||||
<result column="permission" property="type" jdbcType="VARCHAR"
|
||||
javaType="org.apache.guacamole.net.auth.permission.ObjectPermission$Type"/>
|
||||
<result column="sharing_profile_id" property="objectIdentifier" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all permissions for a given user -->
|
||||
<select id="select" resultMap="SharingProfilePermissionResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile_permission.user_id,
|
||||
username,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
JOIN guacamole_user ON guacamole_sharing_profile_permission.user_id = guacamole_user.user_id
|
||||
WHERE guacamole_sharing_profile_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select the single permission matching the given criteria -->
|
||||
<select id="selectOne" resultMap="SharingProfilePermissionResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile_permission.user_id,
|
||||
username,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
JOIN guacamole_user ON guacamole_sharing_profile_permission.user_id = guacamole_user.user_id
|
||||
WHERE
|
||||
guacamole_sharing_profile_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = #{type,jdbcType=VARCHAR}
|
||||
AND sharing_profile_id = #{identifier,jdbcType=VARCHAR}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers accessible by the given user for the given permissions -->
|
||||
<select id="selectAccessibleIdentifiers" resultType="string">
|
||||
|
||||
SELECT DISTINCT sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
WHERE
|
||||
user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
AND permission IN
|
||||
<foreach collection="permissions" item="permission"
|
||||
open="(" separator="," close=")">
|
||||
#{permission,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Delete all given permissions -->
|
||||
<delete id="delete" parameterType="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
|
||||
DELETE FROM guacamole_sharing_profile_permission
|
||||
WHERE (user_id, permission, sharing_profile_id) IN
|
||||
<foreach collection="permissions" item="permission"
|
||||
open="(" separator="," close=")">
|
||||
(#{permission.userID,jdbcType=INTEGER},
|
||||
#{permission.type,jdbcType=VARCHAR},
|
||||
#{permission.objectIdentifier,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given permissions -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
|
||||
INSERT IGNORE INTO guacamole_sharing_profile_permission (
|
||||
user_id,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="permissions" item="permission" separator=",">
|
||||
(#{permission.userID,jdbcType=INTEGER},
|
||||
#{permission.type,jdbcType=VARCHAR},
|
||||
#{permission.objectIdentifier,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileMapper">
|
||||
|
||||
<!-- Result mapper for sharing profile objects -->
|
||||
<resultMap id="SharingProfileResultMap" type="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
<id column="sharing_profile_id" property="objectID" jdbcType="INTEGER"/>
|
||||
<result column="sharing_profile_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="primary_connection_id" property="primaryConnectionIdentifier" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all sharing profile identifiers -->
|
||||
<select id="selectIdentifiers" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers of all readable sharing profiles -->
|
||||
<select id="selectReadableIdentifiers" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
WHERE
|
||||
user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
</select>
|
||||
|
||||
<!-- Select all sharing profiles identifiers associated with a particular connection -->
|
||||
<select id="selectIdentifiersWithin" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
||||
<select id="selectReadableIdentifiersWithin" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=VARCHAR}
|
||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
</select>
|
||||
|
||||
<!-- Select multiple sharing profiles by identifier -->
|
||||
<select id="select" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select multiple sharing profiles by identifier only if readable -->
|
||||
<select id="selectReadable" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile.sharing_profile_id,
|
||||
guacamole_sharing_profile.sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||
WHERE guacamole_sharing_profile.sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=VARCHAR}
|
||||
</foreach>
|
||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select single sharing profile by name -->
|
||||
<select id="selectOneByName" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=VARCHAR}
|
||||
AND sharing_profile_name = #{name,jdbcType=VARCHAR}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Delete single sharing profile by identifier -->
|
||||
<delete id="delete">
|
||||
DELETE FROM guacamole_sharing_profile
|
||||
WHERE sharing_profile_id = #{identifier,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
|
||||
<!-- Insert single sharing profile -->
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="object.objectID"
|
||||
parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
|
||||
INSERT INTO guacamole_sharing_profile (
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
)
|
||||
VALUES (
|
||||
#{object.name,jdbcType=VARCHAR},
|
||||
#{object.primaryConnectionIdentifier,jdbcType=VARCHAR},
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
<!-- Update single sharing profile -->
|
||||
<update id="update" parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
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}
|
||||
</update>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterMapper">
|
||||
|
||||
<!-- Result mapper for sharing profile parameters -->
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterModel">
|
||||
<result column="sharing_profile_id" property="sharingProfileIdentifier" jdbcType="INTEGER"/>
|
||||
<result column="parameter_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="parameter_value" property="value" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all parameters of a given sharing profile -->
|
||||
<select id="select" resultMap="ParameterResultMap">
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
parameter_name,
|
||||
parameter_value
|
||||
FROM guacamole_sharing_profile_parameter
|
||||
WHERE
|
||||
sharing_profile_id = #{identifier,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<!-- Delete all parameters of a given sharing profile -->
|
||||
<delete id="delete">
|
||||
DELETE FROM guacamole_sharing_profile_parameter
|
||||
WHERE sharing_profile_id = #{identifier,jdbcType=VARCHAR}
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given parameters -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterModel">
|
||||
|
||||
INSERT INTO guacamole_sharing_profile_parameter (
|
||||
sharing_profile_id,
|
||||
parameter_name,
|
||||
parameter_value
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="parameters" item="parameter" separator=",">
|
||||
(#{parameter.sharingProfileIdentifier,jdbcType=VARCHAR},
|
||||
#{parameter.name,jdbcType=VARCHAR},
|
||||
#{parameter.value,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
@@ -21,10 +21,10 @@
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.connection.ParameterMapper">
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper">
|
||||
|
||||
<!-- Result mapper for connection parameters -->
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.connection.ParameterModel">
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterModel">
|
||||
<result column="connection_id" property="connectionIdentifier" jdbcType="INTEGER"/>
|
||||
<result column="parameter_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="parameter_value" property="value" jdbcType="VARCHAR"/>
|
||||
@@ -48,7 +48,7 @@
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given parameters -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.connection.ParameterModel">
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.connection.ConnectionParameterModel">
|
||||
|
||||
INSERT INTO guacamole_connection_parameter (
|
||||
connection_id,
|
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.permission.SharingProfilePermissionMapper">
|
||||
|
||||
<!-- Result mapper for sharing profile permissions -->
|
||||
<resultMap id="SharingProfilePermissionResultMap" type="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
<result column="user_id" property="userID" jdbcType="INTEGER"/>
|
||||
<result column="username" property="username" jdbcType="VARCHAR"/>
|
||||
<result column="permission" property="type" jdbcType="VARCHAR"
|
||||
javaType="org.apache.guacamole.net.auth.permission.ObjectPermission$Type"/>
|
||||
<result column="sharing_profile_id" property="objectIdentifier" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all permissions for a given user -->
|
||||
<select id="select" resultMap="SharingProfilePermissionResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile_permission.user_id,
|
||||
username,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
JOIN guacamole_user ON guacamole_sharing_profile_permission.user_id = guacamole_user.user_id
|
||||
WHERE guacamole_sharing_profile_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select the single permission matching the given criteria -->
|
||||
<select id="selectOne" resultMap="SharingProfilePermissionResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile_permission.user_id,
|
||||
username,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
JOIN guacamole_user ON guacamole_sharing_profile_permission.user_id = guacamole_user.user_id
|
||||
WHERE
|
||||
guacamole_sharing_profile_permission.user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = #{type,jdbcType=VARCHAR}::guacamole_object_permission_type
|
||||
AND sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers accessible by the given user for the given permissions -->
|
||||
<select id="selectAccessibleIdentifiers" resultType="string">
|
||||
|
||||
SELECT DISTINCT sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
WHERE
|
||||
user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=INTEGER}::integer
|
||||
</foreach>
|
||||
AND permission IN
|
||||
<foreach collection="permissions" item="permission"
|
||||
open="(" separator="," close=")">
|
||||
#{permission,jdbcType=VARCHAR}::guacamole_object_permission_type
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Delete all given permissions -->
|
||||
<delete id="delete" parameterType="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
|
||||
DELETE FROM guacamole_sharing_profile_permission
|
||||
WHERE (user_id, permission, sharing_profile_id) IN
|
||||
<foreach collection="permissions" item="permission"
|
||||
open="(" separator="," close=")">
|
||||
(#{permission.userID,jdbcType=INTEGER},
|
||||
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type,
|
||||
#{permission.objectIdentifier,jdbcType=INTEGER}::integer)
|
||||
</foreach>
|
||||
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given permissions -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel">
|
||||
|
||||
INSERT INTO guacamole_sharing_profile_permission (
|
||||
user_id,
|
||||
permission,
|
||||
sharing_profile_id
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="permissions" item="permission" separator=",">
|
||||
(#{permission.userID,jdbcType=INTEGER},
|
||||
#{permission.type,jdbcType=VARCHAR}::guacamole_object_permission_type,
|
||||
#{permission.objectIdentifier,jdbcType=INTEGER}::integer)
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileMapper">
|
||||
|
||||
<!-- Result mapper for sharing profile objects -->
|
||||
<resultMap id="SharingProfileResultMap" type="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
<id column="sharing_profile_id" property="objectID" jdbcType="INTEGER"/>
|
||||
<result column="sharing_profile_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="primary_connection_id" property="primaryConnectionIdentifier" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all sharing profile identifiers -->
|
||||
<select id="selectIdentifiers" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers of all readable sharing profiles -->
|
||||
<select id="selectReadableIdentifiers" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile_permission
|
||||
WHERE
|
||||
user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
</select>
|
||||
|
||||
<!-- Select all sharing profile identifiers associated with a particular connection -->
|
||||
<select id="selectIdentifiersWithin" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=INTEGER}::integer
|
||||
</select>
|
||||
|
||||
<!-- Select identifiers of all readable sharing profiles associated with a particular connection -->
|
||||
<select id="selectReadableIdentifiersWithin" resultType="string">
|
||||
SELECT sharing_profile_id
|
||||
FROM guacamole_sharing_profile
|
||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=INTEGER}::integer
|
||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
</select>
|
||||
|
||||
<!-- Select multiple sharing profiles by identifier -->
|
||||
<select id="select" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=INTEGER}::integer
|
||||
</foreach>
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select multiple sharing profiles by identifier only if readable -->
|
||||
<select id="selectReadable" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
guacamole_sharing_profile.sharing_profile_id,
|
||||
guacamole_sharing_profile.sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
JOIN guacamole_sharing_profile_permission ON guacamole_sharing_profile_permission.sharing_profile_id = guacamole_sharing_profile.sharing_profile_id
|
||||
WHERE guacamole_sharing_profile.sharing_profile_id IN
|
||||
<foreach collection="identifiers" item="identifier"
|
||||
open="(" separator="," close=")">
|
||||
#{identifier,jdbcType=INTEGER}::integer
|
||||
</foreach>
|
||||
AND user_id = #{user.objectID,jdbcType=INTEGER}
|
||||
AND permission = 'READ'
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Select single sharing profile by name -->
|
||||
<select id="selectOneByName" resultMap="SharingProfileResultMap">
|
||||
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
FROM guacamole_sharing_profile
|
||||
WHERE
|
||||
primary_connection_id = #{primaryConnectionIdentifier,jdbcType=INTEGER}::integer
|
||||
AND sharing_profile_name = #{name,jdbcType=VARCHAR}
|
||||
|
||||
</select>
|
||||
|
||||
<!-- Delete single sharing profile by identifier -->
|
||||
<delete id="delete">
|
||||
DELETE FROM guacamole_sharing_profile
|
||||
WHERE sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer
|
||||
</delete>
|
||||
|
||||
<!-- Insert single sharing profile -->
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="object.objectID"
|
||||
parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
|
||||
INSERT INTO guacamole_sharing_profile (
|
||||
sharing_profile_name,
|
||||
primary_connection_id
|
||||
)
|
||||
VALUES (
|
||||
#{object.name,jdbcType=VARCHAR},
|
||||
#{object.primaryConnectionIdentifier,jdbcType=INTEGER}::integer
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
<!-- Update single sharing profile -->
|
||||
<update id="update" parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileModel">
|
||||
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
|
||||
</update>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<mapper namespace="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterMapper">
|
||||
|
||||
<!-- Result mapper for sharing profile parameters -->
|
||||
<resultMap id="ParameterResultMap" type="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterModel">
|
||||
<result column="sharing_profile_id" property="sharingProfileIdentifier" jdbcType="INTEGER"/>
|
||||
<result column="parameter_name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="parameter_value" property="value" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- Select all parameters of a given sharing profile -->
|
||||
<select id="select" resultMap="ParameterResultMap">
|
||||
SELECT
|
||||
sharing_profile_id,
|
||||
parameter_name,
|
||||
parameter_value
|
||||
FROM guacamole_sharing_profile_parameter
|
||||
WHERE
|
||||
sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer
|
||||
</select>
|
||||
|
||||
<!-- Delete all parameters of a given sharing profile -->
|
||||
<delete id="delete">
|
||||
DELETE FROM guacamole_sharing_profile_parameter
|
||||
WHERE sharing_profile_id = #{identifier,jdbcType=INTEGER}::integer
|
||||
</delete>
|
||||
|
||||
<!-- Insert all given parameters -->
|
||||
<insert id="insert" parameterType="org.apache.guacamole.auth.jdbc.sharingprofile.SharingProfileParameterModel">
|
||||
|
||||
INSERT INTO guacamole_sharing_profile_parameter (
|
||||
sharing_profile_id,
|
||||
parameter_name,
|
||||
parameter_value
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="parameters" item="parameter" separator=",">
|
||||
(#{parameter.sharingProfileIdentifier,jdbcType=INTEGER}::integer,
|
||||
#{parameter.name,jdbcType=VARCHAR},
|
||||
#{parameter.value,jdbcType=VARCHAR})
|
||||
</foreach>
|
||||
|
||||
</insert>
|
||||
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user