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

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

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

Verification.withSubject介绍

暂无

代码示例

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

@Test
public void shouldValidateSubject() throws Exception {
  String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.Rq8IxqeX7eA6GgYxlcHdPFVRNFFZc5rEI3MQTZZbK3I";
  DecodedJWT jwt = JWTVerifier.init(Algorithm.HMAC256("secret"))
      .withSubject("1234567890")
      .build()
      .verify(token);
  assertThat(jwt, is(notNullValue()));
}

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

@Test
public void shouldThrowOnInvalidSubject() throws Exception {
  exception.expect(InvalidClaimException.class);
  exception.expectMessage("The Claim 'sub' value doesn't match the required one.");
  String token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIn0.Rq8IxqeX7eA6GgYxlcHdPFVRNFFZc5rEI3MQTZZbK3I";
  JWTVerifier.init(Algorithm.HMAC256("secret"))
      .withSubject("invalid")
      .build()
      .verify(token);
}

代码示例来源:origin: com.github.edgar615/spring-boot-util-jwt

verification.withSubject(jwtProperty.getSubject());

相关文章