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.time.Instant;
23  import java.util.ArrayList;
24  import java.util.Date;
25  import java.util.List;
26  
27  /**
28   * Class SubjectConfirmationDataBean represents a SAML (2) SubjectConfirmationData. Please note that
29   * KeyInfo functionality is in SubjectBean for backwards compatibility reasons.
30   */
31  public class SubjectConfirmationDataBean {
32      private String recipient;
33      private String address;
34      private String inResponseTo;
35      private Instant notBefore;
36      private Instant notAfter;
37      private List<Object> any;
38  
39      /**
40       * Constructor SubjectConfirmationDataBean creates a new SubjectConfirmationDataBean instance.
41       */
42      public SubjectConfirmationDataBean() {
43      }
44  
45      /**
46       * Get the recipient of the SubjectConfirmationDataBean
47       * @return the recipient of the SubjectConfirmationDataBean
48       */
49      public String getRecipient() {
50          return recipient;
51      }
52  
53      /**
54       * Set the recipient of the SubjectConfirmationDataBean
55       * @param recipient the recipient of the SubjectConfirmationDataBean
56       */
57      public void setRecipient(String recipient) {
58          this.recipient = recipient;
59      }
60  
61      /**
62       * Get the address of the SubjectConfirmationDataBean
63       * @return the address of the SubjectConfirmationDataBean
64       */
65      public String getAddress() {
66          return address;
67      }
68  
69      /**
70       * Set the address of the SubjectConfirmationDataBean
71       * @param address the address of the SubjectConfirmationDataBean
72       */
73      public void setAddress(String address) {
74          this.address = address;
75      }
76  
77      /**
78       * Get the InResponseTo element of the SubjectConfirmationDataBean
79       * @return the InResponseTo element of the SubjectConfirmationDataBean
80       */
81      public String getInResponseTo() {
82          return inResponseTo;
83      }
84  
85      /**
86       * Set the InResponseTo element of the SubjectConfirmationDataBean
87       * @param inResponseTo the InResponseTo element of the SubjectConfirmationDataBean
88       */
89      public void setInResponseTo(String inResponseTo) {
90          this.inResponseTo = inResponseTo;
91      }
92  
93      /**
94       * Get the NotBefore time of the SubjectConfirmationDataBean
95       * @return the NotBefore time of the SubjectConfirmationDataBean
96       */
97      public Instant getNotBefore() {
98          return notBefore;
99      }
100 
101     /**
102      * Set the notBefore instance
103      *
104      * @param notBefore the notBefore instance to set
105      */
106     public void setNotBefore(Instant notBefore) {
107         if (notBefore != null) {
108             this.notBefore = Date.from(notBefore).toInstant();
109         } else {
110             this.notBefore = null;
111         }
112     }
113 
114     /**
115      * Get the NotOnOrAfter time of the SubjectConfirmationDataBean
116      * @return the NotOnOrAfter time of the SubjectConfirmationDataBean
117      */
118     public Instant getNotAfter() {
119         return notAfter;
120     }
121 
122     /**
123      * Set the notAfter instance
124      *
125      * @param notAfter the notAfter instance to set
126      */
127     public void setNotAfter(Instant notAfter) {
128         if (notAfter != null) {
129             this.notAfter = Date.from(notAfter).toInstant();
130         } else {
131             this.notAfter = null;
132         }
133     }
134 
135     /**
136      * Get the list of additional elements
137      *
138      * @return list of additional elements
139      */
140     public List<Object> getAny() {
141         return any;
142     }
143 
144     /**
145      * Set the list of additional elements
146      *
147      * @param any the list of additional elements
148      */
149     public void setAny(List<Object> any) {
150         this.any = any;
151     }
152 
153     /**
154      * Adds an additional element
155      *
156      * @param obj additional element
157      */
158     public void addAny(Object obj) {
159         if (any == null) {
160             any = new ArrayList<>();
161         }
162         any.add(obj);
163     }
164 
165     /**
166      * Method equals ...
167      *
168      * @param o of type Object
169      * @return boolean
170      */
171     @Override
172     public boolean equals(Object o) {
173         if (this == o) {
174             return true;
175         }
176         if (!(o instanceof SubjectConfirmationDataBean)) {
177             return false;
178         }
179 
180         SubjectConfirmationDataBean that = (SubjectConfirmationDataBean) o;
181 
182         if (recipient == null && that.recipient != null) {
183             return false;
184         } else if (recipient != null && !recipient.equals(that.recipient)) {
185             return false;
186         }
187 
188         if (address == null && that.address != null) {
189             return false;
190         } else if (address != null && !address.equals(that.address)) {
191             return false;
192         }
193 
194         if (inResponseTo == null && that.inResponseTo != null) {
195             return false;
196         } else if (inResponseTo != null && !inResponseTo.equals(that.inResponseTo)) {
197             return false;
198         }
199 
200         if (notBefore == null && that.notBefore != null) {
201             return false;
202         } else if (notBefore != null && !notBefore.equals(that.notBefore)) {
203             return false;
204         }
205 
206         if (notAfter == null && that.notAfter != null) {
207             return false;
208         } else if (notAfter != null && !notAfter.equals(that.notAfter)) {
209             return false;
210         }
211 
212         if (any == null && that.any != null) {
213             return false;
214         } else if (any != null && !any.equals(that.any)) {
215             return false;
216         }
217 
218         return true;
219     }
220 
221     /**
222      * @return the hashcode of this object
223      */
224     @Override
225     public int hashCode() {
226         int result = 0;
227         if (recipient != null) {
228             result = recipient.hashCode();
229         }
230         if (address != null) {
231             result = 31 * result + address.hashCode();
232         }
233         if (inResponseTo != null) {
234             result = 31 * result + inResponseTo.hashCode();
235         }
236         if (notBefore != null) {
237             result = 31 * result + notBefore.hashCode();
238         }
239         if (notAfter != null) {
240             result = 31 * result + notAfter.hashCode();
241         }
242         if (any != null) {
243             result = 31 * result + any.hashCode();
244         }
245         return result;
246     }
247 
248 }