1 package org
.argeo
.naming
;
3 import java
.time
.Instant
;
4 import java
.time
.ZoneOffset
;
5 import java
.time
.ZonedDateTime
;
7 public class SharedSecret
extends AuthPassword
{
8 public final static String X_SHARED_SECRET
= "X-SharedSecret";
9 private final Instant expiry
;
11 public SharedSecret(String authInfo
, String authValue
) {
12 super(authInfo
, authValue
);
16 public SharedSecret(AuthPassword authPassword
) {
18 String authInfo
= getAuthInfo();
19 if (authInfo
.length() == 16) {
20 expiry
= NamingUtils
.ldapDateToInstant(authInfo
);
26 public SharedSecret(ZonedDateTime expiryTimestamp
, String value
) {
27 super(NamingUtils
.instantToLdapDate(expiryTimestamp
), value
);
28 expiry
= expiryTimestamp
.withZoneSameInstant(ZoneOffset
.UTC
).toInstant();
31 public SharedSecret(int hours
, String value
) {
32 this(ZonedDateTime
.now().plusHours(hours
), value
);
36 protected String
getExpectedAuthScheme() {
37 return X_SHARED_SECRET
;
40 public boolean isExpired() {
43 return expiry
.isBefore(Instant
.now());