use of org.apache.wss4j.dom.message.WSSecHeader in project testcases by coheigea.
the class EncryptionAlgorithmBenchmark method doEncryption.
private void doEncryption(String keyTransportAlgorithm, Crypto verifyingCrypto) throws Exception {
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
WSSecEncrypt builder = new WSSecEncrypt(secHeader);
builder.setUserInfo("myservicekey", "skpass");
builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
builder.setKeyEncAlgo(keyTransportAlgorithm);
Document encryptedDoc = builder.build(serviceCrypto);
WSSecurityEngine engine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setWssConfig(WSSConfig.getNewInstance());
data.setDecCrypto(verifyingCrypto);
data.setCallbackHandler(new CommonCallbackHandler());
if (WSConstants.KEYTRANSPORT_RSA15.equals(keyTransportAlgorithm)) {
data.setAllowRSA15KeyTransportAlgorithm(true);
}
Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, "");
Assert.assertNotNull(securityHeader);
WSHandlerResult results = engine.processSecurityHeader(securityHeader, data);
WSSecurityEngineResult actionResult = results.getActionResults().get(WSConstants.ENCR).get(0);
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
}
use of org.apache.wss4j.dom.message.WSSecHeader in project testcases by coheigea.
the class SignatureAlgorithmBenchmark method doSignature.
private void doSignature(String c14nAlgo, boolean addInclusivePrefixes, String digestAlgo, String sigAlgo, Crypto verifyingCrypto) throws Exception {
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
WSSecSignature builder = new WSSecSignature(secHeader);
builder.setUserInfo("myclientkey", "ckpass");
builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
builder.setSigCanonicalization(c14nAlgo);
builder.setDigestAlgo(digestAlgo);
builder.setSignatureAlgorithm(sigAlgo);
builder.setAddInclusivePrefixes(addInclusivePrefixes);
Document signedDoc = builder.build(clientCrypto);
WSSecurityEngine engine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setWssConfig(WSSConfig.getNewInstance());
data.setSigVerCrypto(verifyingCrypto);
data.setSubjectCertConstraints(Collections.singletonList(certConstraint));
List<BSPRule> ignoredRules = new ArrayList<BSPRule>();
ignoredRules.add(BSPRule.R5404);
ignoredRules.add(BSPRule.R5406);
data.setIgnoredBSPRules(ignoredRules);
Element securityHeader = WSSecurityUtil.getSecurityHeader(signedDoc, "");
Assert.assertNotNull(securityHeader);
WSHandlerResult results = engine.processSecurityHeader(securityHeader, data);
WSSecurityEngineResult actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
}
use of org.apache.wss4j.dom.message.WSSecHeader in project testcases by coheigea.
the class EncryptionSerializerBenchmark method doEncryption.
private Document doEncryption(Serializer serializer) throws Exception {
Document doc = StaxUtils.read(new StringReader(SOAPUtil.SAMPLE_SOAP_MSG));
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
WSSecEncrypt builder = new WSSecEncrypt(secHeader);
builder.setUserInfo("myservicekey", "skpass");
builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
builder.setEncryptionSerializer(serializer);
return builder.build(serviceCrypto);
}
use of org.apache.wss4j.dom.message.WSSecHeader in project testcases by coheigea.
the class EncryptionReferenceBenchmark method doEncryption.
private void doEncryption(int identifier, REFERENCE_TYPE referenceType, Crypto verifyingCrypto) throws Exception {
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
WSSecEncrypt builder = new WSSecEncrypt(secHeader);
builder.setUserInfo("myservicekey", "skpass");
builder.setKeyIdentifierType(identifier);
Document encryptedDoc = builder.build(serviceCrypto);
WSSecurityEngine engine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setWssConfig(WSSConfig.getNewInstance());
data.setDecCrypto(verifyingCrypto);
data.setCallbackHandler(new CommonCallbackHandler());
Element securityHeader = WSSecurityUtil.getSecurityHeader(encryptedDoc, "");
Assert.assertNotNull(securityHeader);
WSHandlerResult results = engine.processSecurityHeader(securityHeader, data);
WSSecurityEngineResult actionResult = results.getActionResults().get(WSConstants.ENCR).get(0);
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
REFERENCE_TYPE refType = (REFERENCE_TYPE) actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
Assert.assertTrue(refType == referenceType);
}
use of org.apache.wss4j.dom.message.WSSecHeader in project testcases by coheigea.
the class SignatureReferenceBenchmark method doSignature.
private void doSignature(int identifier, REFERENCE_TYPE referenceType, Crypto verifyingCrypto) throws Exception {
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
WSSecSignature builder = new WSSecSignature(secHeader);
builder.setUserInfo("myclientkey", "ckpass");
builder.setKeyIdentifierType(identifier);
Document signedDoc = builder.build(clientCrypto);
WSSecurityEngine engine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setWssConfig(WSSConfig.getNewInstance());
data.setSigVerCrypto(verifyingCrypto);
data.setSubjectCertConstraints(Collections.singletonList(certConstraint));
Element securityHeader = WSSecurityUtil.getSecurityHeader(signedDoc, "");
Assert.assertNotNull(securityHeader);
WSHandlerResult results = engine.processSecurityHeader(securityHeader, data);
WSSecurityEngineResult actionResult = results.getActionResults().get(WSConstants.SIGN).get(0);
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE));
Assert.assertNotNull(actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE));
REFERENCE_TYPE refType = (REFERENCE_TYPE) actionResult.get(WSSecurityEngineResult.TAG_X509_REFERENCE_TYPE);
Assert.assertTrue(refType == referenceType);
}
Aggregations