use of org.apache.wss4j.dom.str.STRParser.REFERENCE_TYPE 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.str.STRParser.REFERENCE_TYPE 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