1 package org
.argeo
.cms
.directory
.ldap
;
3 import java
.time
.Instant
;
4 import java
.time
.ZoneOffset
;
5 import java
.time
.ZonedDateTime
;
7 import org
.argeo
.api
.acr
.ldap
.NamingUtils
;
9 public class SharedSecret
extends AuthPassword
{
10 public final static String X_SHARED_SECRET
= "X-SharedSecret";
11 private final Instant expiry
;
13 public SharedSecret(String authInfo
, String authValue
) {
14 super(authInfo
, authValue
);
18 public SharedSecret(AuthPassword authPassword
) {
20 String authInfo
= getAuthInfo();
21 if (authInfo
.length() == 16) {
22 expiry
= NamingUtils
.ldapDateToInstant(authInfo
);
28 public SharedSecret(ZonedDateTime expiryTimestamp
, String value
) {
29 super(NamingUtils
.instantToLdapDate(expiryTimestamp
), value
);
30 expiry
= expiryTimestamp
.withZoneSameInstant(ZoneOffset
.UTC
).toInstant();
33 public SharedSecret(int hours
, String value
) {
34 this(ZonedDateTime
.now().plusHours(hours
), value
);
38 protected String
getExpectedAuthScheme() {
39 return X_SHARED_SECRET
;
42 public boolean isExpired() {
45 return expiry
.isBefore(Instant
.now());