mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
GUACAMOLE-220: Add explicit mapper for entities (the basis for users and groups).
This commit is contained in:
@@ -59,6 +59,7 @@ 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.base.EntityMapper;
|
||||
import org.apache.guacamole.auth.jdbc.connection.ConnectionParameterMapper;
|
||||
import org.apache.guacamole.auth.jdbc.permission.SharingProfilePermissionMapper;
|
||||
import org.apache.guacamole.auth.jdbc.permission.SharingProfilePermissionService;
|
||||
@@ -120,6 +121,7 @@ public class JDBCAuthenticationProviderModule extends MyBatisModule {
|
||||
addMapperClass(ConnectionPermissionMapper.class);
|
||||
addMapperClass(ConnectionRecordMapper.class);
|
||||
addMapperClass(ConnectionParameterMapper.class);
|
||||
addMapperClass(EntityMapper.class);
|
||||
addMapperClass(PasswordRecordMapper.class);
|
||||
addMapperClass(SystemPermissionMapper.class);
|
||||
addMapperClass(SharingProfileMapper.class);
|
||||
|
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.apache.guacamole.auth.jdbc.base;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* Mapper for entities. An entity is the base concept behind a user or user
|
||||
* group, and serves as a common point for granting permissions and defining
|
||||
* group membership.
|
||||
*/
|
||||
public interface EntityMapper {
|
||||
|
||||
/**
|
||||
* Inserts the given entity into the database. If the entity already
|
||||
* exists, this will result in an error.
|
||||
*
|
||||
* @param entity
|
||||
* The entity to insert.
|
||||
*
|
||||
* @return
|
||||
* The number of rows inserted.
|
||||
*/
|
||||
int insert(@Param("entity") EntityModel entity);
|
||||
|
||||
}
|
@@ -37,6 +37,7 @@ import org.apache.guacamole.GuacamoleUnsupportedException;
|
||||
import org.apache.guacamole.auth.jdbc.base.ActivityRecordModel;
|
||||
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSearchTerm;
|
||||
import org.apache.guacamole.auth.jdbc.base.ActivityRecordSortPredicate;
|
||||
import org.apache.guacamole.auth.jdbc.base.EntityMapper;
|
||||
import org.apache.guacamole.auth.jdbc.base.ModeledActivityRecord;
|
||||
import org.apache.guacamole.auth.jdbc.permission.ObjectPermissionMapper;
|
||||
import org.apache.guacamole.auth.jdbc.permission.ObjectPermissionModel;
|
||||
@@ -113,6 +114,12 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
|
||||
CONFIRM_NEW_PASSWORD
|
||||
));
|
||||
|
||||
/**
|
||||
* Mapper for creating/deleting entities.
|
||||
*/
|
||||
@Inject
|
||||
private EntityMapper entityMapper;
|
||||
|
||||
/**
|
||||
* Mapper for accessing users.
|
||||
*/
|
||||
@@ -242,6 +249,9 @@ public class UserService extends ModeledDirectoryObjectService<ModeledUser, User
|
||||
if (object.getPassword() != null)
|
||||
passwordPolicyService.verifyPassword(object.getIdentifier(), object.getPassword());
|
||||
|
||||
// Create base entity object, implicitly populating underlying entity ID
|
||||
entityMapper.insert(model);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,41 @@
|
||||
<?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.base.EntityMapper" >
|
||||
|
||||
<!-- Insert single entity -->
|
||||
<insert id="insert" useGeneratedKeys="true" keyProperty="entity.entityID"
|
||||
parameterType="org.apache.guacamole.auth.jdbc.base.EntityModel">
|
||||
|
||||
INSERT INTO guacamole_entity (
|
||||
name,
|
||||
type
|
||||
)
|
||||
VALUES (
|
||||
#{entity.identifier,jdbcType=VARCHAR},
|
||||
#{entity.entityType,jdbcType=VARCHAR}::guacamole_entity_type
|
||||
)
|
||||
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user