use of org.opensaml.xml.XMLObjectBuilder in project OpenAttestation by OpenAttestation.
the class SamlGenerator method createStringAttribute.
// create the host attributes
/**
* An attribute can be multi-valued, but this method builds a single-valued
* String attribute such as FirstName=John or IPAddress=1.2.3.4
* @param name
* @param value
* @return
* @throws ConfigurationException
*/
private Attribute createStringAttribute(String name, String value) throws ConfigurationException {
SAMLObjectBuilder attrBuilder = (SAMLObjectBuilder) builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
Attribute attr = (Attribute) attrBuilder.buildObject();
attr.setName(name);
XMLObjectBuilder xmlBuilder = builderFactory.getBuilder(XSString.TYPE_NAME);
XSString attrValue = (XSString) xmlBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
attrValue.setValue(value);
attr.getAttributeValues().add(attrValue);
return attr;
}
use of org.opensaml.xml.XMLObjectBuilder 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;
}
use of org.opensaml.xml.XMLObjectBuilder in project OpenAttestation by OpenAttestation.
the class SamlGenerator method createBooleanAttribute.
/**
* This method builds a single-valued boolean attribute such as isTrusted=true
* @param name
* @param value
* @return
* @throws ConfigurationException
*/
private Attribute createBooleanAttribute(String name, boolean value) throws ConfigurationException {
SAMLObjectBuilder attrBuilder = (SAMLObjectBuilder) builderFactory.getBuilder(Attribute.DEFAULT_ELEMENT_NAME);
Attribute attr = (Attribute) attrBuilder.buildObject();
attr.setName(name);
XMLObjectBuilder xmlBuilder = builderFactory.getBuilder(XSAny.TYPE_NAME);
XSAny attrValue = (XSAny) xmlBuilder.buildObject(AttributeValue.DEFAULT_ELEMENT_NAME, XSAny.TYPE_NAME);
attrValue.setTextContent(value ? "true" : "false");
attr.getAttributeValues().add(attrValue);
return attr;
}
Aggregations