Class AbstractDomData
java.lang.Object
se.swedenconnect.cert.extensions.data.saci.AbstractDomData
- Direct Known Subclasses:
Attribute
,AttributeMapping
,AuthContextInfo
,IdAttributes
,SAMLAuthContext
Abstract class providing basics for xml elements that are part of the SAMLAuthContext implementation
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
XML name space URI for the RFC 7773 SAMLAuthContext XML elementstatic final String
XML name space URI for SAML assertion dataprotected boolean
indicates if content validation should be done with strict compliance requirementsstatic final DateTimeFormatter
Formatter for XML date element content -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDomData
(Element element) Constructor for the base Abstract classAbstractDomData
(Element element, boolean strictMode) Constructor for the base Abstract class setting strict mode -
Method Summary
Modifier and TypeMethodDescriptionstatic void
adoptAttributes
(Element adoptingElement, Document document, List<Attr> toBeAdoptedList) Adopting a list of attribute nodes in an elementstatic void
adoptElements
(Element adoptingElement, Document document, List<Element> toBeAdoptedList) Adopting a list of elements in a document and adding them to a specific elementstatic String
getAttributeValue
(Element element, String name) Get the attribute value of an element attributestatic String
getAttributeValue
(Element element, String name, String namespaceUri) Get the attribute value of an element attribute supporting a defined name space URIprotected abstract Element
getElement
(Document document) Gets a DOM element from the element data fieldsgetElements
(Element parent, String namespaceUri, String elementName) Get elements from parent element that meets name requirementsgetOtherAttributes
(Element element, List<String> excludeList) Get all attributes of an element that is not listed in an excludeList.static Element
getSingleElement
(Element parent, String namespaceUri, String elementName) Get the first available element from a parent element matching specified name parametersstatic String
instantToString
(Instant instant) Converts an Instant time to an XML formatted xs:dateTime valuestatic Instant
Converts an XML xs:dateTime string to Instantstatic void
setAttribute
(Element element, String name, String value) Sets an XML element attributestatic void
setAttribute
(Element element, String name, String value, String namespaceUri) Sets an XML element attribute with namespace URI declarationprotected abstract void
setValuesFromElement
(Element element) Creates an instance of this elements data from a DOM elementprotected abstract void
validate()
Validates the data fields of this object to assert that it meets basic content requirements
-
Field Details
-
XML_DATE_TIME_FORMATTER
Formatter for XML date element content -
SACI_NS
XML name space URI for the RFC 7773 SAMLAuthContext XML element- See Also:
-
SAML_ASSERTION_NS
XML name space URI for SAML assertion data- See Also:
-
strictMode
protected boolean strictModeindicates if content validation should be done with strict compliance requirements
-
-
Constructor Details
-
AbstractDomData
Constructor for the base Abstract class- Parameters:
element
- The element holding a SAMLAuthContextExtension extension- Throws:
CertificateException
- content validation error
-
AbstractDomData
Constructor for the base Abstract class setting strict mode- Parameters:
element
- The element holding a SAMLAuthContextExtension extensionstrictMode
- true to strictly enforce content requirement rules- Throws:
CertificateException
- content validation error
-
-
Method Details
-
setValuesFromElement
Creates an instance of this elements data from a DOM element- Parameters:
element
- xml element providing content data- Throws:
CertificateException
- content validation error
-
getElement
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
Validates the data fields of this object to assert that it meets basic content requirements- Throws:
CertificateException
- validation errors
-
getSingleElement
Get the first available element from a parent element matching specified name parameters- Parameters:
parent
- the parent elementnamespaceUri
- name space URI for the requested elementelementName
- 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
Get elements from parent element that meets name requirements- Parameters:
parent
- the parent elementnamespaceUri
- name space URI for the requested elementelementName
- 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
Sets an XML element attribute- Parameters:
element
- the element where the attribute should be addedname
- name of the attributevalue
- value of the attribute
-
setAttribute
Sets an XML element attribute with namespace URI declaration- Parameters:
element
- the element where the attribute should be addedname
- name of the attributevalue
- value of the attributenamespaceUri
- name space URI of the attribute
-
getAttributeValue
Get the attribute value of an element attribute- Parameters:
element
- the element holding the attribute valuename
- name of the attribute- Returns:
- attribute value or null if no such attribute is present with a non-empty value
-
getAttributeValue
Get the attribute value of an element attribute supporting a defined name space URI- Parameters:
element
- the element holding the attribute valuename
- name of the attributenamespaceUri
- name space URI of the attribute- Returns:
- attribute value or null if no such attribute is present with a non-empty value
-
getOtherAttributes
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 attributesexcludeList
- 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 addeddocument
- document adopting the elementstoBeAdoptedList
- 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 addeddocument
- document adopting the attribute nodestoBeAdoptedList
- list of attributes to be adopted and added
-
instantToString
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
Converts an XML xs:dateTime string to Instant- Parameters:
xmlTimeStr
- string expression of an xs:dateTime value- Returns:
- Instant object
-