Программисты JAVA общаются здесь
-
Anonymous
Что поставить вместо «parseClaimsJwt» для моего JWTVerifier для моего проекта аутентификации JWT Spring Security
Сообщение
Anonymous »
@RequiredArgsConstructor
Открытый класс JwtVerifier реализует TokenVerifier {
Код: Выделить всё
private final ObjectMapper objectMapper;
@Override
public Authentication valid(String token) throws ClaimJwtException {
String[] split = token.split("\\.");
//dont parse the signature
if (split.length < 2) {
throw new ApiAuthenticationException("Token malformed (base64)");
}
Jwt headerClaimsJwt = Jwts.parser().parseClaimsJwt(split[0] + "." + split[1] + ".");
Claims body = headerClaimsJwt.getPayload();
AuthenticatedIdentity authenticatedIdentity = objectMapper.convertValue(body, AuthenticatedIdentity.class);
authenticatedIdentity.setToken(token);
return authenticatedIdentity;
}
}
JwtParser jwtParser = Jwts.parserBuilder().build();
Jwt headerClaimsJwt = jwtParser.parseClaimsJwt(split[0] + "." + Split[1] + ".");
Подробнее здесь:
https://stackoverflow.com/questions/793 ... ng-securit
1736503777
Anonymous
@RequiredArgsConstructor
Открытый класс JwtVerifier реализует TokenVerifier {
[code]private final ObjectMapper objectMapper;
@Override
public Authentication valid(String token) throws ClaimJwtException {
String[] split = token.split("\\.");
//dont parse the signature
if (split.length < 2) {
throw new ApiAuthenticationException("Token malformed (base64)");
}
Jwt headerClaimsJwt = Jwts.parser().parseClaimsJwt(split[0] + "." + split[1] + ".");
Claims body = headerClaimsJwt.getPayload();
AuthenticatedIdentity authenticatedIdentity = objectMapper.convertValue(body, AuthenticatedIdentity.class);
authenticatedIdentity.setToken(token);
return authenticatedIdentity;
}
[/code]
}
JwtParser jwtParser = Jwts.parserBuilder().build();
Jwt headerClaimsJwt = jwtParser.parseClaimsJwt(split[0] + "." + Split[1] + ".");
Подробнее здесь: [url]https://stackoverflow.com/questions/79345322/what-to-put-instead-of-parseclaimsjwt-for-my-jwtverifier-for-my-spring-securit[/url]