本文整理匯總了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());
}