diff options
author | Morten Tokle <mortent@verizonmedia.com> | 2020-02-28 08:26:15 +0100 |
---|---|---|
committer | Morten Tokle <mortent@verizonmedia.com> | 2020-02-28 08:28:38 +0100 |
commit | 664f3e65851e5396fc83bc44b8638cf35badef52 (patch) | |
tree | f6e8a7a5397e362a6066410c09e100248c341359 /vespa-athenz | |
parent | 1d002116992cdc80c2bf2235c46dfa11ef48b256 (diff) |
Add expiry time
Diffstat (limited to 'vespa-athenz')
-rw-r--r-- | vespa-athenz/pom.xml | 12 | ||||
-rw-r--r-- | vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzAccessToken.java | 9 |
2 files changed, 20 insertions, 1 deletions
diff --git a/vespa-athenz/pom.xml b/vespa-athenz/pom.xml index 0f23eaed964..7d2ad924ae3 100644 --- a/vespa-athenz/pom.xml +++ b/vespa-athenz/pom.xml @@ -131,7 +131,17 @@ <artifactId>jackson-annotations</artifactId> </exclusion> </exclusions> - </dependency> + </dependency> + <dependency> + <groupId>com.auth0</groupId> + <artifactId>java-jwt</artifactId> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> </dependencies> <build> diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzAccessToken.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzAccessToken.java index 49b10a37329..7ad97f8ac3c 100644 --- a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzAccessToken.java +++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/api/AthenzAccessToken.java @@ -1,6 +1,10 @@ // Copyright 2020 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.athenz.api; +import com.auth0.jwt.JWT; +import com.auth0.jwt.interfaces.DecodedJWT; + +import java.time.Instant; import java.util.Objects; /** @@ -15,9 +19,11 @@ public class AthenzAccessToken { private static final String BEARER_TOKEN_PREFIX = "Bearer "; private final String value; + private final DecodedJWT jwt; public AthenzAccessToken(String value) { this.value = stripBearerTokenPrefix(value); + this.jwt = JWT.decode(this.value); } private static String stripBearerTokenPrefix(String rawValue) { @@ -33,6 +39,9 @@ public class AthenzAccessToken { public String value() { return value; } public String valueWithBearerPrefix() { return BEARER_TOKEN_PREFIX + value; } + public Instant getExpiryTime () { + return jwt.getExpiresAt().toInstant(); + } @Override public String toString() { return "AthenzAccessToken{value='" + value + "'}"; } |