* Translate a list of CXF AlgorithmSuite objects into a single WSS4J AlgorithmSuite object
*/
private AlgorithmSuite translateAlgorithmSuites(
List<org.apache.wss4j.policy.model.AlgorithmSuite> algorithmSuites
) {
AlgorithmSuite algorithmSuite = null;
for (org.apache.wss4j.policy.model.AlgorithmSuite cxfAlgorithmSuite
: algorithmSuites) {
if (cxfAlgorithmSuite == null) {
continue;
}
// Translate into WSS4J's AlgorithmSuite class
if (algorithmSuite == null) {
algorithmSuite = new AlgorithmSuite();
}
AlgorithmSuiteType algorithmSuiteType = cxfAlgorithmSuite.getAlgorithmSuiteType();
// Set asymmetric key lengths
if (algorithmSuite.getMaximumAsymmetricKeyLength()
< algorithmSuiteType.getMaximumAsymmetricKeyLength()) {
algorithmSuite.setMaximumAsymmetricKeyLength(
algorithmSuiteType.getMaximumAsymmetricKeyLength());
}
if (algorithmSuite.getMinimumAsymmetricKeyLength()
> algorithmSuiteType.getMinimumAsymmetricKeyLength()) {
algorithmSuite.setMinimumAsymmetricKeyLength(
algorithmSuiteType.getMinimumAsymmetricKeyLength());
}
// Set symmetric key lengths
if (algorithmSuite.getMaximumSymmetricKeyLength()
< algorithmSuiteType.getMaximumSymmetricKeyLength()) {
algorithmSuite.setMaximumSymmetricKeyLength(
algorithmSuiteType.getMaximumSymmetricKeyLength());
}
if (algorithmSuite.getMinimumSymmetricKeyLength()
> algorithmSuiteType.getMinimumSymmetricKeyLength()) {
algorithmSuite.setMinimumSymmetricKeyLength(
algorithmSuiteType.getMinimumSymmetricKeyLength());
}
algorithmSuite.addEncryptionMethod(algorithmSuiteType.getEncryption());
algorithmSuite.addKeyWrapAlgorithm(algorithmSuiteType.getSymmetricKeyWrap());
algorithmSuite.addKeyWrapAlgorithm(algorithmSuiteType.getAsymmetricKeyWrap());
algorithmSuite.addSignatureMethod(cxfAlgorithmSuite.getAsymmetricSignature());
algorithmSuite.addSignatureMethod(cxfAlgorithmSuite.getSymmetricSignature());
algorithmSuite.addDigestAlgorithm(algorithmSuiteType.getDigest());
algorithmSuite.addC14nAlgorithm(cxfAlgorithmSuite.getC14n().getValue());
algorithmSuite.addTransformAlgorithm(cxfAlgorithmSuite.getC14n().getValue());
algorithmSuite.addTransformAlgorithm(SPConstants.STRT10);
algorithmSuite.addTransformAlgorithm(WSConstants.NS_XMLDSIG_ENVELOPED_SIGNATURE);
algorithmSuite.addTransformAlgorithm(WSConstants.SWA_ATTACHMENT_CONTENT_SIG_TRANS);
algorithmSuite.addTransformAlgorithm(WSConstants.SWA_ATTACHMENT_COMPLETE_SIG_TRANS);
algorithmSuite.addDerivedKeyAlgorithm(SPConstants.P_SHA1);
algorithmSuite.addDerivedKeyAlgorithm(SPConstants.P_SHA1_L128);
}
return algorithmSuite;
}