本文整理了Java中io.jsonwebtoken.Claims.getNotBefore()
方法的一些代码示例,展示了Claims.getNotBefore()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Claims.getNotBefore()
方法的具体详情如下:
包路径:io.jsonwebtoken.Claims
类名称:Claims
方法名:getNotBefore
[英]Returns the JWT nbf
(not before) timestamp or null if not present.
A JWT obtained before this timestamp should not be used.
[中]返回JWTnbf
(非之前)时间戳,如果不存在,则返回null。
不应使用在此时间戳之前获得的JWT。
代码示例来源:origin: jwtk/jjwt
Date nbf = claims.getNotBefore();
if (nbf != null) {
代码示例来源:origin: craftingjava/springuni-particles
/**
* Factory method for creating a new {@code {@link JwtAuthenticationToken}}.
* @param claims JWT claims
* @return a JwtAuthenticationToken
*/
public static JwtAuthenticationToken of(Claims claims) {
long userId = Long.valueOf(claims.getSubject());
Collection<GrantedAuthority> authorities =
Arrays.stream(String.valueOf(claims.get(AUTHORITIES)).split(","))
.map(String::trim)
.filter(StringUtils::hasText)
.map(String::toUpperCase)
.map(SimpleGrantedAuthority::new)
.collect(Collectors.toSet());
JwtAuthenticationToken jwtAuthenticationToken = new JwtAuthenticationToken(userId, authorities);
Date now = new Date();
Date expiration = claims.getExpiration();
Date notBefore = Optional.ofNullable(claims.getNotBefore()).orElse(now);
jwtAuthenticationToken.setAuthenticated(now.after(notBefore) && now.before(expiration));
return jwtAuthenticationToken;
}
代码示例来源:origin: io.jsonwebtoken/jjwt
Date nbf = claims.getNotBefore();
if (nbf != null) {
代码示例来源:origin: io.jsonwebtoken/jjwt-impl
Date nbf = claims.getNotBefore();
if (nbf != null) {
内容来源于网络,如有侵权,请联系作者删除!