Search in sources :

Example 1 with XSBase64Binary

use of org.opensaml.xml.schema.XSBase64Binary in project OpenAttestation by OpenAttestation.

the class SamlGenerator method createBase64BinaryAttribute.

/**
         * Creates a base64-encoded attribute
         * @param name
         * @param value
         * @return
         * @throws ConfigurationException 
         */
private Attribute createBase64BinaryAttribute(String name, byte[] value) throws ConfigurationException {
    SAMLObjectBuilder attrBuilder = (SAMLObjectBuilder) builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
    Attribute attr = (Attribute) attrBuilder.buildObject();
    attr.setName(name);
    XMLObjectBuilder xmlBuilder = builderFactory.getBuilder(XSBase64Binary.TYPE_NAME);
    XSBase64Binary attrValue = (XSBase64Binary) xmlBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSBase64Binary.TYPE_NAME);
    attrValue.setValue(Base64.encodeBase64String(value));
    attr.getAttributeValues().add(attrValue);
    return attr;
}
Also used : XSBase64Binary(org.opensaml.xml.schema.XSBase64Binary) SAMLObjectBuilder(org.opensaml.common.SAMLObjectBuilder) Attribute(org.opensaml.saml2.core.Attribute) XMLObjectBuilder(org.opensaml.xml.XMLObjectBuilder)

Aggregations

SAMLObjectBuilder (org.opensaml.common.SAMLObjectBuilder)1 Attribute (org.opensaml.saml2.core.Attribute)1 XMLObjectBuilder (org.opensaml.xml.XMLObjectBuilder)1 XSBase64Binary (org.opensaml.xml.schema.XSBase64Binary)1