Package org.apache.wss4j.dom.common

Examples of org.apache.wss4j.dom.common.CustomHandler


        msgContext.put("password", "security");
        reqData.setMsgContext(msgContext);
        reqData.setUsername("16c73ab6-b892-458f-abf5-2f875f74882e");
       
        Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
        CustomHandler handler = new CustomHandler();
        HandlerAction action = new HandlerAction(WSConstants.SIGN);
        handler.send(
            doc,
            reqData,
            Collections.singletonList(action),
            true
        );
        if (LOG.isDebugEnabled()) {
            LOG.debug("After Signing....");
            String outputString =
                XMLUtils.PrettyDocumentToString(doc);
            LOG.debug(outputString);
        }

        //
        // Verify the inbound request, and create a response with a Signature Confirmation
        //
        List<WSSecurityEngineResult> results = verify(doc);
        doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
        msgContext = (java.util.Map<String, Object>)reqData.getMsgContext();
        WSHandlerResult handlerResult = new WSHandlerResult(null, results);
        List<WSHandlerResult> receivedResults = new ArrayList<WSHandlerResult>();
        receivedResults.add(handlerResult);
        msgContext.put(WSHandlerConstants.RECV_RESULTS, receivedResults);
        handler.send(
            doc,
            reqData,
            Collections.singletonList(action),
            false
        );
        String outputString =
            XMLUtils.PrettyDocumentToString(doc);
        if (LOG.isDebugEnabled()) {
            LOG.debug("Signature Confirmation response....");
            LOG.debug(outputString);
        }
       
        //
        // Verify the SignatureConfirmation response
        //
        results = verify(doc);
        WSSecurityEngineResult scResult =
            WSSecurityUtil.fetchActionResult(results, WSConstants.SC);
        assertTrue(scResult != null);
        assertTrue(scResult.get(WSSecurityEngineResult.TAG_SIGNATURE_CONFIRMATION) != null);
        handler.signatureConfirmation(reqData, results);
    }
View Full Code Here


    /**
     */
    @org.junit.Test
    public void
    testOrder() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results = new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SIGN)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.UT);
        actions.add(WSConstants.TS);
        actions.add(WSConstants.SIGN);
       
        assertTrue (handler.checkResults(results, actions));
        assertTrue (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testReverseOrder() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results = new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.SIGN)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.UT);
        actions.add(WSConstants.TS);
        actions.add(WSConstants.SIGN);
       
        assertFalse (handler.checkResults(results, actions));
        assertTrue (handler.checkResultsAnyOrder(results, actions));
        assertTrue (results.size() == 4 && actions.size() == 3);
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testMixedOrder() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SIGN)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.UT);
        actions.add(WSConstants.TS);
        actions.add(WSConstants.SIGN);
       
        assertFalse (handler.checkResults(results, actions));
        assertTrue (handler.checkResultsAnyOrder(results, actions));
        assertFalse (actions.isEmpty());
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testMixedOrder2() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SIGN)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.SIGN);
        actions.add(WSConstants.UT);
        actions.add(WSConstants.TS);
       
        assertFalse (handler.checkResults(results, actions));
        assertTrue (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testMissingResult() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.TS);
        actions.add(WSConstants.UT);
        actions.add(WSConstants.SIGN);
       
        assertFalse (handler.checkResults(results, actions));
        assertFalse (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testMissingAction() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SIGN)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.SC)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.TS);
        actions.add(WSConstants.UT);
       
        assertFalse (handler.checkResults(results, actions));
        assertFalse (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testNoResult() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.TS);
       
        assertFalse (handler.checkResults(results, actions));
        assertFalse (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testNoAction() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.TS)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
       
        assertFalse (handler.checkResults(results, actions));
        assertFalse (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

    /**
     */
    @org.junit.Test
    public void
    testMultipleIdenticalResults() throws Exception {
        CustomHandler handler = new CustomHandler();
       
        java.util.List<WSSecurityEngineResult> results =
            new java.util.ArrayList<WSSecurityEngineResult>();
        results.add(
            new WSSecurityEngineResult(WSConstants.ENCR)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.UT)
        );
        results.add(
            new WSSecurityEngineResult(WSConstants.ENCR)
        );
       
        java.util.List<Integer> actions = new java.util.ArrayList<Integer>();
        actions.add(WSConstants.ENCR);
        actions.add(WSConstants.UT);
        actions.add(WSConstants.UT);
       
        assertFalse (handler.checkResults(results, actions));
        assertFalse (handler.checkResultsAnyOrder(results, actions));
    }
View Full Code Here

TOP

Related Classes of org.apache.wss4j.dom.common.CustomHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.