return new WSSSignatureVerifier(signatureType, inputProcessorChain.getSecurityContext(), securityProperties);
}
private void checkBSPCompliance(InputProcessorChain inputProcessorChain, SignatureType signatureType) throws WSSecurityException {
String algorithm = signatureType.getSignedInfo().getSignatureMethod().getAlgorithm();
final WSInboundSecurityContext securityContext = (WSInboundSecurityContext) inputProcessorChain.getSecurityContext();
if (!(WSSConstants.NS_XMLDSIG_HMACSHA1.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_RSASHA1.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_HMACSHA256.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_HMACSHA384.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_HMACSHA512.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_RSASHA256.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_RSASHA384.equals(algorithm)
|| WSSConstants.NS_XMLDSIG_RSASHA512.equals(algorithm))) {
// Weakening this rule a bit to allow > SHA-1
securityContext.handleBSPRule(BSPRule.R5421);
}
BigInteger hmacOutputLength = XMLSecurityUtils.getQNameType(
signatureType.getSignedInfo().getSignatureMethod().getContent(),
WSSConstants.TAG_dsig_HMACOutputLength);
if (hmacOutputLength != null) {
securityContext.handleBSPRule(BSPRule.R5401);
}
List<Object> keyInfoContent = signatureType.getKeyInfo().getContent();
if (keyInfoContent.size() != 1) {
securityContext.handleBSPRule(BSPRule.R5402);
}
SecurityTokenReferenceType securityTokenReferenceType = XMLSecurityUtils.getQNameType(keyInfoContent,
WSSConstants.TAG_wsse_SecurityTokenReference);
if (securityTokenReferenceType == null) {
securityContext.handleBSPRule(BSPRule.R5417);
}
Iterator<ObjectType> objectTypeIterator = signatureType.getObject().iterator();
while (objectTypeIterator.hasNext()) {
ObjectType objectType = objectTypeIterator.next();
ManifestType manifestType = XMLSecurityUtils.getQNameType(objectType.getContent(), WSSConstants.TAG_dsig_Manifest);
if (manifestType != null) {
securityContext.handleBSPRule(BSPRule.R5403);
}
}
CanonicalizationMethodType canonicalizationMethodType = signatureType.getSignedInfo().getCanonicalizationMethod();
if (!WSSConstants.NS_C14N_EXCL.equals(canonicalizationMethodType.getAlgorithm())) {
securityContext.handleBSPRule(BSPRule.R5404);
}
InclusiveNamespaces inclusiveNamespacesType = XMLSecurityUtils.getQNameType(canonicalizationMethodType.getContent(),
WSSConstants.TAG_c14nExcl_InclusiveNamespaces);
if (inclusiveNamespacesType != null && inclusiveNamespacesType.getPrefixList().size() == 0) {
securityContext.handleBSPRule(BSPRule.R5406);
}
}