Class 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 using Context when the OpaBundle 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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.security.Principal

        equals, hashCode, implies, toString
    • Constructor Detail

      • OpaJwtPrincipalImpl

        public 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 Detail

      • getName

        public java.lang.String getName()
        Specified by:
        getName in interface java.security.Principal
      • getJwt

        public java.lang.String getJwt()
        Specified by:
        getJwt in interface OpaJwtPrincipal
        Returns:
        the JWT as string
      • getClaims

        public java.util.Map<java.lang.String,​com.auth0.jwt.interfaces.Claim> getClaims()
        Specified by:
        getClaims in interface OpaJwtPrincipal
        Returns:
        map with the claims decoded from the JWT
      • getConstraints

        public java.lang.String getConstraints()
        Specified by:
        getConstraints in interface OpaJwtPrincipal
        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 interface OpaJwtPrincipal
        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