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.auth;
20  
21  import java.io.Serializable;
22  import java.util.Map;
23  import org.apache.syncope.common.lib.AbstractLDAPConf;
24  import org.apache.syncope.common.lib.to.AuthModuleTO;
25  
26  public class GoogleMfaAuthModuleConf implements MFAAuthModuleConf {
27  
28      private static final long serialVersionUID = -7883257599139312426L;
29  
30      public static class LDAP extends AbstractLDAPConf implements Serializable {
31  
32          private static final long serialVersionUID = -7274446267090678730L;
33  
34          /**
35           * Name of LDAP attribute that holds GAuth account/credential as JSON.
36           */
37          private String accountAttributeName = "casGAuthRecord";
38  
39          public String getAccountAttributeName() {
40              return accountAttributeName;
41          }
42  
43          public void setAccountAttributeName(final String accountAttributeName) {
44              this.accountAttributeName = accountAttributeName;
45          }
46      }
47  
48      /**
49       * Issuer used in the barcode when dealing with device registration events.
50       * Used in the registration URL to identify CAS.
51       */
52      private String issuer = "Syncope";
53  
54      /**
55       * Label used in the barcode when dealing with device registration events.
56       * Used in the registration URL to identify CAS.
57       */
58      private String label = "Syncope";
59  
60      /**
61       * Length of the generated code.
62       */
63      private int codeDigits = 6;
64  
65      /**
66       * The expiration time of the generated code in seconds.
67       */
68      private long timeStepSize = 30;
69  
70      /**
71       * Since TOTP passwords are time-based, it is essential that
72       * the clock of both the server and
73       * the client are synchronised within
74       * the tolerance defined here as the window size.
75       */
76      private int windowSize = 3;
77  
78      private LDAP ldap;
79  
80      @Override
81      public String getFriendlyName() {
82          return "Google Authenticator";
83      }
84  
85      public String getIssuer() {
86          return issuer;
87      }
88  
89      public void setIssuer(final String issuer) {
90          this.issuer = issuer;
91      }
92  
93      public String getLabel() {
94          return label;
95      }
96  
97      public void setLabel(final String label) {
98          this.label = label;
99      }
100 
101     public int getCodeDigits() {
102         return codeDigits;
103     }
104 
105     public void setCodeDigits(final int codeDigits) {
106         this.codeDigits = codeDigits;
107     }
108 
109     public long getTimeStepSize() {
110         return timeStepSize;
111     }
112 
113     public void setTimeStepSize(final long timeStepSize) {
114         this.timeStepSize = timeStepSize;
115     }
116 
117     public int getWindowSize() {
118         return windowSize;
119     }
120 
121     public void setWindowSize(final int windowSize) {
122         this.windowSize = windowSize;
123     }
124 
125     public LDAP getLdap() {
126         return ldap;
127     }
128 
129     public void setLdap(final LDAP ldap) {
130         this.ldap = ldap;
131     }
132 
133     @Override
134     public Map<String, Object> map(final AuthModuleTO authModule, final Mapper mapper) {
135         return mapper.map(authModule, this);
136     }
137 }