
com.bcgdv.jwt.services.StringJwtClaimsHandlerAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of token-generation Show documentation
Show all versions of token-generation Show documentation
JWT token generation with encrypted payloads and CLI
package com.bcgdv.jwt.services;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.jsonwebtoken.*;
/**
* Needs doco
*/
public class StringJwtClaimsHandlerAdapter extends JwtHandlerAdapter {
/**
* Needs doco
*/
private ObjectMapper objectMapper = new ObjectMapper();
/**
* Needs doco
* @param claims needs doco
* @return needs doco
*/
private String deserializeClaims(Claims claims) {
try {
return objectMapper.writeValueAsString(claims);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Needs doco
* @param jwt needs doco
* @return needs doco
*/
@Override
public String onClaimsJwt(Jwt jwt) {
return deserializeClaims(jwt.getBody());
}
/**
* Needs doco
* @param jws needs doco
* @return needs doco.
*/
@Override
public String onClaimsJws(Jws jws) {
return deserializeClaims(jws.getBody());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy