int index = uri.lastIndexOf("/");
String attrName = uri.substring(index + 1, uri.length());
String attrNamespace = uri.substring(0, index);
Attribute attribute = (Attribute) buildXMLObject(Attribute.DEFAULT_ELEMENT_NAME);
attribute.setName(attrName);
attribute.setNameFormat(attrNamespace);
XMLObjectBuilderFactory builderFactory = Configuration.getBuilderFactory();
// TODO remove this else if condition after WSO2 IS supports claim
// types properly
if (claim.getUri().equals(IdentityConstants.CLAIM_PPID)) {
XSBase64BinaryBuilder ppidValueBuilder = (XSBase64BinaryBuilder) builderFactory
.getBuilder(XSBase64Binary.TYPE_NAME);
XSBase64Binary ppidValue = ppidValueBuilder.buildObject(
AttributeValue.DEFAULT_ELEMENT_NAME, XSBase64Binary.TYPE_NAME);
ppidValue.setValue(claim.getValue());
attribute.getAttributeValues().add(ppidValue);
} else {
XSStringBuilder attributeValueBuilder = (XSStringBuilder) builderFactory
.getBuilder(XSString.TYPE_NAME);
XSString stringValue = attributeValueBuilder.buildObject(
AttributeValue.DEFAULT_ELEMENT_NAME, XSString.TYPE_NAME);
stringValue.setValue(claim.getValue());
attribute.getAttributeValues().add(stringValue);
}
attributeStmt.getAttributes().add(attribute);
}
}