Search in sources :

Example 1 with XMLObject

use of org.opensaml.xml.XMLObject in project OpenAttestation by OpenAttestation.

the class TrustAssertion method readAssertion.

private Assertion readAssertion(Element document) throws UnmarshallingException {
    log.debug("Reading assertion from element {}", document.getTagName());
    UnmarshallerFactory factory = Configuration.getUnmarshallerFactory();
    Unmarshaller unmarshaller = factory.getUnmarshaller(document);
    // UnmarshallingException
    XMLObject xml = unmarshaller.unmarshall(document);
    Assertion samlAssertion = (Assertion) xml;
    return samlAssertion;
}
Also used : Assertion(org.opensaml.saml2.core.Assertion) XMLObject(org.opensaml.xml.XMLObject) UnmarshallerFactory(org.opensaml.xml.io.UnmarshallerFactory) Unmarshaller(org.opensaml.xml.io.Unmarshaller)

Example 2 with XMLObject

use of org.opensaml.xml.XMLObject in project OpenAttestation by OpenAttestation.

the class TrustAssertion method populateAssertionMap.

/**
     * Sample assertion statements that may appear in the XML: Trusted (boolean)
     * Trusted_BIOS (boolean) Trusted_VMM (boolean) BIOS_Name (string)
     * BIOS_Version (string) BIOS_OEM (string) VMM_Name (string) VMM_Version
     * (string) VMM_OSName (string) VMM_OSVersion (string) The BIOS_* entries
     * will only appear if Trusted_BIOS is true The VMM_* entries will only
     * appear if Trusted_VMM is true
     */
private void populateAssertionMap() {
    for (Statement statement : assertion.getStatements()) {
        if (statement instanceof AttributeStatement) {
            HashMap<String, String> assertionMap = new HashMap<String, String>();
            HostTrustAssertion hostTrustAssertion = new HostTrustAssertion(assertion, assertionMap);
            log.debug("attributes.size: " + ((AttributeStatement) statement).getAttributes().size());
            for (Attribute attribute : ((AttributeStatement) statement).getAttributes()) {
                String attributeValue = null;
                for (XMLObject value : attribute.getAttributeValues()) {
                    if (value instanceof XSAny) {
                        // boolean attributes are the text "true" or "false"
                        attributeValue = (((XSAny) value).getTextContent());
                    }
                    if (value instanceof XSString) {
                        attributeValue = (((XSString) value).getValue());
                    }
                }
                assertionMap.put(attribute.getName(), attributeValue);
            }
            hostAssertionMap.put(assertionMap.get("Host_Name"), hostTrustAssertion);
        }
    }
}
Also used : HashMap(java.util.HashMap) Attribute(org.opensaml.saml2.core.Attribute) Statement(org.opensaml.saml2.core.Statement) AttributeStatement(org.opensaml.saml2.core.AttributeStatement) AttributeStatement(org.opensaml.saml2.core.AttributeStatement) XMLObject(org.opensaml.xml.XMLObject) XSString(org.opensaml.xml.schema.XSString) XSString(org.opensaml.xml.schema.XSString) XSAny(org.opensaml.xml.schema.XSAny)

Aggregations

XMLObject (org.opensaml.xml.XMLObject)2 HashMap (java.util.HashMap)1 Assertion (org.opensaml.saml2.core.Assertion)1 Attribute (org.opensaml.saml2.core.Attribute)1 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)1 Statement (org.opensaml.saml2.core.Statement)1 Unmarshaller (org.opensaml.xml.io.Unmarshaller)1 UnmarshallerFactory (org.opensaml.xml.io.UnmarshallerFactory)1 XSAny (org.opensaml.xml.schema.XSAny)1 XSString (org.opensaml.xml.schema.XSString)1