Search in sources :

Example 11 with SAMLObjectBuilder

use of org.opensaml.common.SAMLObjectBuilder in project OpenAttestation by OpenAttestation.

the class SamlGenerator method createAssertion.

/*
        private AttributeStatement createHostAttributes(TxtHost host, ManifestType pcrManifest) throws ConfigurationException {
            AttributeStatement attrStatement = createHostAttributes(host);
            attrStatement.getAttributes().add(createComplexAttribute("Manifest", pcrManifest);

            return attrStatement;
            
        }
        */
/**
         * Creates an assertion with attributes of the host
         * 
         * ID attribute: see section 5.4.2  "References" of http://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf
         * 
         * @param host
         * @return 
         */
private Assertion createAssertion(TxtHost host, X509AttributeCertificate tagCertificate, Map<String, String> vmMetaData) throws ConfigurationException, UnknownHostException {
    // Create the assertion
    SAMLObjectBuilder assertionBuilder = (SAMLObjectBuilder) builderFactory.getBuilder(Assertion.DEFAULT_ELEMENT_NAME);
    Assertion assertion = (Assertion) assertionBuilder.buildObject();
    // ID is arbitrary, only needs to be unique WITHIN THE DOCUMENT, and is required so that the Signature element can refer to it, for example #HostTrustAssertion
    assertion.setID("HostTrustAssertion");
    assertion.setIssuer(createIssuer());
    DateTime now = new DateTime();
    assertion.setIssueInstant(now);
    assertion.setVersion(SAMLVersion.VERSION_20);
    assertion.setSubject(createSubject(host));
    assertion.getAttributeStatements().add(createHostAttributes(host, tagCertificate, vmMetaData));
    return assertion;
}
Also used : SAMLObjectBuilder(org.opensaml.common.SAMLObjectBuilder) Assertion(org.opensaml.saml2.core.Assertion) DateTime(org.joda.time.DateTime)

Aggregations

SAMLObjectBuilder (org.opensaml.common.SAMLObjectBuilder)11 DateTime (org.joda.time.DateTime)3 Attribute (org.opensaml.saml2.core.Attribute)3 XMLObjectBuilder (org.opensaml.xml.XMLObjectBuilder)3 Assertion (org.opensaml.saml2.core.Assertion)2 NameID (org.opensaml.saml2.core.NameID)2 XSString (org.opensaml.xml.schema.XSString)2 UTF8NameValueMicroformat (com.intel.mtwilson.datatypes.UTF8NameValueMicroformat)1 UTF8NameValueSequence (com.intel.mtwilson.datatypes.UTF8NameValueSequence)1 InetAddress (java.net.InetAddress)1 AttributeStatement (org.opensaml.saml2.core.AttributeStatement)1 Issuer (org.opensaml.saml2.core.Issuer)1 Subject (org.opensaml.saml2.core.Subject)1 SubjectConfirmation (org.opensaml.saml2.core.SubjectConfirmation)1 SubjectConfirmationData (org.opensaml.saml2.core.SubjectConfirmationData)1 XSAny (org.opensaml.xml.schema.XSAny)1 XSBase64Binary (org.opensaml.xml.schema.XSBase64Binary)1