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 org.joda.time.DateTime;
23  
24  
25  /**
26   * Class ConditionsBean represents a SAML Conditions object (can be used to create
27   * both SAML v1.1 and v2.0 statements)
28   *
29   * Created on May 20, 2009
30   */
31  public class ConditionsBean {
32      private DateTime notBefore;
33      private DateTime notAfter;
34      private int tokenPeriodMinutes;
35      private String audienceURI;
36  
37      /**
38       * Constructor ConditionsBean creates a new ConditionsBean instance.
39       */
40      public ConditionsBean() {
41      }
42  
43      /**
44       * Constructor ConditionsBean creates a new ConditionsBean instance.
45       *
46       * @param notBefore The notBefore instance
47       * @param notAfter The notAfter instance
48       */
49      public ConditionsBean(
50          DateTime notBefore, 
51          DateTime notAfter
52      ) {
53          this.notBefore = notBefore;
54          this.notAfter = notAfter;
55      }
56      
57      /**
58       * Constructor ConditionsBean creates a new ConditionsBean instance.
59       *
60       * @param tokenPeriodMinutes how long the token is valid for in minutes
61       */
62      public ConditionsBean(
63          int tokenPeriodMinutes
64      ) {
65          this.tokenPeriodMinutes = tokenPeriodMinutes;
66      }
67      
68      /**
69       * Get the notBefore instance
70       *
71       * @return the notBefore instance
72       */
73      public DateTime getNotBefore() {
74          return notBefore;
75      }
76  
77      /**
78       * Set the notBefore instance
79       *
80       * @param notBefore the notBefore instance to set
81       */
82      public void setNotBefore(DateTime notBefore) {
83          this.notBefore = notBefore;
84      }
85      
86      /**
87       * Get the notAfter instance
88       *
89       * @return the notAfter instance
90       */
91      public DateTime getNotAfter() {
92          return notAfter;
93      }
94  
95      /**
96       * Set the notAfter instance
97       *
98       * @param notAfter the notAfter instance to set
99       */
100     public void setNotAfter(DateTime notAfter) {
101         this.notAfter = notAfter;
102     }
103     
104     /**
105      * Get the tokenPeriodMinutes of this object.
106      *
107      * @return the tokenPeriodMinutes (type int)
108      */
109     public int getTokenPeriodMinutes() {
110         return tokenPeriodMinutes;
111     }
112 
113     /**
114      * Set the tokenPeriodMinutes.
115      *
116      * @param tokenPeriodMinutes the tokenPeriodMinutes to set
117      */
118     public void setTokenPeriodMinutes(int tokenPeriodMinutes) {
119         this.tokenPeriodMinutes = tokenPeriodMinutes;
120     }
121     
122     /**
123      * Get the audienceURI instance
124      *
125      * @return the audienceURI instance
126      */
127     public String getAudienceURI() {
128         return audienceURI;
129     }
130 
131     /**
132      * Set the audienceURI instance
133      *
134      * @param audienceURI the audienceURI instance to set
135      */
136     public void setAudienceURI(String audienceURI) {
137         this.audienceURI = audienceURI;
138     }
139 
140     /**
141      * Method equals ...
142      *
143      * @param o of type Object
144      * @return boolean
145      */
146     @Override
147     public boolean equals(Object o) {
148         if (this == o) return true;
149         if (!(o instanceof ConditionsBean)) return false;
150 
151         ConditionsBean that = (ConditionsBean) o;
152 
153         if (tokenPeriodMinutes != that.tokenPeriodMinutes) return false;
154         
155         if (notBefore == null && that.notBefore != null) {
156             return false;
157         } else if (notBefore != null && !notBefore.equals(that.notBefore)) {
158             return false;
159         }
160         
161         if (notAfter == null && that.notAfter != null) {
162             return false;
163         } else if (notAfter != null && !notAfter.equals(that.notAfter)) {
164             return false; 
165         }
166         
167         if (audienceURI == null && that.audienceURI != null) {
168             return false;
169         } else if (audienceURI != null && !audienceURI.equals(that.audienceURI)) {
170             return false; 
171         }
172 
173         return true;
174     }
175 
176     /**
177      * @return the hashcode of this object
178      */
179     @Override
180     public int hashCode() {
181         int result = tokenPeriodMinutes;
182         if (notBefore != null) {
183             result = 31 * result + notBefore.hashCode();
184         }
185         if (notAfter != null) {
186             result = 31 * result + notAfter.hashCode();
187         }
188         if (audienceURI != null) {
189             result = 31 * result + audienceURI.hashCode();
190         }
191         return result;
192     }
193 }