Search in sources :

Example 26 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project midpoint by Evolveum.

the class TestWSSecurity method test150GetConfigNoPasswordWrongDigest.

@Test
public void test150GetConfigNoPasswordWrongDigest() throws Exception {
    final String TEST_NAME = "test150GetConfigNoPasswordWrongDigest";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    modelPort = createModelPort(USER_NOPASSWORD_USERNAME, "wrongPassword", WSConstants.PW_DIGEST);
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // WHEN
    try {
        modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, objectHolder, resultHolder);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    tailer.tail();
    assertAuditLoginFailed(tailer, "no credentials in user");
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.testng.annotations.Test)

Example 27 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project midpoint by Evolveum.

the class TestWSSecurity method test121GetConfigAsNobodyWrongPasswordDigest.

@Test
public void test121GetConfigAsNobodyWrongPasswordDigest() throws Exception {
    final String TEST_NAME = "test121GetConfigAsNobodyWrongPasswordDigest";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    modelPort = createModelPort(USER_NOBODY_USERNAME, "wrongNobodyPassword", WSConstants.PW_DIGEST);
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // WHEN
    try {
        modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, objectHolder, resultHolder);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    tailer.tail();
    assertAuditLoginFailed(tailer, "no authorizations");
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.testng.annotations.Test)

Example 28 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project midpoint by Evolveum.

the class TestWSSecurity method test152GetConfigNoPasswordEmptyDigest.

@Test
public void test152GetConfigNoPasswordEmptyDigest() throws Exception {
    final String TEST_NAME = "test152GetConfigNoPasswordEmptyDigest";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    modelPort = createModelPort(USER_NOPASSWORD_USERNAME, " ", WSConstants.PW_DIGEST);
    Holder<ObjectType> objectHolder = new Holder<ObjectType>();
    Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
    // WHEN
    try {
        modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(), null, objectHolder, resultHolder);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    tailer.tail();
    assertAuditLoginFailed(tailer, "no credentials in user");
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) OperationResultType(com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType) Holder(javax.xml.ws.Holder) SystemConfigurationType(com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) Test(org.testng.annotations.Test)

Example 29 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project midpoint by Evolveum.

the class TestWSSecurity method test135ModifyConfigAsDarthAdder.

@Test
public void test135ModifyConfigAsDarthAdder() throws Exception {
    final String TEST_NAME = "test135ModifyConfigAsDarthAdder";
    displayTestTitle(TEST_NAME);
    LogfileTestTailer tailer = createLogTailer();
    ObjectReferenceType ref = new ObjectReferenceType();
    // fake
    ref.setOid("c4e998e6-d903-11e4-9aaf-001e8c717e5b");
    ObjectDeltaListType deltaList = ModelClientUtil.createModificationDeltaList(SystemConfigurationType.class, SystemObjectsType.SYSTEM_CONFIGURATION.value(), "globalSecurityPolicyRef", ModificationTypeType.REPLACE, ref);
    try {
        // WHEN
        modelPort.executeChanges(deltaList, null);
        AssertJUnit.fail("Unexpected success");
    } catch (SOAPFaultException e) {
        assertSoapFault(e, "FailedAuthentication", "could not be authenticated or authorized");
    }
    // THEN
    tailer.tail();
    displayAudit(tailer);
    assertAuditLoginLogout(tailer);
    assertAuditIds(tailer);
    assertAuditOperation(tailer, "MODIFY_OBJECT", OperationResultStatusType.FATAL_ERROR, "not authorized");
    tailer.assertAudit(4);
}
Also used : LogfileTestTailer(com.evolveum.midpoint.test.util.LogfileTestTailer) ObjectReferenceType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) ObjectDeltaListType(com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType) Test(org.testng.annotations.Test)

Example 30 with SOAPFaultException

use of javax.xml.ws.soap.SOAPFaultException in project tomee by apache.

the class CalculatorTest method call.

@Test
public void call() throws MalformedURLException {
    final EJBContainer container = EJBContainer.createEJBContainer(new Properties() {

        {
            setProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE, "true");
            // random port to avoid issue on CI, default is 4204
            setProperty("httpejbd.port", "0");
        }
    });
    // get back the random port
    final int port = Integer.parseInt(SystemInstance.get().getProperty("httpejbd.port"));
    // normal call
    final Service service = Service.create(new URL("http://127.0.0.1:" + port + "/webservice-ws-with-resources-config/CalculatorBean?wsdl"), new QName("http://security.ws.superbiz.org/", "CalculatorBeanService"));
    final Calculator calculator = service.getPort(Calculator.class);
    ClientProxy.getClient(calculator).getOutInterceptors().add(new WSS4JOutInterceptor(new HashMap<String, Object>() {

        {
            put("action", "UsernameToken");
            put("user", "openejb");
            put("passwordType", "PasswordText");
            put("passwordCallbackRef", new CallbackHandler() {

                @Override
                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
                    pc.setPassword("tomee");
                }
            });
        }
    }));
    assertEquals(5, calculator.add(2, 3));
    // bad auth
    final Calculator calculator2 = service.getPort(Calculator.class);
    ClientProxy.getClient(calculator2).getOutInterceptors().add(new WSS4JOutInterceptor(new HashMap<String, Object>() {

        {
            put("action", "UsernameToken");
            put("user", "openejb");
            put("passwordType", "PasswordText");
            put("passwordCallbackRef", new CallbackHandler() {

                @Override
                public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
                    final WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
                    pc.setPassword("wrong");
                }
            });
        }
    }));
    try {
        assertEquals(5, calculator2.add(2, 3));
    } catch (SOAPFaultException sfe) {
        assertThat(sfe.getMessage(), CoreMatchers.containsString("A security error was encountered when verifying the message"));
    }
    container.close();
    // valid it passed because all was fine and not because the server config was not here
    assertTrue(PasswordCallbackHandler.wasCalled());
}
Also used : CallbackHandler(javax.security.auth.callback.CallbackHandler) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) Service(javax.xml.ws.Service) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) IOException(java.io.IOException) Properties(java.util.Properties) URL(java.net.URL) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) EJBContainer(javax.ejb.embeddable.EJBContainer) WSS4JOutInterceptor(org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor) UnsupportedCallbackException(javax.security.auth.callback.UnsupportedCallbackException) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Test(org.junit.Test)

Aggregations

SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)31 LogfileTestTailer (com.evolveum.midpoint.test.util.LogfileTestTailer)21 Test (org.testng.annotations.Test)21 Holder (javax.xml.ws.Holder)18 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)17 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)17 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)17 QName (javax.xml.namespace.QName)7 URL (java.net.URL)5 Test (org.junit.Test)5 ObjectDeltaListType (com.evolveum.midpoint.xml.ns._public.common.api_types_3.ObjectDeltaListType)4 SOAPException (javax.xml.soap.SOAPException)4 SOAPFault (javax.xml.soap.SOAPFault)4 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)3 IOException (java.io.IOException)3 Service (javax.xml.ws.Service)3 JAXBElement (javax.xml.bind.JAXBElement)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 ServiceIface (org.jboss.as.test.integration.ws.wsse.ServiceIface)2 UseNewBusFeature (org.jboss.wsf.stack.cxf.client.UseNewBusFeature)2