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 cxf by apache.
the class HWDOMSourcePayloadProvider method invoke.
public DOMSource invoke(DOMSource request) {
QName qn = (QName) ctx.getMessageContext().get(MessageContext.WSDL_OPERATION);
if (qn == null) {
throw new RuntimeException("No Operation Name");
}
DOMSource response = new DOMSource();
Node n = request.getNode();
if (n instanceof Document) {
n = ((Document) n).getDocumentElement();
}
if (n.getLocalName().equals(sayHi.getLocalPart())) {
response.setNode(sayHiResponse);
} else if (n.getLocalName().equals(greetMe.getLocalPart())) {
Element el = DOMUtils.getFirstElement(n);
String s = DOMUtils.getContent(el);
if (s.trim().equals("throwFault")) {
try {
SOAPFactory f = SOAPFactory.newInstance();
SOAPFault soapFault = f.createFault();
soapFault.setFaultString("Test Fault String ****");
Detail detail = soapFault.addDetail();
detail = soapFault.getDetail();
QName qName = new QName("http://www.Hello.org/greeter", "TestFault", "ns");
DetailEntry de = detail.addDetailEntry(qName);
qName = new QName("http://www.Hello.org/greeter", "ErrorCode", "ns");
SOAPElement errorElement = de.addChildElement(qName);
errorElement.setTextContent("errorcode");
throw new SOAPFaultException(soapFault);
} catch (SOAPException e) {
e.printStackTrace();
}
}
response.setNode(greetMeResponse);
}
return response;
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class HWSoapMessageDocProvider method invoke.
public SOAPMessage invoke(SOAPMessage request) {
QName qn = (QName) ctx.getMessageContext().get(MessageContext.WSDL_OPERATION);
if (qn == null) {
throw new RuntimeException("No Operation Name");
}
SOAPMessage response = null;
SOAPBody body = null;
try {
body = SAAJUtils.getBody(request);
} catch (SOAPException e) {
return null;
}
Node n = body.getFirstChild();
while (n.getNodeType() != Node.ELEMENT_NODE) {
n = n.getNextSibling();
}
if (n.getLocalName().equals(sayHi.getLocalPart())) {
response = sayHiResponse;
} else if (n.getLocalName().equals(greetMe.getLocalPart())) {
Element el = DOMUtils.getFirstElement(n);
String v = DOMUtils.getContent(el);
if (v.contains("Return sayHi")) {
response = sayHiResponse;
} else if (v.contains("exceed maxLength")) {
response = greetMeResponseExceedMaxLengthRestriction;
} else if (v.contains("throwFault")) {
try {
SOAPFactory f = SOAPFactory.newInstance();
SOAPFault soapFault = f.createFault();
soapFault.setFaultString("Test Fault String ****");
Detail detail = soapFault.addDetail();
detail = soapFault.getDetail();
QName qName = new QName("http://www.Hello.org/greeter", "TestFault", "ns");
DetailEntry de = detail.addDetailEntry(qName);
qName = new QName("http://www.Hello.org/greeter", "ErrorCode", "ns");
SOAPElement errorElement = de.addChildElement(qName);
errorElement.setTextContent("errorcode");
throw new SOAPFaultException(soapFault);
} catch (SOAPException ex) {
// ignore
}
} else {
response = greetMeResponse;
}
}
return response;
}
use of javax.xml.ws.soap.SOAPFaultException in project cxf by apache.
the class ProviderRPCClientServerTest method doGreeterRPCLit.
private void doGreeterRPCLit(SOAPServiceRPCLit service, QName portName, int count, boolean doFault) throws Exception {
String response1 = new String("TestGreetMeResponse");
String response2 = new String("TestSayHiResponse");
try {
GreeterRPCLit greeter = service.getPort(portName, GreeterRPCLit.class);
updateAddressPort(greeter, PORT);
for (int idx = 0; idx < count; idx++) {
String greeting = greeter.greetMe("Milestone-" + idx);
assertNotNull("no response received from service", greeting);
assertEquals(response1, greeting);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response2, reply);
if (doFault) {
try {
greeter.greetMe("throwFault");
} catch (SOAPFaultException ex) {
assertNotNull(ex.getFault().getDetail());
try {
assertTrue(ex.getFault().getDetail().getDetailEntries().hasNext());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
} catch (UndeclaredThrowableException ex) {
throw (Exception) ex.getCause();
}
}
Aggregations