Class JsonWebTokenUtil
- java.lang.Object
-
- org.technologybrewery.fermenter.stout.authz.json.JsonWebTokenUtil
-
public final class JsonWebTokenUtil extends Object
Builds/decodes a JSON Web Token (JWT) for a given subject and set of policies (represented as resource/action pairs). This allows you to ask the PDP for a number of claims and represent them in a JWT format. Within a service, you can simply return this token as a string.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringcreateToken(String subject, String audience, Collection<? extends AbstractAuthorizationRequest> ruleClaims)Creates a JSON Web Token (JWT) for the given subject, audience, and resource/action pairs.static io.jsonwebtoken.Jws<io.jsonwebtoken.Claims>parseLocalToken(String token)Decodes a JSON Web Token.
-
-
-
Method Detail
-
createToken
public static String createToken(String subject, String audience, Collection<? extends AbstractAuthorizationRequest> ruleClaims)
Creates a JSON Web Token (JWT) for the given subject, audience, and resource/action pairs.- Parameters:
subject- The subject for which the token will contain informationaudience- The audience to whom this token is intendedruleClaims- resource/action pairs for which the PDP will be asked for decisions or id requests for attributes- Returns:
- A signed, compressed JWT token
-
parseLocalToken
public static io.jsonwebtoken.Jws<io.jsonwebtoken.Claims> parseLocalToken(String token)
Decodes a JSON Web Token.- Parameters:
token- the token to decode- Returns:
- the decoded token. See JJWT for usage details.
-
-