Search in sources :

Example 1 with NoAlternativesOperationSimpleService

use of org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService in project cxf by apache.

the class JavaFirstPolicyServiceTest method testNoAltOperationClientCertPolicy.

@Test
public void testNoAltOperationClientCertPolicy() {
    System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
    ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslcertclient.xml" });
    NoAlternativesOperationSimpleService simpleService = clientContext.getBean("NoAlternativesOperationSimpleServiceClient", NoAlternativesOperationSimpleService.class);
    try {
        simpleService.doStuff();
        fail("Expected exception as no credentials");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    WSS4JOutInterceptor wssOut = addToClient(simpleService);
    wssOut.setProperties(getNoPasswordProperties("alice"));
    simpleService.doStuff();
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    try {
        simpleService.doStuff();
        fail("Expected exception as password not allowed");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getNoPasswordProperties("alice"));
    try {
        simpleService.ping();
        fail("Expected exception as no password");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    simpleService.ping();
    clientContext.close();
}
Also used : NoAlternativesOperationSimpleService(org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Test(org.junit.Test)

Example 2 with NoAlternativesOperationSimpleService

use of org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService in project cxf by apache.

the class JavaFirstPolicyServiceTest method testNoAltOperationNoClientCertPolicy.

@Test
public void testNoAltOperationNoClientCertPolicy() {
    System.setProperty("testutil.ports.JavaFirstPolicyServer.3", PORT3);
    ClassPathXmlApplicationContext clientContext = new ClassPathXmlApplicationContext(new String[] { "org/apache/cxf/systest/ws/policy/sslnocertclient.xml" });
    NoAlternativesOperationSimpleService simpleService = clientContext.getBean("NoAlternativesOperationSimpleServiceClient", NoAlternativesOperationSimpleService.class);
    try {
        simpleService.doStuff();
        fail("Expected exception as no credentials");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    WSS4JOutInterceptor wssOut = addToClient(simpleService);
    wssOut.setProperties(getNoPasswordProperties("alice"));
    try {
        simpleService.doStuff();
        fail("Expected exception as no password and no client cert");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    try {
        simpleService.doStuff();
        fail("Expected exception as no client cert and password not allowed");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getNoPasswordProperties("alice"));
    try {
        simpleService.ping();
        fail("Expected exception as no password");
    } catch (SOAPFaultException e) {
        assertTrue(true);
    }
    wssOut.setProperties(getPasswordProperties("alice", "password"));
    simpleService.ping();
    clientContext.close();
}
Also used : NoAlternativesOperationSimpleService(org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) Test(org.junit.Test)

Aggregations

SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 NoAlternativesOperationSimpleService (org.apache.cxf.systest.ws.policy.javafirst.NoAlternativesOperationSimpleService)2 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)2 Test (org.junit.Test)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2