Search in sources :

Example 1 with SignatureActionToken

use of org.apache.wss4j.common.SignatureActionToken in project cxf by apache.

the class SecurityActionTokenTest method testSignature.

@Test
public void testSignature() throws Exception {
    SignatureActionToken actionToken = new SignatureActionToken();
    actionToken.setCryptoProperties("outsecurity.properties");
    actionToken.setUser("myalias");
    List<HandlerAction> actions = Collections.singletonList(new HandlerAction(WSConstants.SIGN, actionToken));
    Map<String, Object> outProperties = new HashMap<>();
    outProperties.put(WSHandlerConstants.HANDLER_ACTIONS, actions);
    outProperties.put(ConfigurationConstants.PW_CALLBACK_REF, new TestPwdCallback());
    Map<String, Object> inProperties = new HashMap<>();
    inProperties.put(ConfigurationConstants.ACTION, ConfigurationConstants.SIGNATURE);
    inProperties.put(ConfigurationConstants.SIG_VER_PROP_FILE, "insecurity.properties");
    List<String> xpaths = new ArrayList<>();
    xpaths.add("//wsse:Security");
    xpaths.add("//wsse:Security/ds:Signature");
    List<WSHandlerResult> handlerResults = getResults(makeInvocation(outProperties, xpaths, inProperties));
    WSSecurityEngineResult actionResult = handlerResults.get(0).getActionResults().get(WSConstants.SIGN).get(0);
    X509Certificate certificate = (X509Certificate) actionResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
    assertNotNull(certificate);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WSHandlerResult(org.apache.wss4j.dom.handler.WSHandlerResult) WSSecurityEngineResult(org.apache.wss4j.dom.engine.WSSecurityEngineResult) HandlerAction(org.apache.wss4j.dom.handler.HandlerAction) X509Certificate(java.security.cert.X509Certificate) SignatureActionToken(org.apache.wss4j.common.SignatureActionToken) Test(org.junit.Test)

Aggregations

X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 SignatureActionToken (org.apache.wss4j.common.SignatureActionToken)1 WSSecurityEngineResult (org.apache.wss4j.dom.engine.WSSecurityEngineResult)1 HandlerAction (org.apache.wss4j.dom.handler.HandlerAction)1 WSHandlerResult (org.apache.wss4j.dom.handler.WSHandlerResult)1 Test (org.junit.Test)1