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  /**
23   * Class NameIDBean represents a SAML NameID (can be used to create both SAML v1.1 and v2.0 statements)
24   */
25  public class NameIDBean {
26      private String nameValue;
27      private String nameIDFormat = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified";
28      private String nameQualifier;
29      private String spNameQualifier;
30      private String spProvidedID;
31  
32      /**
33       * Constructor NameIDBean creates a new NameIDBean instance.
34       */
35      public NameIDBean() {
36      }
37  
38      /**
39       * Constructor NameIDBean creates a new NameIDBean instance.
40       *
41       * @param nameValue of type String
42       * @param nameQualifier of type String
43       */
44      public NameIDBean(
45          String nameValue,
46          String nameQualifier,
47          String nameIDFormat
48      ) {
49          this.setNameValue(nameValue);
50          this.setNameQualifier(nameQualifier);
51          this.setNameIDFormat(nameIDFormat);
52      }
53  
54      public String getNameValue() {
55          return nameValue;
56      }
57  
58      public void setNameValue(String nameValue) {
59          this.nameValue = nameValue;
60      }
61  
62      public String getNameIDFormat() {
63          return nameIDFormat;
64      }
65  
66      public void setNameIDFormat(String nameIDFormat) {
67          this.nameIDFormat = nameIDFormat;
68      }
69  
70      public String getNameQualifier() {
71          return nameQualifier;
72      }
73  
74      public void setNameQualifier(String nameQualifier) {
75          this.nameQualifier = nameQualifier;
76      }
77  
78      public String getSPNameQualifier() {
79          return spNameQualifier;
80      }
81  
82      public void setSPNameQualifier(String spNameQualifier) {
83          this.spNameQualifier = spNameQualifier;
84      }
85  
86      public String getSPProvidedID() {
87          return spProvidedID;
88      }
89  
90      public void setSPProvidedID(String spProvidedID) {
91          this.spProvidedID = spProvidedID;
92      }
93  
94      /**
95       * Method equals ...
96       *
97       * @param o of type Object
98       * @return boolean
99       */
100     @Override
101     public boolean equals(Object o) {
102         if (this == o) {
103             return true;
104         }
105         if (!(o instanceof NameIDBean)) {
106             return false;
107         }
108 
109         NameIDBean that = (NameIDBean) o;
110 
111         if (nameValue == null && that.nameValue != null) {
112             return false;
113         } else if (nameValue != null && !nameValue.equals(that.nameValue)) {
114             return false;
115         }
116 
117         if (nameIDFormat == null && that.nameIDFormat != null) {
118             return false;
119         } else if (nameIDFormat != null && !nameIDFormat.equals(that.nameIDFormat)) {
120             return false;
121         }
122 
123         if (nameQualifier == null && that.nameQualifier != null) {
124             return false;
125         } else if (nameQualifier != null && !nameQualifier.equals(that.nameQualifier)) {
126             return false;
127         }
128 
129         if (spNameQualifier == null && that.spNameQualifier != null) {
130             return false;
131         } else if (spNameQualifier != null && !spNameQualifier.equals(that.spNameQualifier)) {
132             return false;
133         }
134 
135         if (spProvidedID == null && that.spProvidedID != null) {
136             return false;
137         } else if (spProvidedID != null && !spProvidedID.equals(that.spProvidedID)) {
138             return false;
139         }
140 
141         return true;
142     }
143 
144     /**
145      * @return the hashcode of this object
146      */
147     @Override
148     public int hashCode() {
149         int result = 0;
150         if (nameValue != null) {
151             result = nameValue.hashCode();
152         }
153         if (nameIDFormat != null) {
154             result = 31 * result + nameIDFormat.hashCode();
155         }
156         if (nameQualifier != null) {
157             result = 31 * result + nameQualifier.hashCode();
158         }
159         if (spNameQualifier != null) {
160             result = 31 * result + spNameQualifier.hashCode();
161         }
162         if (spProvidedID != null) {
163             result = 31 * result + spProvidedID.hashCode();
164         }
165         return result;
166     }
167 
168 }