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.util.List;
23  import java.util.ArrayList;
24  
25  
26  /**
27   * Class SamlAttributeStatement represents a SAML attribute statement
28   */
29  public class AttributeStatementBean {
30      private SubjectBean subject;
31      private List<AttributeBean> attributeBeans;
32  
33      /**
34       * Constructor SamlAttributeStatement creates a new SamlAttributeStatement instance.
35       */
36      public AttributeStatementBean() {
37          attributeBeans = new ArrayList<>();
38      }
39  
40      /**
41       * Constructor SamlAttributeStatement creates a new SamlAttributeStatement instance.
42       * @param subject A new SubjectBean instance
43       * @param attributeBeans A list of Attributes
44       */
45      public AttributeStatementBean(
46          SubjectBean subject,
47          List<AttributeBean> attributeBeans
48      ) {
49          this.subject = subject;
50          this.attributeBeans = attributeBeans;
51      }
52  
53      /**
54       * Method getSamlAttributes returns the samlAttributes of this SamlAttributeStatement object.
55       *
56       * @return the samlAttributes (type List<SamlAttribute>) of this SamlAttributeStatement object.
57       */
58      public List<AttributeBean> getSamlAttributes() {
59          return attributeBeans;
60      }
61  
62      /**
63       * Method setSamlAttributes sets the samlAttributes of this SamlAttributeStatement object.
64       *
65       * @param attributeBeans the samlAttributes of this SamlAttributeStatement object.
66       *
67       */
68      public void setSamlAttributes(List<AttributeBean> attributeBeans) {
69          this.attributeBeans = attributeBeans;
70      }
71  
72      /**
73       * Get the Subject
74       * @return the Subject
75       */
76      public SubjectBean getSubject() {
77          return subject;
78      }
79  
80      /**
81       * Set the Subject
82       * @param subject the SubjectBean instance to set
83       */
84      public void setSubject(SubjectBean subject) {
85          this.subject = subject;
86      }
87  
88      @Override
89      public boolean equals(Object o) {
90          if (this == o) {
91              return true;
92          }
93          if (!(o instanceof AttributeStatementBean)) {
94              return false;
95          }
96  
97          AttributeStatementBean that = (AttributeStatementBean) o;
98  
99          if (attributeBeans == null && that.attributeBeans != null) {
100             return false;
101         } else if (attributeBeans != null && !attributeBeans.equals(that.attributeBeans)) {
102             return false;
103         }
104 
105         if (subject == null && that.subject != null) {
106             return false;
107         } else if (subject != null && !subject.equals(that.subject)) {
108             return false;
109         }
110 
111         return true;
112     }
113 
114     @Override
115     public int hashCode() {
116         int result = subject != null ? subject.hashCode() : 0;
117         result = 31 * result + (attributeBeans != null ? attributeBeans.hashCode() : 0);
118         return result;
119     }
120 }