Class GenericJsonJWE<A,B extends JsonJWE.Recipient<A>>

java.lang.Object
io.inverno.mod.security.jose.internal.AbstractJsonJOSEObject<A>
io.inverno.mod.security.jose.internal.jwe.GenericJsonJWE<A,B>
Type Parameters:
A - the payload type
B - the JSON JWE recipient type
All Implemented Interfaces:
JsonJOSEObject<A>, JsonJWE<A,B>

public class GenericJsonJWE<A,B extends JsonJWE.Recipient<A>> extends AbstractJsonJOSEObject<A> implements JsonJWE<A,B>

Generic JSON JWE implementation.

Since:
1.5
Author:
Jeremy Kuhn
  • Constructor Details

    • GenericJsonJWE

      public GenericJsonJWE(JWEHeader protectedHeader, JWEHeader unprotectedHeader, String iv, String aad, String cipherText, String tag, List<B> recipients, com.fasterxml.jackson.databind.ObjectMapper mapper)

      Creates a generic JSON JWE.

      Parameters:
      protectedHeader - the protected header
      unprotectedHeader - the unprotected header
      iv - the Base64URL encoded initialization vector without padding
      aad - the Base64URL encoded additional authentication data without padding
      cipherText - the Base64URL encoded cipher text without padding
      tag - the Base64URL encoded authenticationt tag without padding
      recipients - the list of JSON JWE recipients
      mapper - an object mapper
  • Method Details

    • getProtectedHeader

      public JWEHeader getProtectedHeader()
      Description copied from interface: JsonJWE

      Returns the protected header common to all recipients.

      Specified by:
      getProtectedHeader in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the protected header
    • getEncodedProtectedHeader

      public String getEncodedProtectedHeader()

      Returns the protected JWE header encoded as Base64URL.

      Returns:
      the Base64URL encoded protected JWE header.
    • getUnprotectedHeader

      public JWEHeader getUnprotectedHeader()
      Description copied from interface: JsonJWE

      Returns the unprotected header common to all recipients.

      Specified by:
      getUnprotectedHeader in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the unprotected header
    • getInitializationVector

      public String getInitializationVector()
      Description copied from interface: JsonJWE

      Returns the initialization vector common to all recipients encoded as Base64URL.

      Specified by:
      getInitializationVector in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the Base64URL encoded initialization vector with no padding
    • getAdditionalAuthenticationData

      public String getAdditionalAuthenticationData()
      Description copied from interface: JsonJWE

      Returns the additional authentication data common to all recipients encoded as Base64URL.

      Specified by:
      getAdditionalAuthenticationData in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the Base64URL encoded additional authentication data with no padding
    • getCipherText

      public String getCipherText()
      Description copied from interface: JsonJWE

      Returns the cipher text common to all recipients encoded as Base64URL.

      Specified by:
      getCipherText in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the Base64URL encoded cipher text with no padding
    • getAuthenticationTag

      public String getAuthenticationTag()
      Description copied from interface: JsonJWE

      Returns the authentication tag common to all recipients encoded as Base64URL.

      Specified by:
      getAuthenticationTag in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      the Base64URL encoded authentication tag with no padding
    • getRecipients

      public List<B> getRecipients()
      Description copied from interface: JsonJWE

      Returns the list of recipients.

      When considering a built JSON JWE, recipient must be of type JsonJWE.BuiltRecipient which directly exposes the built JWE objects corresponding to recipient.

      When considering a read JSON JWE, recipient must be of type JsonJWE.ReadRecipient which exposes JWE objects per recipient as single publisher used to decrypt and validate the corresponding JWE.

      Specified by:
      getRecipients in interface JsonJWE<A,B extends JsonJWE.Recipient<A>>
      Returns:
      a list of recipients
    • toJson

      public String toJson() throws JOSEProcessingException
      Description copied from interface: JsonJOSEObject

      Serializes the JOSE object to a JSON representation.

      Specified by:
      toJson in interface JsonJOSEObject<A>
      Overrides:
      toJson in class AbstractJsonJOSEObject<A>
      Returns:
      the JSON representation of the JOSE object
      Throws:
      JOSEProcessingException - if there was an error serializing the JOSE object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractJsonJOSEObject<A>
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class AbstractJsonJOSEObject<A>