Class KeyDescriptorBuilder

java.lang.Object
se.swedenconnect.opensaml.common.builder.AbstractSAMLObjectBuilder<org.opensaml.saml.saml2.metadata.KeyDescriptor>
se.swedenconnect.opensaml.saml2.metadata.build.KeyDescriptorBuilder
All Implemented Interfaces:
SAMLObjectBuilder<org.opensaml.saml.saml2.metadata.KeyDescriptor>

public class KeyDescriptorBuilder extends AbstractSAMLObjectBuilder<org.opensaml.saml.saml2.metadata.KeyDescriptor>
A builder for KeyDescriptor elements.

This builder only supports a subset of the possible elements of a key descriptor, but should be sufficient for most cases.

Author:
Martin Lindström (martin@idsec.se)
  • Constructor Details

    • KeyDescriptorBuilder

      public KeyDescriptorBuilder()
  • Method Details

    • builder

      public static KeyDescriptorBuilder builder()
      Utility method that creates a builder.
      Returns:
      a builder
    • getObjectType

      protected Class<org.opensaml.saml.saml2.metadata.KeyDescriptor> getObjectType()
      Returns the object type.
      Specified by:
      getObjectType in class AbstractSAMLObjectBuilder<org.opensaml.saml.saml2.metadata.KeyDescriptor>
      Returns:
      the object type
    • use

      public KeyDescriptorBuilder use(org.opensaml.security.credential.UsageType usageType)
      Assigns the usage type for the key descriptor.
      Parameters:
      usageType - the usage type
      Returns:
      the builder
    • keyName

      public KeyDescriptorBuilder keyName(String name)
      Assigns the key name of the KeyInfo element within the key descriptor.
      Parameters:
      name - the key name
      Returns:
      the builder
    • certificate

      public KeyDescriptorBuilder certificate(X509Certificate certificate)
      Assigns a certificate to be used as a X.509 data element of the KeyInfo element within the key descriptor.
      Parameters:
      certificate - the certificate
      Returns:
      the builder
    • certificate

      public KeyDescriptorBuilder certificate(InputStream certificate)
      Assigns an input stream to a certificate resource that is to be used as a X.509 data element of the KeyInfo element within the key descriptor.
      Parameters:
      certificate - the certificate resource
      Returns:
      the builder
    • certificate

      public KeyDescriptorBuilder certificate(String base64Encoding)
      Assigns a certificate (in Base64-encoded format) to be used as a X.509 data element of the KeyInfo element within the key descriptor.
      Parameters:
      base64Encoding - the base64 encoding (note: not PEM-format)
      Returns:
      the builder
    • certificate

      public KeyDescriptorBuilder certificate(org.opensaml.security.x509.X509Credential credential)
      Assigns a certificate in OpenSAML credential format to be used as a X.509 data element of the KeyInfo element within the key descriptor.
      Parameters:
      credential - the credential
      Returns:
      the builder
    • encryptionMethods

      public KeyDescriptorBuilder encryptionMethods(List<String> algorithms)
      Assigns a list of encryption methods.

      Note: the method only accepts algorithm URI:s. If you need to assign other parts of an EncryptionMethod object you must use encryptionMethodsExt(List).

      Parameters:
      algorithms - list of algorithms
      Returns:
      the builder
    • encryptionMethods

      public KeyDescriptorBuilder encryptionMethods(String... algorithms)
      Parameters:
      algorithms - list of algorithms
      Returns:
      the builder
    • encryptionMethodsExt

      public KeyDescriptorBuilder encryptionMethodsExt(List<org.opensaml.saml.saml2.metadata.EncryptionMethod> algorithms)
      Assigns a list of encryption methods.
      Parameters:
      algorithms - ordered list of encryption methods
      Returns:
      the builder
    • encryptionMethods

      public KeyDescriptorBuilder encryptionMethods(org.opensaml.saml.saml2.metadata.EncryptionMethod... algorithms)
      Parameters:
      algorithms - ordered list of encryption methods
      Returns:
      the builder