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");
}
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");
}
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");
}
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);
}
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());
}
Aggregations