Java Code Examples for org.eclipse.microprofile.jwt.tck.util.TokenUtils#currentTimeInSecs()
The following examples show how to use
org.eclipse.microprofile.jwt.tck.util.TokenUtils#currentTimeInSecs() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestJsonWebToken.java From smallrye-jwt with Apache License 2.0 | 5 votes |
@Test(expectedExceptions = { ParseException.class }, description = "Illustrate validation of exp that has just expired") public void testNimbusFailJustExpired() throws Exception { HashMap<String, Long> timeClaims = new HashMap<>(); // Set exp to 61 seconds in past long exp = TokenUtils.currentTimeInSecs() - 61; timeClaims.put(Claims.exp.name(), exp); String token = TokenUtils.generateTokenString("/Token1.json", null, timeClaims); RSAPublicKey publicKey = (RSAPublicKey) TokenUtils.readPublicKey("/publicKey.pem"); JWTAuthContextInfo contextInfo = new JWTAuthContextInfo(publicKey, "https://server.example.com"); contextInfo.setExpGracePeriodSecs(60); JsonWebToken jwt = validateToken(token, contextInfo); }
Example 2
Source File: TestJsonWebToken.java From smallrye-jwt with Apache License 2.0 | 5 votes |
@Test(description = "Illustrate validation of exp that is in grace period") public void testNimbusExpGrace() throws Exception { HashMap<String, Long> timeClaims = new HashMap<>(); // Set exp to 45 seconds in past long exp = TokenUtils.currentTimeInSecs() - 45; timeClaims.put(Claims.exp.name(), exp); String token = TokenUtils.generateTokenString("/Token1.json", null, timeClaims); RSAPublicKey publicKey = (RSAPublicKey) TokenUtils.readPublicKey("/publicKey.pem"); JWTAuthContextInfo contextInfo = new JWTAuthContextInfo(publicKey, "https://server.example.com"); contextInfo.setExpGracePeriodSecs(60); JsonWebToken jwt = validateToken(token, contextInfo); }
Example 3
Source File: AbstractVerifierTest.java From microprofile-jwt-auth with Apache License 2.0 | 5 votes |
@Test(description = "Illustrate validation of exp that is in grace period") public void testExpGrace() throws Exception { HashMap<String, Long> timeClaims = new HashMap<>(); // Set exp to 45 seconds in past long exp = TokenUtils.currentTimeInSecs() - 45; timeClaims.put(Claims.exp.name(), exp); String token = TokenUtils.generateTokenString("/Token1.json", null, timeClaims); RSAPublicKey publicKey = (RSAPublicKey) TokenUtils.readPublicKey("/publicKey.pem"); int expGracePeriodSecs = 60; validateToken(token, publicKey, TEST_ISSUER, expGracePeriodSecs); }