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