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 java.util.List;
23 import java.util.ArrayList;
24
25 /**
26 * Class SamlAttribute represents an instance of a SAML attribute.
27 * <p/>
28 * Created on May 18, 2009
29 */
30 public class AttributeBean {
31 private String simpleName;
32 private String qualifiedName;
33 private String nameFormat;
34 private List<String> attributeValues;
35 private List<?> customAttributeValues;
36
37 /**
38 * Constructor SamlAttribute creates a new SamlAttribute instance.
39 */
40 public AttributeBean() {
41 attributeValues = new ArrayList<String>();
42 }
43
44 /**
45 * Constructor SamlAttribute creates a new SamlAttribute instance.
46 *
47 * @param simpleName of type String
48 * @param qualifiedName of type String
49 * @param attributeValues of type List<String>
50 */
51 public AttributeBean(String simpleName, String qualifiedName, List<String> attributeValues) {
52 this.simpleName = simpleName;
53 this.qualifiedName = qualifiedName;
54 this.attributeValues = attributeValues;
55 }
56
57 /**
58 * Method getSimpleName returns the simpleName of this SamlAttribute object.
59 *
60 * @return the simpleName (type String) of this SamlAttribute object.
61 */
62 public String getSimpleName() {
63 return simpleName;
64 }
65
66 /**
67 * Method setSimpleName sets the simpleName of this SamlAttribute object.
68 *
69 * @param simpleName the simpleName of this SamlAttribute object.
70 */
71 public void setSimpleName(String simpleName) {
72 this.simpleName = simpleName;
73 }
74
75 /**
76 * Method getNameFormat returns the nameFormat of this SamlAttribute object
77 *
78 * @return he nameFormat of this SamlAttribute object
79 */
80 public String getNameFormat() {
81 return nameFormat;
82 }
83
84 /**
85 * Method setNameFormat sets the nameFormat of this SamlAttribute object.
86 *
87 * @param nameFormat the nameFormat of this SamlAttribute object.
88 */
89 public void setNameFormat(String nameFormat) {
90 this.nameFormat = nameFormat;
91 }
92
93 /**
94 * Method getQualifiedName returns the qualifiedName of this SamlAttribute object.
95 *
96 * @return the qualifiedName (type String) of this SamlAttribute object.
97 */
98 public String getQualifiedName() {
99 return qualifiedName;
100 }
101
102 /**
103 * Method setQualifiedName sets the qualifiedName of this SamlAttribute object.
104 *
105 * @param qualifiedName the qualifiedName of this SamlAttribute object.
106 */
107 public void setQualifiedName(String qualifiedName) {
108 this.qualifiedName = qualifiedName;
109 }
110
111 /**
112 * Method getAttributeValues returns the attributeValues of this SamlAttribute object.
113 *
114 * @return the attributeValues (type List) of this SamlAttribute object.
115 */
116 public List<String> getAttributeValues() {
117 return attributeValues;
118 }
119
120 /**
121 * Method setAttributeValues sets the attributeValues of this SamlAttribute object.
122 *
123 * @param attributeValues the attributeValues of this SamlAttribute object.
124 */
125 public void setAttributeValues(List<String> attributeValues) {
126 this.attributeValues = attributeValues;
127 }
128
129 /**
130 * Method setCustomAttributeValues sets the attributeValues of this SamlAttribute object.
131 * This method allows the user to specify OpenSAML XMLObject attributes.
132 *
133 * @param customAttributeValues the attributeValues of this SamlAttribute object.
134 */
135 public void setCustomAttributeValues(List<?> customAttributeValues) {
136 this.customAttributeValues = customAttributeValues;
137 }
138
139 /**
140 * Method getCustomAttributeValues returns the attributeValues of this SamlAttribute object.
141 *
142 * @return the attributeValues (type List) of this SamlAttribute object.
143 */
144 public List<?> getCustomAttributeValues() {
145 return customAttributeValues;
146 }
147
148 @Override
149 public boolean equals(Object o) {
150 if (this == o) return true;
151 if (!(o instanceof AttributeBean)) return false;
152
153 AttributeBean that = (AttributeBean) o;
154
155 if (attributeValues == null && that.attributeValues != null) {
156 return false;
157 } else if (attributeValues != null && !attributeValues.equals(that.attributeValues)) {
158 return false;
159 }
160
161 if (customAttributeValues == null && that.customAttributeValues != null) {
162 return false;
163 } else if (customAttributeValues != null
164 && !customAttributeValues.equals(that.customAttributeValues)) {
165 return false;
166 }
167
168 if (qualifiedName == null && that.qualifiedName != null) {
169 return false;
170 } else if (qualifiedName != null && !qualifiedName.equals(that.qualifiedName)) {
171 return false;
172 }
173
174 if (nameFormat == null && that.nameFormat != null) {
175 return false;
176 } else if (nameFormat != null && !nameFormat.equals(that.nameFormat)) {
177 return false;
178 }
179
180 if (simpleName == null && that.simpleName != null) {
181 return false;
182 } else if (simpleName != null && !simpleName.equals(that.simpleName)) {
183 return false;
184 }
185
186 return true;
187 }
188
189 @Override
190 public int hashCode() {
191 int result = 0;
192 if (simpleName != null) {
193 result = 31 * result + simpleName.hashCode();
194 }
195 if (qualifiedName != null) {
196 result = 31 * result + qualifiedName.hashCode();
197 }
198 if (nameFormat != null) {
199 result = 31 * result + nameFormat.hashCode();
200 }
201 if (attributeValues != null) {
202 result = 31 * result + attributeValues.hashCode();
203 }
204 if (customAttributeValues != null) {
205 result = 31 * result + customAttributeValues.hashCode();
206 }
207 return result;
208 }
209 }