QName definitionType = getQName(eachDefinitionElement);
if (TIMESTAMP_ELEMENT_QNAME.equals(definitionType)) {
if (!timestampFound) {
TimestampPolicy timestampPolicy = new TimestampPolicy();
readTimestampSettings(timestampPolicy, eachDefinitionElement);
applyDefaults(timestampPolicy, senderEnableDynamicPolicy);
declarations.senderSettings().append(timestampPolicy);
timestampFound = true;
} else {
log.log(Level.SEVERE,
"WSS0516.duplicate.configuration.element",
new Object[] {
definitionType, configData.getLocalName()});
throw new IllegalStateException(
"Duplicate Timestamp element");
}
} else if (ENCRYPT_OPERATION_ELEMENT_QNAME.equals(definitionType)) {
EncryptionPolicy encryptionPolicy = new EncryptionPolicy();
readEncryptionSettings(encryptionPolicy, eachDefinitionElement);
applyDefaults(encryptionPolicy, senderEnableDynamicPolicy);
declarations.senderSettings().append(encryptionPolicy);
} else if (SIGN_OPERATION_ELEMENT_QNAME.equals(definitionType)) {
SignaturePolicy signaturePolicy = new SignaturePolicy();
readSigningSettings(signaturePolicy, eachDefinitionElement, senderEnableDynamicPolicy);
//declarations.senderSettings().append(signaturePolicy);
//added for BackwardCompatibility with XWSS1.1, the xmlsec in XWSS11 cannot
//accept PrefixList in CanonicalizationMethod parameters
SignaturePolicy.FeatureBinding fb =
(SignaturePolicy.FeatureBinding)signaturePolicy.getFeatureBinding();
if (fb != null) {
fb.isBSP(senderBSPFlag);
}
//end of XWSS11 BC fix
String includeTimeStamp =
eachDefinitionElement.getAttribute(INCLUDE_TIMESTAMP_ATTRIBUTE_NAME);
boolean timeStamp = getBooleanValue(includeTimeStamp);
if (timeStamp && !hasTimestampSiblingPolicy(eachDefinitionElement)) {
//System.out.println("Adding from SIGN");
TimestampPolicy t = new TimestampPolicy();
t.setMaxClockSkew(Timestamp.MAX_CLOCK_SKEW);
t.setTimestampFreshness(Timestamp.TIMESTAMP_FRESHNESS_LIMIT);
applyDefaults(t, senderEnableDynamicPolicy);
declarations.senderSettings().append(t);
}
declarations.senderSettings().append(signaturePolicy);
} else if (
USERNAME_PASSWORD_AUTHENTICATION_ELEMENT_QNAME.
equals(definitionType)) {
try {
AuthenticationTokenPolicy utBinding =
new AuthenticationTokenPolicy();
AuthenticationTokenPolicy.UsernameTokenBinding
featureBinding =
(AuthenticationTokenPolicy.UsernameTokenBinding)
utBinding.newUsernameTokenFeatureBinding();
featureBinding.newTimestampFeatureBinding();
readUsernamePasswordSettings(featureBinding, eachDefinitionElement);
applyDefaults(featureBinding, senderEnableDynamicPolicy);
declarations.senderSettings().append(utBinding);
} catch (PolicyGenerationException pge) {
// log
throw new IllegalStateException(pge.getMessage());
}
} else if (SAML_ELEMENT_QNAME.equals(definitionType)) {
try {
AuthenticationTokenPolicy samlBinding =
new AuthenticationTokenPolicy();
AuthenticationTokenPolicy.SAMLAssertionBinding
featureBinding =
(AuthenticationTokenPolicy.SAMLAssertionBinding)
samlBinding.newSAMLAssertionFeatureBinding();
readSAMLTokenSettings(
featureBinding, eachDefinitionElement);
applyDefaults(featureBinding, senderEnableDynamicPolicy);
declarations.senderSettings().append(samlBinding);
} catch (PolicyGenerationException pge) {
// log
throw new IllegalStateException(pge.getMessage());
}
} else if (SIGNATURE_REQUIREMENT_ELEMENT_QNAME.equals(
definitionType)) {
SignaturePolicy signaturePolicy = new SignaturePolicy();
readVerifySettings(signaturePolicy, eachDefinitionElement,receiverBSPFlag, receiverEnableDynamicPolicy);
declarations.receiverSettings().append(signaturePolicy);
String requireTimeStamp =
eachDefinitionElement.getAttribute(TIMESTAMP_REQUIRED_ATTRIBUTE_NAME);
boolean timeStamp = getBooleanValue(requireTimeStamp);
if (timeStamp && !hasTimestampSiblingPolicy(eachDefinitionElement)) {
//System.out.println("Adding from RequireSignature");
TimestampPolicy t = new TimestampPolicy();
//t.setMaxClockSkew(Timestamp.MAX_CLOCK_SKEW);
//t.setTimestampFreshness(Timestamp.TIMESTAMP_FRESHNESS_LIMIT);
applyReceiverDefaults(t, receiverBSPFlag, securityHandlerClass, receiverEnableDynamicPolicy);
declarations.receiverSettings().append(t);
}
} else if (ENCRYPTION_REQUIREMENT_ELEMENT_QNAME.equals(
definitionType)) {
EncryptionPolicy encryptionPolicy = new EncryptionPolicy();
readDecryptionSettings(encryptionPolicy, eachDefinitionElement);
applyReceiverDefaults(encryptionPolicy, receiverBSPFlag, receiverEnableDynamicPolicy);
declarations.receiverSettings().append(encryptionPolicy);
} else if (USERNAMETOKEN_REQUIREMENT_ELEMENT_QNAME.equals(
definitionType)) {
try {
AuthenticationTokenPolicy utBinding =
new AuthenticationTokenPolicy();
AuthenticationTokenPolicy.UsernameTokenBinding
featureBinding =
(AuthenticationTokenPolicy.UsernameTokenBinding)
utBinding.newUsernameTokenFeatureBinding();
featureBinding.newTimestampFeatureBinding();
readUsernamePasswordRequirementSettings(
featureBinding, eachDefinitionElement);
applyReceiverDefaults(featureBinding, receiverBSPFlag, securityHandlerClass, receiverEnableDynamicPolicy);
declarations.receiverSettings().append(utBinding);
if (MessageConstants.debug) {
log.log(Level.FINEST, "Added usernameToken Requirement ...." + featureBinding);
}
} catch (PolicyGenerationException pge) {
// log
throw new IllegalStateException(pge.getMessage());
}
} else if (TIMESTAMP_REQUIREMENT_ELEMENT_QNAME.equals(
definitionType)) {
TimestampPolicy timestampPolicy = new TimestampPolicy();
readTimestampRequirementSettings(
timestampPolicy, eachDefinitionElement);
applyReceiverDefaults(timestampPolicy, receiverBSPFlag, securityHandlerClass, receiverEnableDynamicPolicy);
declarations.receiverSettings().append(timestampPolicy);