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