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.common.lib.policy;
20  
21  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
22  import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
23  import java.util.ArrayList;
24  import java.util.List;
25  import org.apache.syncope.common.lib.Schema;
26  import org.apache.syncope.common.lib.types.AnyTypeKind;
27  import org.apache.syncope.common.lib.types.SchemaType;
28  
29  public class DefaultPasswordRuleConf extends AbstractPasswordRuleConf {
30  
31      private static final long serialVersionUID = -7988778083915548547L;
32  
33      private int maxLength;
34  
35      private int minLength;
36  
37      private int alphabetical;
38  
39      private int uppercase;
40  
41      private int lowercase;
42  
43      private int digit;
44  
45      private int special;
46  
47      private final List<Character> specialChars = new ArrayList<>();
48  
49      private final List<Character> illegalChars = new ArrayList<>();
50  
51      private int repeatSame;
52  
53      /**
54       * Specify if using username as password is allowed.
55       */
56      private boolean usernameAllowed;
57  
58      /**
59       * Substrings not permitted.
60       */
61      private final List<String> wordsNotPermitted = new ArrayList<>();
62  
63      /**
64       * User attribute values not permitted.
65       */
66      @Schema(anyTypeKind = AnyTypeKind.USER,
67              type = { SchemaType.PLAIN, SchemaType.DERIVED, SchemaType.VIRTUAL })
68      private final List<String> schemasNotPermitted = new ArrayList<>();
69  
70      public int getMaxLength() {
71          return maxLength;
72      }
73  
74      public void setMaxLength(final int maxLength) {
75          this.maxLength = maxLength;
76      }
77  
78      public int getMinLength() {
79          return minLength;
80      }
81  
82      public void setMinLength(final int minLength) {
83          this.minLength = minLength;
84      }
85  
86      public int getAlphabetical() {
87          return alphabetical;
88      }
89  
90      public void setAlphabetical(final int alphabetical) {
91          this.alphabetical = alphabetical;
92      }
93  
94      public int getUppercase() {
95          return uppercase;
96      }
97  
98      public void setUppercase(final int uppercase) {
99          this.uppercase = uppercase;
100     }
101 
102     public int getLowercase() {
103         return lowercase;
104     }
105 
106     public void setLowercase(final int lowercase) {
107         this.lowercase = lowercase;
108     }
109 
110     public int getDigit() {
111         return digit;
112     }
113 
114     public void setDigit(final int digit) {
115         this.digit = digit;
116     }
117 
118     public int getSpecial() {
119         return special;
120     }
121 
122     public void setSpecial(final int special) {
123         this.special = special;
124     }
125 
126     @JacksonXmlElementWrapper(localName = "specialChars")
127     @JacksonXmlProperty(localName = "char")
128     public List<Character> getSpecialChars() {
129         return specialChars;
130     }
131 
132     @JacksonXmlElementWrapper(localName = "illegalChars")
133     @JacksonXmlProperty(localName = "char")
134     public List<Character> getIllegalChars() {
135         return illegalChars;
136     }
137 
138     public int getRepeatSame() {
139         return repeatSame;
140     }
141 
142     public void setRepeatSame(final int repeatSame) {
143         this.repeatSame = repeatSame;
144     }
145 
146     public boolean isUsernameAllowed() {
147         return usernameAllowed;
148     }
149 
150     public void setUsernameAllowed(final boolean usernameAllowed) {
151         this.usernameAllowed = usernameAllowed;
152     }
153 
154     @JacksonXmlElementWrapper(localName = "wordsNotPermitted")
155     @JacksonXmlProperty(localName = "word")
156     public List<String> getWordsNotPermitted() {
157         return wordsNotPermitted;
158     }
159 
160     @JacksonXmlElementWrapper(localName = "schemasNotPermitted")
161     @JacksonXmlProperty(localName = "schema")
162     public List<String> getSchemasNotPermitted() {
163         return schemasNotPermitted;
164     }
165 }