Debian Codegraph @

src/main/org/h2/security/auth/H2AuthConfig.java

raw
1 /*
2 * Copyright 2004-2023 H2 Group. Multiple-Licensed under the MPL 2.0,
3 * and the EPL 1.0 (https://h2database.com/html/license.html).
4 * Initial Developer: Alessandro Ventura
5 */
6 package org.h2.security.auth;
7
8 import java.util.ArrayList;
9 import java.util.List;
10
11 /**
12 * Describe configuration of H2 DefaultAuthenticator.
13 */
14 public class H2AuthConfig {
15
16 private boolean allowUserRegistration=true;
17 private boolean createMissingRoles=true;
18 private List<RealmConfig> realms;
19 private List<UserToRolesMapperConfig> userToRolesMappers;
20
21 /**
22 * Allow user registration flag. If set to {@code true}
23 * creates external users in the database if not present.
24 *
25 * @return {@code true} in case user registration is allowed,
26 * otherwise returns {@code false}.
27 */
28 public boolean isAllowUserRegistration() {
29 return allowUserRegistration;
30 }
31
32 /**
33 * @param allowUserRegistration Allow user registration flag.
34 */
35 public void setAllowUserRegistration(boolean allowUserRegistration) {
36 this.allowUserRegistration = allowUserRegistration;
37 }
38
39 /**
40 * When set create roles not found in the database. If not set roles not
41 * found in the database are silently skipped.
42 * @return {@code true} if the flag is set, otherwise returns {@code false}.
43 */
44 public boolean isCreateMissingRoles() {
45 return createMissingRoles;
46 }
47
48 /**
49 * When set create roles not found in the database. If not set roles not
50 * found in the database are silently skipped
51 * @param createMissingRoles missing roles flag.
52 */
53 public void setCreateMissingRoles(boolean createMissingRoles) {
54 this.createMissingRoles = createMissingRoles;
55 }
56
57 /**
58 * Gets configuration of authentication realms.
59 *
60 * @return configuration of authentication realms.
61 */
62 public List<RealmConfig> getRealms() {
63 if (realms == null) {
64 realms = new ArrayList<>();
65 }
66 return realms;
67 }
68
69 /**
70 * Sets configuration of authentication realms.
71 *
72 * @param realms configuration of authentication realms.
73 */
74 public void setRealms(List<RealmConfig> realms) {
75 this.realms = realms;
76 }
77
78 /**
79 * Gets configuration of the mappers external users to database roles.
80 *
81 * @return configuration of the mappers external users to database roles.
82 */
83 public List<UserToRolesMapperConfig> getUserToRolesMappers() {
84 if (userToRolesMappers == null) {
85 userToRolesMappers = new ArrayList<>();
86 }
87 return userToRolesMappers;
88 }
89
90 /**
91 * Sets configuration of the mappers external users to database roles.
92 *
93 * @param userToRolesMappers configuration of the mappers external users to database roles.
94 */
95 public void setUserToRolesMappers(List<UserToRolesMapperConfig> userToRolesMappers) {
96 this.userToRolesMappers = userToRolesMappers;
97 }
98 }