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  
20  package org.apache.wss4j.common.saml.bean;
21  
22  import java.time.Instant;
23  
24  /**
25   * Class AuthenticationStatementBean represents the raw data required to create
26   * a SAML v1.1 or v2.0 authentication statement.
27   */
28  public class AuthenticationStatementBean {
29      private SubjectBean subject;
30      private Instant sessionNotOnOrAfter;
31      private Instant authenticationInstant;
32      private String authenticationMethod;
33      private SubjectLocalityBean subjectLocality;
34      private String sessionIndex;
35  
36      /**
37       * Default constructor
38       */
39      public AuthenticationStatementBean() {
40      }
41  
42      /**
43       * Construct a new AuthenticationStatementBean
44       *
45       * @param subject the Subject to set
46       * @param authenticationMethod the Authentication Method to set
47       * @param authenticationInstant the Authentication Instant to set
48       * @param sessionNotOnOrAfter the Session NotOnOrAfter time to set
49       */
50      public AuthenticationStatementBean(
51          SubjectBean subject,
52          String authenticationMethod,
53          Instant authenticationInstant,
54          Instant sessionNotOnOrAfter
55      ) {
56          this.subject = subject;
57          this.authenticationMethod = authenticationMethod;
58          this.authenticationInstant = authenticationInstant;
59          this.sessionNotOnOrAfter = sessionNotOnOrAfter;
60      }
61  
62      /**
63       * Get the Subject
64       * @return the subject
65       */
66      public SubjectBean getSubject() {
67          return subject;
68      }
69  
70      /**
71       * Set the subject
72       * @param subject the SubjectBean instance to set
73       */
74      public void setSubject(SubjectBean subject) {
75          this.subject = subject;
76      }
77  
78      /**
79       * Get the authentication method
80       * @return the authentication method
81       */
82      public String getAuthenticationMethod() {
83          return authenticationMethod;
84      }
85  
86      /**
87       * Set the authentication method
88       * @param authenticationMethod the authentication method
89       */
90      public void setAuthenticationMethod(String authenticationMethod) {
91          this.authenticationMethod = authenticationMethod;
92      }
93  
94      /**
95       * Get the authentication instant
96       * @return the authentication instant
97       */
98      public Instant getAuthenticationInstant() {
99          return authenticationInstant;
100     }
101 
102     /**
103      * Set the authentication instant
104      * @param authenticationInstant the authentication instant
105      */
106     public void setAuthenticationInstant(Instant authenticationInstant) {
107         this.authenticationInstant = authenticationInstant;
108     }
109 
110     /**
111      * Get the sessionNotOnOrAfter
112      * @return the sessionNotOnOrAfter
113      */
114     public Instant getSessionNotOnOrAfter() {
115         return sessionNotOnOrAfter;
116     }
117 
118     /**
119      * Set the sessionNotOnOrAfter
120      * @param sessionNotOnOrAfter the sessionNotOnOrAfter
121      */
122     public void setSessionNotOnOrAfter(Instant sessionNotOnOrAfter) {
123         this.sessionNotOnOrAfter = sessionNotOnOrAfter;
124     }
125 
126     /**
127      * Get Subject Locality.
128      *
129      * @return the subjectLocality
130      */
131     public final SubjectLocalityBean getSubjectLocality() {
132         return subjectLocality;
133     }
134 
135     /**
136      * Set Subject Locality.
137      *
138      * @param subjectLocality the subjectLocality to set
139      */
140     public final void setSubjectLocality(final SubjectLocalityBean subjectLocality) {
141         this.subjectLocality = subjectLocality;
142     }
143 
144     /**
145      * Get the session index.
146      *
147      * @return the sessionIndex
148      */
149     public final String getSessionIndex() {
150         return sessionIndex;
151     }
152 
153     /**
154      * Set the session index.
155      *
156      * @param sessionIndex the sessionIndex to set
157      */
158     public final void setSessionIndex(final String sessionIndex) {
159         this.sessionIndex = sessionIndex;
160     }
161 
162     @Override
163     public boolean equals(Object o) {
164         if (this == o) {
165             return true;
166         }
167         if (!(o instanceof AuthenticationStatementBean)) {
168             return false;
169         }
170 
171         AuthenticationStatementBean that = (AuthenticationStatementBean) o;
172 
173         if (authenticationInstant == null && that.authenticationInstant != null) {
174             return false;
175         } else if (authenticationInstant != null
176             && !authenticationInstant.equals(that.authenticationInstant)) {
177             return false;
178         }
179 
180         if (sessionNotOnOrAfter == null && that.sessionNotOnOrAfter != null) {
181             return false;
182         } else if (sessionNotOnOrAfter != null
183             && !sessionNotOnOrAfter.equals(that.sessionNotOnOrAfter)) {
184             return false;
185         }
186 
187         if (authenticationMethod == null && that.authenticationMethod != null) {
188             return false;
189         } else if (authenticationMethod != null
190             && !authenticationMethod.equals(that.authenticationMethod)) {
191             return false;
192         }
193 
194         if (subject == null && that.subject != null) {
195             return false;
196         } else if (subject != null
197             && !subject.equals(that.subject)) {
198             return false;
199         }
200 
201         if (subjectLocality == null && that.subjectLocality != null) {
202             return false;
203         } else if (subjectLocality != null && !subjectLocality.equals(that.subjectLocality)) {
204             return false;
205         }
206 
207         if (sessionIndex == null && that.sessionIndex != null) {
208             return false;
209         } else if (sessionIndex != null && !sessionIndex.equals(that.sessionIndex)) {
210             return false;
211         }
212 
213         return true;
214     }
215 
216     @Override
217     public int hashCode() {
218         int result = subject != null ? subject.hashCode() : 0;
219         result = 31 * result + (authenticationInstant != null ? authenticationInstant.hashCode() : 0);
220         result = 31 * result + (sessionNotOnOrAfter != null ? sessionNotOnOrAfter.hashCode() : 0);
221         result = 31 * result + (authenticationMethod != null ? authenticationMethod.hashCode() : 0);
222         result = 31 * result + (subjectLocality != null ? subjectLocality.hashCode() : 0);
223         result = 31 * result + (sessionIndex != null ? sessionIndex.hashCode() : 0);
224         return result;
225     }
226 }