Java Code Examples for io.jsonwebtoken.Claims#getExpiration()
The following examples show how to use
io.jsonwebtoken.Claims#getExpiration() .
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: JwtUtils.java From common-project with Apache License 2.0 | 6 votes |
/** * 解析token * * @param token * @return * @throws Exception */ public static AuthTokenDetails parseToken(String token) throws Exception { Claims claims = Jwts.parser().setSigningKey(SECRET_KEY).parseClaimsJws(token).getBody(); String userId = claims.getSubject(); String appId = (String) claims.get(APP_ID_FIELD); String organizationId = (String) claims.get(ORGANIZATION_ID_FIELD); String roleId = (String) claims.get(ROLE_ID_FIELD); String roleType = (String) claims.get(ROLE_TYPE_FIELD); String language = (String) claims.get(LANGUAGE_FIELD); Date expirationDate = claims.getExpiration(); AuthTokenDetails authTokenDetails = new AuthTokenDetails(); authTokenDetails.setUserId(Long.valueOf(userId)); authTokenDetails.setAppId(appId); authTokenDetails.setOrganizationId(Long.valueOf(organizationId)); authTokenDetails.setRoleId(roleId == null ? null : Long.valueOf(roleId)); authTokenDetails.setRoleType(RoleTypeEnum.valueOf(roleType)); authTokenDetails.setExpirationDate(expirationDate); authTokenDetails.setLanguage(language); return authTokenDetails; }
Example 2
Source File: DefaultJwtSecurityTokenService.java From onetwo with Apache License 2.0 | 6 votes |
@Override public Authentication createAuthentication(String token) throws BadCredentialsException { Claims claims = createClaimsFromToken(token); DateTime expireation = new DateTime(claims.getExpiration()); if(expireation.isBeforeNow()){ return null; } String authorityString = claims.get(JwtSecurityUtils.CLAIM_AUTHORITIES).toString(); List<GrantedAuthority> authorities = GuavaUtils.splitAsStream(authorityString, ",").map(auth->{ return new SimpleGrantedAuthority(auth); }) .collect(Collectors.toList()); Authentication authentication = buildAuthentication(claims, authorities); return authentication; }
Example 3
Source File: JwtTokenUtils.java From spring-admin-vue with Apache License 2.0 | 5 votes |
/** * 判断令牌是否过期 * * @param token 令牌 * @return 是否过期 */ public Boolean isTokenExpired(String token) { try { Claims claims = getClaimsFromToken(token); Date expiration = claims.getExpiration(); return expiration.before(new Date()); } catch (Exception e) { return false; } }
Example 4
Source File: JwtTokenUtil.java From angular-spring-api with MIT License | 5 votes |
public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 5
Source File: JWT_Utils.java From SuperBoot with MIT License | 5 votes |
/** * 获取TOKEN失效时间 * * @param token TOKEN信息 * @return */ public Date getExpirationDateFromToken(String token) { Date expiration; try { Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { throw new BaseException(StatusCode.TOKEN_INVALID); } return expiration; }
Example 6
Source File: JwtTokenUtil.java From xmanager with Apache License 2.0 | 5 votes |
public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 7
Source File: JwtTokenUtil.java From SpringBootLearn with Apache License 2.0 | 5 votes |
/** * 根据token 获取过期时间 * @param token * @return */ private Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 8
Source File: _JwtTokenUtil.java From generator-spring-rest-jwt with MIT License | 5 votes |
public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 9
Source File: JwtTokenUtil.java From microservices-sample-project with Apache License 2.0 | 5 votes |
public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 10
Source File: JwtTokenUtil.java From ponto-inteligente-api with MIT License | 5 votes |
/** * Retorna a data de expiração de um token JWT. * * @param token * @return Date */ public Date getExpirationDateFromToken(String token) { Date expiration; try { Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 11
Source File: JwtTokenUtil.java From Blog with Apache License 2.0 | 5 votes |
/** * 从token中获取过期时间 * * @param token * @return */ public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 12
Source File: JwtTokenUtil.java From spring-security with Apache License 2.0 | 5 votes |
public Date getExpirationDateFromToken(String token) { Date expiration; try { final Claims claims = getClaimsFromToken(token); expiration = claims.getExpiration(); } catch (Exception e) { expiration = null; } return expiration; }
Example 13
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 14
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 15
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 16
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 17
Source File: JwtTokenUtil.java From mall-learning with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 18
Source File: JwtTokenUtil.java From HIS with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 19
Source File: JwtTokenUtil.java From mall-swarm with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }
Example 20
Source File: JwtTokenUtil.java From mall-tiny with Apache License 2.0 | 4 votes |
/** * 从token中获取过期时间 */ private Date getExpiredDateFromToken(String token) { Claims claims = getClaimsFromToken(token); return claims.getExpiration(); }