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.Date;
24  
25  /**
26   * Class DelegateBean represents a SAML 2.0 Delegate object. Only NameIDs are supported for now, not
27   * BaseID or EncryptedIDs.
28   *
29   * See:
30   * http://docs.oasis-open.org/security/saml/Post2.0/sstc-saml-delegation-cs-01.pdf
31   */
32  public class DelegateBean {
33      private Instant delegationInstant;
34      private String confirmationMethod;
35      private NameIDBean nameIDBean;
36  
37      public Instant getDelegationInstant() {
38          return delegationInstant;
39      }
40  
41      public void setDelegationInstant(Instant delegationInstant) {
42          if (delegationInstant != null) {
43              this.delegationInstant = Date.from(delegationInstant).toInstant();
44          } else {
45              this.delegationInstant = null;
46          }
47      }
48  
49      public String getConfirmationMethod() {
50          return confirmationMethod;
51      }
52  
53      public void setConfirmationMethod(String confirmationMethod) {
54          this.confirmationMethod = confirmationMethod;
55      }
56  
57      public NameIDBean getNameIDBean() {
58          return nameIDBean;
59      }
60  
61      public void setNameIDBean(NameIDBean nameIDBean) {
62          this.nameIDBean = nameIDBean;
63      }
64  
65      /**
66       * Method equals ...
67       *
68       * @param o of type Object
69       * @return boolean
70       */
71      @Override
72      public boolean equals(Object o) {
73          if (this == o) {
74              return true;
75          }
76          if (!(o instanceof DelegateBean)) {
77              return false;
78          }
79  
80          DelegateBean that = (DelegateBean) o;
81  
82          if (delegationInstant == null && that.delegationInstant != null) {
83              return false;
84          } else if (delegationInstant != null && !delegationInstant.equals(that.delegationInstant)) {
85              return false;
86          }
87  
88          if (confirmationMethod == null && that.confirmationMethod != null) {
89              return false;
90          } else if (confirmationMethod != null && !confirmationMethod.equals(that.confirmationMethod)) {
91              return false;
92          }
93  
94          if (nameIDBean == null && that.nameIDBean != null) {
95              return false;
96          } else if (nameIDBean != null && !nameIDBean.equals(that.nameIDBean)) {
97              return false;
98          }
99  
100         return true;
101     }
102 
103     /**
104      * @return the hashcode of this object
105      */
106     @Override
107     public int hashCode() {
108         int result = 0;
109         if (delegationInstant != null) {
110             result = 31 * result + delegationInstant.hashCode();
111         }
112         if (confirmationMethod != null) {
113             result = 31 * result + confirmationMethod.hashCode();
114         }
115         if (nameIDBean != null) {
116             result = 31 * result + nameIDBean.hashCode();
117         }
118         return result;
119     }
120 
121 }