|
19 | 19 |
|
20 | 20 | package org.apache.guacamole.auth.jdbc.permission; |
21 | 21 |
|
| 22 | +import java.util.Collection; |
| 23 | +import org.apache.guacamole.auth.jdbc.base.EntityModel; |
| 24 | +import org.apache.guacamole.net.auth.permission.ObjectPermission; |
| 25 | +import org.apache.ibatis.annotations.Param; |
| 26 | + |
22 | 27 | /** |
23 | 28 | * Mapper for user permissions. |
24 | 29 | */ |
25 | | -public interface UserPermissionMapper extends ObjectPermissionMapper {} |
| 30 | +public interface UserPermissionMapper extends ObjectPermissionMapper { |
| 31 | + |
| 32 | + /** |
| 33 | + * Deletes the given permissions from the database. If any permissions do |
| 34 | + * not exist, they will be ignored. |
| 35 | + * |
| 36 | + * @param permissions |
| 37 | + * The permissions to delete. |
| 38 | + * |
| 39 | + * @param caseSensitive |
| 40 | + * Whether or not string comparisons for usernames will be done in a |
| 41 | + * case-sensitive manner. |
| 42 | + * |
| 43 | + * @return |
| 44 | + * The number of rows deleted. |
| 45 | + */ |
| 46 | + int delete(@Param("permissions") Collection<ObjectPermission.Type> permissions, |
| 47 | + @Param("caseSensitive") boolean caseSensitive); |
| 48 | + |
| 49 | + /** |
| 50 | + * Inserts the given permissions into the database. If any permissions |
| 51 | + * already exist, they will be ignored. |
| 52 | + * |
| 53 | + * @param permissions |
| 54 | + * The permissions to insert. |
| 55 | + * |
| 56 | + * @param caseSensitive |
| 57 | + * Whether or not string comparisons for usernames will be done in a |
| 58 | + * case-sensitive manner. |
| 59 | + * |
| 60 | + * @return |
| 61 | + * The number of rows inserted. |
| 62 | + */ |
| 63 | + int insert(@Param("permissions") Collection<ObjectPermission.Type> permissions, |
| 64 | + @Param("caseSensitive") boolean caseSensitive); |
| 65 | + |
| 66 | + /** |
| 67 | + * Retrieves all permissions associated with the given entity (user or user |
| 68 | + * group). |
| 69 | + * |
| 70 | + * @param entity |
| 71 | + * The entity to retrieve permissions for. |
| 72 | + * |
| 73 | + * @param effectiveGroups |
| 74 | + * The identifiers of all groups that should be taken into account |
| 75 | + * when determining the permissions effectively granted to the user. If |
| 76 | + * no groups are given, only permissions directly granted to the user |
| 77 | + * will be used. |
| 78 | + * |
| 79 | + * @param caseSensitive |
| 80 | + * Whether or not string comparisons for usernames will be done in a |
| 81 | + * case-sensitive manner. |
| 82 | + * |
| 83 | + * @return |
| 84 | + * All permissions associated with the given entity. |
| 85 | + */ |
| 86 | + Collection<ObjectPermission.Type> select(@Param("entity") EntityModel entity, |
| 87 | + @Param("effectiveGroups") Collection<String> effectiveGroups, |
| 88 | + @Param("caseSensitive") boolean caseSensitive); |
| 89 | + |
| 90 | + /** |
| 91 | + * Retrieve the permission of the given type associated with the given |
| 92 | + * entity and object, if it exists. If no such permission exists, null is |
| 93 | + * returned. |
| 94 | + * |
| 95 | + * @param entity |
| 96 | + * The entity to retrieve permissions for. |
| 97 | + * |
| 98 | + * @param type |
| 99 | + * The type of permission to return. |
| 100 | + * |
| 101 | + * @param identifier |
| 102 | + * The identifier of the object affected by the permission to return. |
| 103 | + * |
| 104 | + * @param effectiveGroups |
| 105 | + * The identifiers of all groups that should be taken into account |
| 106 | + * when determining the permissions effectively granted to the user. If |
| 107 | + * no groups are given, only permissions directly granted to the user |
| 108 | + * will be used. |
| 109 | + * |
| 110 | + * @param caseSensitive |
| 111 | + * Whether or not string comparisons for usernames will be done in a |
| 112 | + * case-sensitive manner. |
| 113 | + * |
| 114 | + * @return |
| 115 | + * The requested permission, or null if no such permission is granted |
| 116 | + * to the given entity for the given object. |
| 117 | + */ |
| 118 | + ObjectPermissionModel selectOne(@Param("entity") EntityModel entity, |
| 119 | + @Param("type") ObjectPermission.Type type, |
| 120 | + @Param("identifier") String identifier, |
| 121 | + @Param("effectiveGroups") Collection<String> effectiveGroups, |
| 122 | + @Param("caseSensitive") boolean caseSensitive); |
| 123 | + |
| 124 | + /** |
| 125 | + * Retrieves the subset of the given identifiers for which the given entity |
| 126 | + * has at least one of the given permissions. |
| 127 | + * |
| 128 | + * @param entity |
| 129 | + * The entity to check permissions of. |
| 130 | + * |
| 131 | + * @param permissions |
| 132 | + * The permissions to check. An identifier will be included in the |
| 133 | + * resulting collection if at least one of these permissions is granted |
| 134 | + * for the associated object |
| 135 | + * |
| 136 | + * @param identifiers |
| 137 | + * The identifiers of the objects affected by the permissions being |
| 138 | + * checked. |
| 139 | + * |
| 140 | + * @param effectiveGroups |
| 141 | + * The identifiers of all groups that should be taken into account |
| 142 | + * when determining the permissions effectively granted to the user. If |
| 143 | + * no groups are given, only permissions directly granted to the user |
| 144 | + * will be used. |
| 145 | + * |
| 146 | + * @param caseSensitive |
| 147 | + * Whether or not string comparisons for usernames will be done in a |
| 148 | + * case-sensitive manner. |
| 149 | + * |
| 150 | + * @return |
| 151 | + * A collection containing the subset of identifiers for which at least |
| 152 | + * one of the specified permissions is granted. |
| 153 | + */ |
| 154 | + Collection<String> selectAccessibleIdentifiers(@Param("entity") EntityModel entity, |
| 155 | + @Param("permissions") Collection<ObjectPermission.Type> permissions, |
| 156 | + @Param("identifiers") Collection<String> identifiers, |
| 157 | + @Param("effectiveGroups") Collection<String> effectiveGroups, |
| 158 | + @Param("caseSenstive") boolean caseSensitive); |
| 159 | + |
| 160 | +} |
0 commit comments