Class EncryptionMethodMetadata

java.lang.Object
se.swedenconnect.security.credential.opensaml.EncryptionMethodMetadata

public class EncryptionMethodMetadata extends Object
Settings for representing md:EncryptionMethod elements.

When represented in properties files as the value for the OpenSamlMetadataProperties.ENCRYPTION_METHODS metadata property, a string format according to the following format is used:


 <encryption-algorithm-uri>[;key-size=<size-in-bits>][;oaep-params=<base64-params>][;digest-method=<digest-method-uri>]
 

Example:


 <md:EncryptionMethod xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
   <ds:DigestMethod xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
 </md:EncryptionMethod>

 "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p;digest-method=http://www.w3.org/2000/09/xmldsig#sha1"
 
Author:
Martin Lindström
  • Field Details

  • Constructor Details

    • EncryptionMethodMetadata

      public EncryptionMethodMetadata()
  • Method Details

    • getAlgorithm

      @Nonnull public String getAlgorithm()
      Gets the algorithm URI for the encryption method.
      Returns:
      the algorithm URI for the encryption method
    • setAlgorithm

      public void setAlgorithm(@Nonnull String algorithm)
      Assigns the algorithm URI for the encryption method.
      Parameters:
      algorithm - the algorithm URI
    • getKeySize

      @Nullable public Integer getKeySize()
      Gets the key size (relevant if the encryption method is a symmetric algorithm).
      Returns:
      the key size in bits, or null
    • setKeySize

      public void setKeySize(@Nullable Integer keySize)
      Assigns the key size.
      Parameters:
      keySize - the key size in bits
    • getOaepParams

      @Nullable public String getOaepParams()
      Gets the OAEP parameters (base64-encoded).
      Returns:
      the OAEP parameters or null
    • setOaepParams

      public void setOaepParams(@Nullable String oaepParams)
      Assigns the OAEP parameters (base64-encoded).
      Parameters:
      oaepParams - the OAEP parameters
    • getDigestMethod

      @Nullable public String getDigestMethod()
      Gets the digest algorithm to use. Relevant if the encryption method is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p or http://www.w3.org/2009/xmlenc11#rsa-oaep.
      Returns:
      the digest method, or null
    • setDigestMethod

      public void setDigestMethod(@Nullable String digestMethod)
      Assigns the digest algorithm to use. Relevant if the encryption method is http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p or http://www.w3.org/2009/xmlenc11#rsa-oaep.
      Parameters:
      digestMethod - the digest method
    • parseMethod

      @Nonnull public static EncryptionMethodMetadata parseMethod(@Nonnull String method) throws IllegalArgumentException
      Parses the string representation of an encryption method (see class documentation above) into an EncryptionMethodMetadata object.
      Parameters:
      method - the string representation
      Returns:
      an EncryptionMethodMetadata object
      Throws:
      IllegalArgumentException - for invalid indata
    • parseMethods

      @Nonnull public static List<EncryptionMethodMetadata> parseMethods(@Nonnull String methods) throws IllegalArgumentException
      Parses a string representation of several encryption methods. Each method is separated by a ','. See parseMethod(String).
      Parameters:
      methods - the string representation
      Returns:
      a list of EncryptionMethodMetadata objects
      Throws:
      IllegalArgumentException - for invalid indate
    • toEncryptionMethod

      @Nonnull public EncryptionMethod toEncryptionMethod()
      Creates an OpenSAML EncryptionMethod object given the settings of this object.
      Returns:
      an OpenSAML EncryptionMethod object
    • toString

      public String toString()
      Overrides:
      toString in class Object