/*
*/
private static EncryptionTarget readEncryptionTargetSettings(
Element targetSettings) {
EncryptionTarget target = new EncryptionTarget();
// Read-in the target type attribute
NamedNodeMap targetAttributes = targetSettings.getAttributes();
int attributeCount = targetAttributes.getLength();
String attributeName = null;
for (int index = 0; index < attributeCount; index++) {
Attr targetAttribute = (Attr) targetAttributes.item(index);
attributeName = targetAttribute.getName();
if (TARGET_TYPE_ATTRIBUTE_NAME.equalsIgnoreCase(attributeName)) {
String targetType = targetAttribute.getValue();
// valid values of targetType are xpath, qname, id
if (Target.TARGET_TYPE_VALUE_QNAME.equalsIgnoreCase(targetType)){
target.setType(Target.TARGET_TYPE_VALUE_QNAME);
}else if(Target.TARGET_TYPE_VALUE_XPATH.equalsIgnoreCase(targetType)){
target.setType(Target.TARGET_TYPE_VALUE_XPATH);
}else if(Target.TARGET_TYPE_VALUE_URI.equalsIgnoreCase(targetType)) {
target.setType(Target.TARGET_TYPE_VALUE_URI);
} else {
log.log(Level.SEVERE,
"WSS0519.illegal.attribute.value",
"xwss:Target@Type");
throw new IllegalStateException(targetType
+ " is not a recognized type of Target");
}
} else if
(CONTENT_ONLY_ATTRIBUTE_NAME.equalsIgnoreCase(attributeName)) {
String contentOnly = targetAttribute.getValue();
target.setContentOnly(getBooleanValue(contentOnly));
} else if
(ENFORCE_ATTRIBUTE_NAME.equalsIgnoreCase(attributeName)) {
String enforce_S = targetAttribute.getValue();
boolean enforce = Boolean.valueOf(enforce_S);
target.setEnforce(enforce);
} else if
(VALUE_ATTRIBUTE_NAME.equalsIgnoreCase(attributeName)) {
} else {
log.log(Level.SEVERE,
"WSS0512.illegal.attribute.name",
new Object[]
{attributeName, "xwss:Target"});
throw new IllegalStateException(attributeName
+ " is not a recognized attribute of Target");
}
}
// Read-in the target type attribute
//read value attribute
String targetValue = targetSettings.getAttribute(VALUE_ATTRIBUTE_NAME);
if (targetValue == null ) {
//|| targetValue.equals("")) {
// log
throw new IllegalStateException(
"value attribute of the EncryptionTarget element missing/empty");
}
if (targetValue.startsWith("#"))
targetValue = targetValue.substring(1);
target.setValue(targetValue);
//read any transform child elements
Element eachDefinitionElement = getFirstChildElement(targetSettings);
while (eachDefinitionElement != null) {
QName definitionType = getQName(eachDefinitionElement);
if (TRANSFORM_ELEMENT_QNAME.equals(definitionType)) {
EncryptionTarget.Transform transform =
readEncTransform(eachDefinitionElement);
target.addCipherReferenceTransform(transform);
} else {
log.log(
Level.SEVERE,
"WSS0513.illegal.configuration.element",
definitionType.toString());