1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.wss4j.common.saml.bean;
21
22 import java.time.Instant;
23 import java.util.Date;
24 import java.util.List;
25
26
27
28
29
30 public class ConditionsBean {
31 private Instant notBefore;
32 private Instant notAfter;
33 private long tokenPeriodSeconds;
34 private List<AudienceRestrictionBean> audienceRestrictions;
35 private boolean oneTimeUse;
36 private ProxyRestrictionBean proxyRestriction;
37 private List<DelegateBean> delegates;
38
39
40
41
42 public ConditionsBean() {
43 }
44
45
46
47
48
49
50
51 public ConditionsBean(
52 Instant notBefore,
53 Instant notAfter
54 ) {
55 if (notBefore != null) {
56 this.notBefore = Date.from(notBefore).toInstant();
57 }
58 if (notAfter != null) {
59 this.notAfter = Date.from(notAfter).toInstant();
60 }
61 }
62
63
64
65
66
67
68 public ConditionsBean(
69 int tokenPeriodMinutes
70 ) {
71 this.tokenPeriodSeconds = tokenPeriodMinutes * 60L;
72 }
73
74
75
76
77
78
79 public Instant getNotBefore() {
80 return notBefore;
81 }
82
83
84
85
86
87
88 public void setNotBefore(Instant notBefore) {
89 if (notBefore != null) {
90 this.notBefore = Date.from(notBefore).toInstant();
91 } else {
92 this.notBefore = null;
93 }
94 }
95
96
97
98
99
100
101 public Instant getNotAfter() {
102 return notAfter;
103 }
104
105
106
107
108
109
110 public void setNotAfter(Instant notAfter) {
111 if (notAfter != null) {
112 this.notAfter = Date.from(notAfter).toInstant();
113 } else {
114 this.notAfter = null;
115 }
116 }
117
118
119
120
121
122
123 public int getTokenPeriodMinutes() {
124 return (int)(tokenPeriodSeconds / 60L);
125 }
126
127
128
129
130
131
132 public void setTokenPeriodMinutes(int tokenPeriodMinutes) {
133 this.tokenPeriodSeconds = tokenPeriodMinutes * 60L;
134 }
135
136
137
138
139
140
141 public long getTokenPeriodSeconds() {
142 return tokenPeriodSeconds;
143 }
144
145
146
147
148
149
150 public void setTokenPeriodSeconds(long tokenPeriodSeconds) {
151 this.tokenPeriodSeconds = tokenPeriodSeconds;
152 }
153
154
155
156
157
158
159 public List<AudienceRestrictionBean> getAudienceRestrictions() {
160 return audienceRestrictions;
161 }
162
163
164
165
166
167
168 public void setAudienceRestrictions(List<AudienceRestrictionBean> audienceRestrictions) {
169 this.audienceRestrictions = audienceRestrictions;
170 }
171
172
173
174
175
176 public boolean isOneTimeUse() {
177 return oneTimeUse;
178 }
179
180
181
182
183
184 public void setOneTimeUse(boolean oneTimeUse) {
185 this.oneTimeUse = oneTimeUse;
186 }
187
188 public ProxyRestrictionBean getProxyRestriction() {
189 return proxyRestriction;
190 }
191
192 public void setProxyRestriction(ProxyRestrictionBean proxyRestriction) {
193 this.proxyRestriction = proxyRestriction;
194 }
195
196 public List<DelegateBean> getDelegates() {
197 return delegates;
198 }
199
200 public void setDelegates(List<DelegateBean> delegates) {
201 this.delegates = delegates;
202 }
203
204
205
206
207
208
209
210 @Override
211 public boolean equals(Object o) {
212 if (this == o) {
213 return true;
214 }
215 if (!(o instanceof ConditionsBean)) {
216 return false;
217 }
218
219 ConditionsBean that = (ConditionsBean) o;
220
221 if (tokenPeriodSeconds != that.tokenPeriodSeconds) {
222 return false;
223 }
224
225 if (notBefore == null && that.notBefore != null) {
226 return false;
227 } else if (notBefore != null && !notBefore.equals(that.notBefore)) {
228 return false;
229 }
230
231 if (notAfter == null && that.notAfter != null) {
232 return false;
233 } else if (notAfter != null && !notAfter.equals(that.notAfter)) {
234 return false;
235 }
236
237 if (audienceRestrictions == null && that.audienceRestrictions != null) {
238 return false;
239 } else if (audienceRestrictions != null
240 && !audienceRestrictions.equals(that.audienceRestrictions)) {
241 return false;
242 }
243
244 if (oneTimeUse != that.oneTimeUse) {
245 return false;
246 }
247
248 if (proxyRestriction == null && that.proxyRestriction != null) {
249 return false;
250 } else if (proxyRestriction != null
251 && !proxyRestriction.equals(that.proxyRestriction)) {
252 return false;
253 }
254
255 if (delegates == null && that.delegates != null) {
256 return false;
257 } else if (delegates != null && !delegates.equals(that.delegates)) {
258 return false;
259 }
260
261 return true;
262 }
263
264
265
266
267 @Override
268 public int hashCode() {
269 int result = (int)tokenPeriodSeconds;
270 if (notBefore != null) {
271 result = 31 * result + notBefore.hashCode();
272 }
273 if (notAfter != null) {
274 result = 31 * result + notAfter.hashCode();
275 }
276 if (audienceRestrictions != null) {
277 result = 31 * result + audienceRestrictions.hashCode();
278 }
279 result = 31 * result + (oneTimeUse ? 1 : 0);
280 if (proxyRestriction != null) {
281 result = 31 * result + proxyRestriction.hashCode();
282 }
283 if (delegates != null) {
284 result = 31 * result + delegates.hashCode();
285 }
286 return result;
287 }
288
289 }