本文整理汇总了Java中io.jsonwebtoken.PrematureJwtException类的典型用法代码示例。如果您正苦于以下问题:Java PrematureJwtException类的具体用法?Java PrematureJwtException怎么用?Java PrematureJwtException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PrematureJwtException类属于io.jsonwebtoken包,在下文中一共展示了PrematureJwtException类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticate
import io.jsonwebtoken.PrematureJwtException; //导入依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) {
log.debug("Authenticating: {}", authentication);
try {
final String token = authentication.getCredentials().toString();
final Claims claims = jwtParser.parseClaimsJws(token).getBody();
checkClaims(claims);
return new JwtToken(token, claims);
} catch (ExpiredJwtException | MalformedJwtException | PrematureJwtException | SignatureException | UnsupportedJwtException e) {
log.warn("{}", e);
throw new BadCredentialsException(e.getMessage(), e);
}
}
示例2: testAuthenticatePrematureJwtException
import io.jsonwebtoken.PrematureJwtException; //导入依赖的package包/类
@Test
public void testAuthenticatePrematureJwtException() throws Exception {
final String token = "token";
doReturn(token).when(authentication).getCredentials();
doThrow(new PrematureJwtException(null, null, null)).when(jwtParser).parseClaimsJws(anyString());
exception.expect(BadCredentialsException.class);
exception.expectCause(is(instanceOf(PrematureJwtException.class)));
jwtAuthenticationProvider.authenticate(authentication);
}
示例3: validateJwt
import io.jsonwebtoken.PrematureJwtException; //导入依赖的package包/类
private Map<String, Object> validateJwt(String token, ApiRequest request, JWTPolicyBean config)
throws ExpiredJwtException, PrematureJwtException, MalformedJwtException, SignatureException, InvalidClaimException {
JwtParser parser = Jwts.parser()
.setSigningKey(config.getSigningKey())
.setAllowedClockSkewSeconds(config.getAllowedClockSkew());
// Set all claims
config.getRequiredClaims().stream() // TODO add type variable to allow dates, etc
.forEach(requiredClaim -> parser.require(requiredClaim.getClaimName(), requiredClaim.getClaimValue()));
return parser.parse(token, new ConfigCheckingJwtHandler(config));
}
示例4: jwtPremature
import io.jsonwebtoken.PrematureJwtException; //导入依赖的package包/类
public PolicyFailure jwtPremature(IPolicyContext context, PrematureJwtException e) {
return createAuthenticationPolicyFailure(context, AUTH_JWT_PREMATURE,
e.getLocalizedMessage());
}