/** {@inheritDoc} */
protected void marshallAttributes(XMLObject xmlObject, Element domElement) throws MarshallingException {
KeyDescriptor keyDescriptor = (KeyDescriptor) xmlObject;
if (keyDescriptor.getUse() != null) {
UsageType use = keyDescriptor.getUse();
// UsageType enum contains more values than are allowed by SAML 2 schema
if (use.equals(UsageType.SIGNING) || use.equals(UsageType.ENCRYPTION)) {
domElement.setAttribute(KeyDescriptor.USE_ATTRIB_NAME, use.toString().toLowerCase());
} else if (use.equals(UsageType.UNSPECIFIED)) {
// emit nothing for unspecified - this is semantically equivalent to non-existent attribute
} else {
// Just in case values are unknowingly added to UsageType in the future...
throw new MarshallingException("KeyDescriptor had illegal value for use attribute: " + use.toString());
}
}
}