Package org.sdase.commons.server.opa
Interface OpaJwtPrincipal
-
- All Superinterfaces:
java.security.Principal
- All Known Implementing Classes:
OpaJwtPrincipalImpl
public interface OpaJwtPrincipal extends java.security.Principal
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static OpaJwtPrincipalImpl
create(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)
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()
-
-
-
Method Detail
-
create
static OpaJwtPrincipalImpl create(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)
- Parameters:
jwt
- The token this Principal is created from. May be required to pass it to other services.claims
- The claims in the verifiedjwt
.om
- The Object Mapper to use to decode the constraints.constraints
- Authorization details used within the service for limiting result data- Returns:
- the principal that contains a jwt token, claims, and constraints that can be decoded
-
getJwt
java.lang.String getJwt()
- Returns:
- the JWT as string
-
getClaims
java.util.Map<java.lang.String,com.auth0.jwt.interfaces.Claim> getClaims()
- Returns:
- map with the claims decoded from the JWT
-
getConstraints
java.lang.String getConstraints()
- Returns:
- the constraint object as JSON String
-
getConstraintsAsEntity
<T> T getConstraintsAsEntity(java.lang.Class<T> resultType)
returns the constraint as Object. The object type must match the response from OPA sidecar- 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
-
-