org.springframework.security.oauth2.jwt.Jwt.getClaimAsString()方法的使用及代码示例

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

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

Jwt.getClaimAsString介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-security

/**
   * {@inheritDoc}
   */
  @Override
  public OAuth2TokenValidatorResult validate(Jwt token) {
    Assert.notNull(token, "token cannot be null");

    String tokenIssuer = token.getClaimAsString(JwtClaimNames.ISS);
    if (this.issuer.equals(tokenIssuer)) {
      return OAuth2TokenValidatorResult.success();
    } else {
      return OAuth2TokenValidatorResult.failure(INVALID_ISSUER);
    }
  }
}

代码示例来源:origin: spring-projects/spring-security

String authorizedParty = idToken.getClaimAsString(IdTokenClaimNames.AZP);
if (idToken.getAudience().size() > 1 && authorizedParty == null) {
  invalidClaims.put(IdTokenClaimNames.AZP, authorizedParty);

代码示例来源:origin: spring-cloud/spring-cloud-gcp

@RequestMapping("/topsecret")
public String secured() {
  Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
  if (authentication != null && authentication.getPrincipal() instanceof Jwt) {
    Jwt jwt = (Jwt) authentication.getPrincipal();
    return String.format("You are [%s] with e-mail address [%s].%n",
        jwt.getSubject(), jwt.getClaimAsString("email"));
  }
  else {
    return "Something went wrong; authentication is not provided by IAP/JWT.\n";
  }
}

代码示例来源:origin: org.springframework.security/spring-security-oauth2-jose

/**
   * {@inheritDoc}
   */
  @Override
  public OAuth2TokenValidatorResult validate(Jwt token) {
    Assert.notNull(token, "token cannot be null");

    String tokenIssuer = token.getClaimAsString(JwtClaimNames.ISS);
    if (this.issuer.equals(tokenIssuer)) {
      return OAuth2TokenValidatorResult.success();
    } else {
      return OAuth2TokenValidatorResult.failure(INVALID_ISSUER);
    }
  }
}

相关文章