com.auth0.jwt.interfaces.Verification.acceptExpiresAt()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.9k)|赞(0)|评价(0)|浏览(374)

本文整理了Java中com.auth0.jwt.interfaces.Verification.acceptExpiresAt()方法的一些代码示例,展示了Verification.acceptExpiresAt()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Verification.acceptExpiresAt()方法的具体详情如下:
包路径:com.auth0.jwt.interfaces.Verification
类名称:Verification
方法名:acceptExpiresAt

Verification.acceptExpiresAt介绍

暂无

代码示例

代码示例来源:origin: auth0/java-jwt

@Test
public void shouldValidateExpiresAtWithLeeway() throws Exception {
  Clock clock = mock(Clock.class);
  when(clock.getToday()).thenReturn(new Date(DATE_TOKEN_MS_VALUE + 1000));
  String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0Nzc1OTJ9.isvT0Pqx0yjnZk53mUFSeYFJLDs-Ls9IsNAm86gIdZo";
  JWTVerifier.BaseVerification verification = (JWTVerifier.BaseVerification) JWTVerifier.init(Algorithm.HMAC256("secret"))
      .acceptExpiresAt(2);
  DecodedJWT jwt = verification
      .build(clock)
      .verify(token);
  assertThat(jwt, is(notNullValue()));
}

代码示例来源:origin: auth0/java-jwt

@Test
public void shouldThrowOnNegativeExpiresAtLeeway() throws Exception {
  exception.expect(IllegalArgumentException.class);
  exception.expectMessage("Leeway value can't be negative.");
  Algorithm algorithm = mock(Algorithm.class);
  JWTVerifier.init(algorithm)
      .acceptExpiresAt(-1);
}

代码示例来源:origin: auth0/java-jwt

@SuppressWarnings("RedundantCast")
@Test
public void shouldOverrideDefaultExpiresAtLeeway() throws Exception {
  Algorithm algorithm = mock(Algorithm.class);
  JWTVerifier verifier = JWTVerifier.init(algorithm)
      .acceptLeeway(1234L)
      .acceptExpiresAt(9999L)
      .build();
  assertThat(verifier.claims, is(notNullValue()));
  assertThat(verifier.claims, hasEntry("iat", (Object) 1234L));
  assertThat(verifier.claims, hasEntry("exp", (Object) 9999L));
  assertThat(verifier.claims, hasEntry("nbf", (Object) 1234L));
}

代码示例来源:origin: com.microsoft.bot.connector/bot-connector

if (!tokenValidationParameters.validateLifetime) {
  verification = verification
      .acceptExpiresAt(System.currentTimeMillis() + 500)
      .acceptNotBefore(0);

相关文章