View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.core.persistence.api.dao;
20  
21  import java.util.Collection;
22  import java.util.List;
23  import java.util.Map;
24  import java.util.Optional;
25  import java.util.Set;
26  import org.apache.commons.lang3.tuple.Pair;
27  import org.apache.syncope.core.persistence.api.entity.ExternalResource;
28  import org.apache.syncope.core.persistence.api.entity.Privilege;
29  import org.apache.syncope.core.persistence.api.entity.Role;
30  import org.apache.syncope.core.persistence.api.entity.group.Group;
31  import org.apache.syncope.core.persistence.api.entity.user.LinkedAccount;
32  import org.apache.syncope.core.persistence.api.entity.user.SecurityQuestion;
33  import org.apache.syncope.core.persistence.api.entity.user.UMembership;
34  import org.apache.syncope.core.persistence.api.entity.user.User;
35  
36  public interface UserDAO extends AnyDAO<User> {
37  
38      String findKey(String username);
39  
40      Optional<String> findUsername(String key);
41  
42      /**
43       * Checks if the calling user is authorized to access the User matching the provided key, under the given
44       * realm.
45       *
46       * @param authRealms realms for which the calling user owns entitlement(s) to check
47       * @param key User key
48       * @param realm User's realm full path
49       * @param groups group the User is member of
50       */
51      void securityChecks(Set<String> authRealms, String key, String realm, Collection<String> groups);
52  
53      Map<String, Integer> countByRealm();
54  
55      Map<String, Integer> countByStatus();
56  
57      User findByUsername(String username);
58  
59      User findByToken(String token);
60  
61      List<User> findBySecurityQuestion(SecurityQuestion securityQuestion);
62  
63      UMembership findMembership(String key);
64  
65      List<Role> findDynRoles(String key);
66  
67      Collection<Role> findAllRoles(User user);
68  
69      List<Group> findDynGroups(String key);
70  
71      Collection<Group> findAllGroups(User user);
72  
73      Collection<String> findAllGroupKeys(User user);
74  
75      Collection<String> findAllGroupNames(User user);
76  
77      Collection<ExternalResource> findAllResources(User user);
78  
79      boolean linkedAccountExists(String userKey, String connObjectKeyValue);
80  
81      Optional<? extends LinkedAccount> findLinkedAccount(ExternalResource resource, String connObjectKeyValue);
82  
83      List<LinkedAccount> findLinkedAccounts(String userKey);
84  
85      List<LinkedAccount> findLinkedAccountsByResource(ExternalResource resource);
86  
87      List<LinkedAccount> findLinkedAccountsByPrivilege(Privilege privilege);
88  
89      Pair<Set<String>, Set<String>> saveAndGetDynGroupMembs(User user);
90  }