Class AbstractDomData

java.lang.Object
se.swedenconnect.cert.extensions.data.saci.AbstractDomData
Direct Known Subclasses:
Attribute, AttributeMapping, AuthContextInfo, IdAttributes, SAMLAuthContext

public abstract class AbstractDomData extends Object
Abstract class providing basics for xml elements that are part of the SAMLAuthContext implementation
  • Field Details

    • XML_DATE_TIME_FORMATTER

      public static final DateTimeFormatter XML_DATE_TIME_FORMATTER
      Formatter for XML date element content
    • SACI_NS

      public static final String SACI_NS
      XML name space URI for the RFC 7773 SAMLAuthContext XML element
      See Also:
    • SAML_ASSERTION_NS

      public static final String SAML_ASSERTION_NS
      XML name space URI for SAML assertion data
      See Also:
    • strictMode

      protected boolean strictMode
      indicates if content validation should be done with strict compliance requirements
  • Constructor Details

    • AbstractDomData

      public AbstractDomData(Element element) throws CertificateException
      Constructor for the base Abstract class
      Parameters:
      element - The element holding a SAMLAuthContextExtension extension
      Throws:
      CertificateException - content validation error
    • AbstractDomData

      public AbstractDomData(Element element, boolean strictMode) throws CertificateException
      Constructor for the base Abstract class setting strict mode
      Parameters:
      element - The element holding a SAMLAuthContextExtension extension
      strictMode - true to strictly enforce content requirement rules
      Throws:
      CertificateException - content validation error
  • Method Details

    • setValuesFromElement

      protected abstract void setValuesFromElement(Element element) throws CertificateException
      Creates an instance of this elements data from a DOM element
      Parameters:
      element - xml element providing content data
      Throws:
      CertificateException - content validation error
    • getElement

      protected abstract Element getElement(Document document)
      Gets a DOM element from the element data fields
      Parameters:
      document - the document this element shall belong to
      Returns:
      DOM element populated with the field data of this object
    • validate

      protected abstract void validate() throws CertificateException
      Validates the data fields of this object to assert that it meets basic content requirements
      Throws:
      CertificateException - validation errors
    • getSingleElement

      public static Element getSingleElement(Element parent, String namespaceUri, String elementName)
      Get the first available element from a parent element matching specified name parameters
      Parameters:
      parent - the parent element
      namespaceUri - name space URI for the requested element
      elementName - the name of the requested element
      Returns:
      the first available element matching the name criteria or null if no such element exists in the parent element
    • getElements

      public static List<Element> getElements(Element parent, String namespaceUri, String elementName)
      Get elements from parent element that meets name requirements
      Parameters:
      parent - the parent element
      namespaceUri - name space URI for the requested element
      elementName - the name of the requested elements
      Returns:
      all available elements matching the name criteria or null if no such element exists in the parent element
    • setAttribute

      public static void setAttribute(Element element, String name, String value)
      Sets an XML element attribute
      Parameters:
      element - the element where the attribute should be added
      name - name of the attribute
      value - value of the attribute
    • setAttribute

      public static void setAttribute(Element element, String name, String value, String namespaceUri)
      Sets an XML element attribute with namespace URI declaration
      Parameters:
      element - the element where the attribute should be added
      name - name of the attribute
      value - value of the attribute
      namespaceUri - name space URI of the attribute
    • getAttributeValue

      public static String getAttributeValue(Element element, String name)
      Get the attribute value of an element attribute
      Parameters:
      element - the element holding the attribute value
      name - name of the attribute
      Returns:
      attribute value or null if no such attribute is present with a non-empty value
    • getAttributeValue

      public static String getAttributeValue(Element element, String name, String namespaceUri)
      Get the attribute value of an element attribute supporting a defined name space URI
      Parameters:
      element - the element holding the attribute value
      name - name of the attribute
      namespaceUri - name space URI of the attribute
      Returns:
      attribute value or null if no such attribute is present with a non-empty value
    • getOtherAttributes

      public static List<Attr> getOtherAttributes(Element element, List<String> excludeList)
      Get all attributes of an element that is not listed in an excludeList. This is used to locate extension attributes with any declaration that are not part of the defined set.
      Parameters:
      element - element holding attributes
      excludeList - list of attribute names that should be excluded from the result list
      Returns:
      list of attributes not present in the exclude list
    • adoptElements

      public static void adoptElements(Element adoptingElement, Document document, List<Element> toBeAdoptedList)
      Adopting a list of elements in a document and adding them to a specific element
      Parameters:
      adoptingElement - the element where the adopted elements should be added
      document - document adopting the elements
      toBeAdoptedList - list of elements to be adopted and added to the adopting element
    • adoptAttributes

      public static void adoptAttributes(Element adoptingElement, Document document, List<Attr> toBeAdoptedList)
      Adopting a list of attribute nodes in an element
      Parameters:
      adoptingElement - the element where the provided attributes should be added
      document - document adopting the attribute nodes
      toBeAdoptedList - list of attributes to be adopted and added
    • instantToString

      public static String instantToString(Instant instant)
      Converts an Instant time to an XML formatted xs:dateTime value
      Parameters:
      instant - time to be converted
      Returns:
      XML string formatted as xs:dateTime
    • parseTime

      public static Instant parseTime(String xmlTimeStr)
      Converts an XML xs:dateTime string to Instant
      Parameters:
      xmlTimeStr - string expression of an xs:dateTime value
      Returns:
      Instant object