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.apache.ws.security.saml.ext.builder.SAML1Constants;
23  
24  /**
25   * Class SubjectBean represents a SAML subject (can be used to create
26   * both SAML v1.1 and v2.0 statements)
27   *
28   * Created on May 20, 2009
29   */
30  public class SubjectBean {
31      private String subjectName;
32      private String subjectNameIDFormat = SAML1Constants.NAMEID_FORMAT_UNSPECIFIED;
33      private String subjectNameQualifier;
34      private String subjectConfirmationMethod;
35      private KeyInfoBean keyInfo;
36      private SubjectConfirmationDataBean subjectConfirmationData;
37  
38      /**
39       * Constructor SubjectBean creates a new SubjectBean instance.
40       */
41      public SubjectBean() {
42      }
43  
44      /**
45       * Constructor SubjectBean creates a new SubjectBean instance.
46       *
47       * @param subjectName of type String
48       * @param subjectNameQualifier of type String
49       * @param subjectConfirmationMethod of type String
50       */
51      public SubjectBean(
52          String subjectName, 
53          String subjectNameQualifier, 
54          String subjectConfirmationMethod
55      ) {
56          this.subjectName = subjectName;
57          this.subjectNameQualifier = subjectNameQualifier;
58          this.subjectConfirmationMethod = subjectConfirmationMethod;
59      }
60      
61      /**
62       * Constructor SubjectBean creates a new SubjectBean instance.
63       *
64       * @param subjectName of type String
65       * @param subjectNameQualifier of type String
66       * @param subjectConfirmationMethod of type String
67       * @param subjectNameIDFormat of type String
68       */
69      public SubjectBean(
70          String subjectName, 
71          String subjectNameQualifier, 
72          String subjectConfirmationMethod,
73          String subjectNameIDFormat
74      ) {
75          this(subjectName, subjectNameQualifier, subjectConfirmationMethod);
76          this.subjectNameIDFormat = subjectNameIDFormat;
77      }
78  
79      /**
80       * Method getSubjectName returns the subjectName of this SubjectBean object.
81       *
82       * @return the subjectName (type String) of this SubjectBean object.
83       */
84      public String getSubjectName() {
85          return subjectName;
86      }
87  
88      /**
89       * Method setSubjectName sets the subjectName of this SubjectBean object.
90       *
91       * @param subjectName the subjectName of this SubjectBean object.
92       */
93      public void setSubjectName(String subjectName) {
94          this.subjectName = subjectName;
95      }
96      
97      /**
98       * Method getSubjectNameQualifier returns the subjectNameQualifier of this SubjectBean object.
99       *
100      * @return the subjectNameQualifier (type String) of this SubjectBean object.
101      */
102     public String getSubjectNameQualifier() {
103         return subjectNameQualifier;
104     }
105 
106     /**
107      * Method setSubjectNameQualifier sets the subjectNameQualifier of this SubjectBean object.
108      *
109      * @param subjectNameQualifier the subjectNameQualifier of this SubjectBean object.
110      */
111     public void setSubjectNameQualifier(String subjectNameQualifier) {
112         this.subjectNameQualifier = subjectNameQualifier;
113     }
114     
115     /**
116      * Method getSubjectConfirmationMethod returns the subjectConfirmationMethod of
117      * this SubjectBean object.
118      *
119      * @return the subjectConfirmationMethod (type String) of this SubjectBean object.
120      */
121     public String getSubjectConfirmationMethod() {
122         return subjectConfirmationMethod;
123     }
124 
125     /**
126      * Method setSubjectConfirmationMethod sets the subjectConfirmationMethod of
127      * this SubjectBean object.
128      *
129      * @param subjectConfirmationMethod the subjectConfirmationMethod of this 
130      *        SubjectBean object.
131      */
132     public void setSubjectConfirmationMethod(String subjectConfirmationMethod) {
133         this.subjectConfirmationMethod = subjectConfirmationMethod;
134     }
135     
136     /**
137      * Method getSubjectNameIDFormat returns the subjectNameIDFormat of this SubjectBean 
138      * object.
139      *
140      * @return the subjectNameIDFormat (type String) of this SubjectBean object.
141      */
142     public String getSubjectNameIDFormat() {
143         return subjectNameIDFormat;
144     }
145 
146     /**
147      * Method setSubjectNameIDFormat sets the subjectNameIDFormat of this SubjectBean 
148      * object.
149      *
150      * @param subjectNameIDFormat the subjectNameIDFormat of this SubjectBean object.
151      */
152     public void setSubjectNameIDFormat(String subjectNameIDFormat) {
153         this.subjectNameIDFormat = subjectNameIDFormat;
154     }
155     
156     /**
157      * Method getKeyInfo returns the keyInfo of this SubjectBean object.
158      *
159      * @return the keyInfo (type KeyInfoBean) of this SubjectBean object.
160      */
161     public KeyInfoBean getKeyInfo() {
162         return keyInfo;
163     }
164 
165     /**
166      * Method setKeyInfo sets the keyInfo of this SubjectBean object.
167      *
168      * @param keyInfo the keyInfo of this SubjectBean object.
169      */
170     public void setKeyInfo(KeyInfoBean keyInfo) {
171         this.keyInfo = keyInfo;
172     }
173     
174     /**
175      * Set the SubjectConfirmationData of this SubjectBean object
176      * @return the SubjectConfirmationData of this SubjectBean object
177      */
178     public SubjectConfirmationDataBean getSubjectConfirmationData() {
179         return subjectConfirmationData;
180     }
181 
182     /**
183      * Get the SubjectConfirmationData of this SubjectBean object
184      * @param subjectConfirmationData the SubjectConfirmationData of this SubjectBean object
185      */
186     public void setSubjectConfirmationData(
187         SubjectConfirmationDataBean subjectConfirmationData
188     ) {
189         this.subjectConfirmationData = subjectConfirmationData;
190     }
191     
192     /**
193      * Method equals ...
194      *
195      * @param o of type Object
196      * @return boolean
197      */
198     @Override
199     public boolean equals(Object o) {
200         if (this == o) return true;
201         if (!(o instanceof SubjectBean)) return false;
202 
203         SubjectBean that = (SubjectBean) o;
204 
205         if (subjectName == null && that.subjectName != null) {
206             return false;
207         } else if (subjectName != null && !subjectName.equals(that.subjectName)) {
208             return false;
209         }
210         
211         if (subjectNameQualifier == null && that.subjectNameQualifier != null) {
212             return false;
213         } else if (subjectNameQualifier != null && 
214             !subjectNameQualifier.equals(that.subjectNameQualifier)) {
215             return false;
216         }
217         
218         if (subjectConfirmationMethod == null && that.subjectConfirmationMethod != null) {
219             return false;
220         } else if (subjectConfirmationMethod != null && 
221             !subjectConfirmationMethod.equals(that.subjectConfirmationMethod)) {
222             return false;
223         }
224         
225         if (subjectNameIDFormat == null && that.subjectNameIDFormat != null) {
226             return false;
227         } else if (subjectNameIDFormat != null 
228             && !subjectNameIDFormat.equals(that.subjectNameIDFormat)) {
229             return false;
230         }
231         
232         if (keyInfo == null && that.keyInfo != null) {
233             return false;
234         } else if (keyInfo != null && !keyInfo.equals(that.keyInfo)) {
235             return false;
236         }
237         
238         if (subjectConfirmationData == null && that.subjectConfirmationData != null) {
239             return false;
240         } else if (subjectConfirmationData != null 
241             && !subjectConfirmationData.equals(that.subjectConfirmationData)) {
242             return false;
243         }
244 
245         return true;
246     }
247 
248     /**
249      * @return the hashcode of this object
250      */
251     @Override
252     public int hashCode() {
253         int result = 0;
254         if (subjectName != null) {
255             result = subjectName.hashCode();
256         }
257         if (subjectNameQualifier != null) {
258             result = 31 * result + subjectNameQualifier.hashCode();
259         }
260         if (subjectConfirmationMethod != null) {
261             result = 31 * result + subjectConfirmationMethod.hashCode();
262         }
263         if (subjectNameIDFormat != null) {
264             result = 31 * result + subjectNameIDFormat.hashCode();
265         }
266         if (keyInfo != null) {
267             result = 31 * result + keyInfo.hashCode();
268         }
269         if (subjectConfirmationData != null) {
270             result = 31 * result + subjectConfirmationData.hashCode();
271         }
272         return result;
273     }
274 
275 }