for (Object object : xmlSignature.getObjects()) {
if (object instanceof XMLObject) {
XMLObject xmlObject = (XMLObject)object;
for (Object xmlStructure : xmlObject.getContent()) {
if (xmlStructure instanceof Manifest) {
throw new WSSecurityException(
WSSecurityException.INVALID_SECURITY, "R5403"
);
}
}
}
}
// Check the c14n algorithm
String c14nMethod =
xmlSignature.getSignedInfo().getCanonicalizationMethod().getAlgorithm();
if (!WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(c14nMethod)) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "badC14nAlgo");
}
// Not allowed HMAC OutputLength
AlgorithmParameterSpec parameterSpec =
xmlSignature.getSignedInfo().getSignatureMethod().getParameterSpec();
if (parameterSpec instanceof HMACParameterSpec) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "R5401");
}
// Must have InclusiveNamespaces with a PrefixList
/*
parameterSpec =
xmlSignature.getSignedInfo().getCanonicalizationMethod().getParameterSpec();
if (!(parameterSpec instanceof ExcC14NParameterSpec)) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "R5406");
}
*/
// Check References
for (Object refObject : xmlSignature.getSignedInfo().getReferences()) {
Reference reference = (Reference)refObject;
if (reference.getTransforms().isEmpty()) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "R5416");
}
for (int i = 0; i < reference.getTransforms().size(); i++) {
Transform transform = (Transform)reference.getTransforms().get(i);
String algorithm = transform.getAlgorithm();
if (!(WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(algorithm)
|| STRTransform.TRANSFORM_URI.equals(algorithm)
|| WSConstants.NS_XMLDSIG_FILTER2.equals(algorithm)
|| WSConstants.NS_XMLDSIG_ENVELOPED_SIGNATURE.equals(algorithm)
|| WSConstants.SWA_ATTACHMENT_COMPLETE_SIG_TRANS.equals(algorithm)
|| WSConstants.SWA_ATTACHMENT_CONTENT_SIG_TRANS.equals(algorithm))) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "R5423");
}
if (i == (reference.getTransforms().size() - 1)
&& (!(WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(algorithm)
|| STRTransform.TRANSFORM_URI.equals(algorithm)
|| WSConstants.SWA_ATTACHMENT_COMPLETE_SIG_TRANS.equals(algorithm)
|| WSConstants.SWA_ATTACHMENT_CONTENT_SIG_TRANS.equals(algorithm)))) {
throw new WSSecurityException(WSSecurityException.INVALID_SECURITY, "R5412");
}
/*if (WSConstants.C14N_EXCL_OMIT_COMMENTS.equals(algorithm)) {
parameterSpec = transform.getParameterSpec();
if (!(parameterSpec instanceof ExcC14NParameterSpec)) {