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.wa;
20  
21  import java.time.LocalDateTime;
22  import org.apache.commons.lang3.builder.EqualsBuilder;
23  import org.apache.commons.lang3.builder.HashCodeBuilder;
24  import org.apache.commons.lang3.builder.ToStringBuilder;
25  import org.apache.syncope.common.lib.BaseBean;
26  
27  public class GoogleMfaAuthToken implements BaseBean {
28  
29      private static final long serialVersionUID = 2185073386484048953L;
30  
31      public static class Builder {
32  
33          private final GoogleMfaAuthToken instance = new GoogleMfaAuthToken();
34  
35          public GoogleMfaAuthToken.Builder issueDate(final LocalDateTime issueDate) {
36              instance.setIssueDate(issueDate);
37              return this;
38          }
39  
40          public GoogleMfaAuthToken.Builder token(final int otp) {
41              instance.setOtp(otp);
42              return this;
43          }
44  
45          public GoogleMfaAuthToken build() {
46              return instance;
47          }
48      }
49  
50      private int otp;
51  
52      private LocalDateTime issueDate;
53  
54      public int getOtp() {
55          return otp;
56      }
57  
58      public void setOtp(final int otp) {
59          this.otp = otp;
60      }
61  
62      public LocalDateTime getIssueDate() {
63          return issueDate;
64      }
65  
66      public void setIssueDate(final LocalDateTime issueDate) {
67          this.issueDate = issueDate;
68      }
69  
70      @Override
71      public int hashCode() {
72          return new HashCodeBuilder()
73                  .append(otp)
74                  .append(issueDate)
75                  .toHashCode();
76      }
77  
78      @Override
79      public boolean equals(final Object obj) {
80          if (obj == null) {
81              return false;
82          }
83          if (obj == this) {
84              return true;
85          }
86          if (obj.getClass() != getClass()) {
87              return false;
88          }
89          GoogleMfaAuthToken other = (GoogleMfaAuthToken) obj;
90          return new EqualsBuilder()
91                  .append(this.otp, other.otp)
92                  .append(this.issueDate, other.issueDate)
93                  .isEquals();
94      }
95  
96      @Override
97      public String toString() {
98          return new ToStringBuilder(this)
99                  .append("token", otp)
100                 .append("issueDate", issueDate)
101                 .toString();
102     }
103 }