Class OpaJwtPrincipalImpl
- java.lang.Object
-
- org.sdase.commons.server.opa.internal.OpaJwtPrincipalImpl
-
- All Implemented Interfaces:
java.security.Principal
,OpaJwtPrincipal
public class OpaJwtPrincipalImpl extends java.lang.Object implements OpaJwtPrincipal
Principal for @SecurityContext
that optionally contains a JWT and a set of constraints as JSON object string.The
OpaJwtPrincipal
can be injected as field in endpoint implementations usingContext
when theOpaBundle
is used to setup the open policy agent configuration.
-
-
Constructor Summary
Constructors Constructor Description OpaJwtPrincipalImpl(java.lang.String name, java.lang.String jwt, java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim> claims, com.fasterxml.jackson.databind.JsonNode constraints, com.fasterxml.jackson.databind.ObjectMapper om)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim>
getClaims()
java.lang.String
getConstraints()
<T> T
getConstraintsAsEntity(java.lang.Class<T> resultType)
returns the constraint as Object.java.lang.String
getJwt()
java.lang.String
getName()
-
-
-
Method Detail
-
getName
public java.lang.String getName()
- Specified by:
getName
in interfacejava.security.Principal
-
getJwt
public java.lang.String getJwt()
- Specified by:
getJwt
in interfaceOpaJwtPrincipal
- Returns:
- the JWT as string
-
getClaims
public java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim> getClaims()
- Specified by:
getClaims
in interfaceOpaJwtPrincipal
- Returns:
- map with the claims decoded from the JWT
-
getConstraints
public java.lang.String getConstraints()
- Specified by:
getConstraints
in interfaceOpaJwtPrincipal
- Returns:
- the constraint object as JSON String
-
getConstraintsAsEntity
public <T> T getConstraintsAsEntity(java.lang.Class<T> resultType)
Description copied from interface:OpaJwtPrincipal
returns the constraint as Object. The object type must match the response from OPA sidecar- Specified by:
getConstraintsAsEntity
in interfaceOpaJwtPrincipal
- Type Parameters:
T
- type for correct casting- Parameters:
resultType
- Result class to that the constraint string is parsed- Returns:
- the object or null if no constraint exists
-
-