use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlSubjectConfTest method testHOKNonMatchingCert.
// Sign using "alice"
@org.junit.Test
public void testHOKNonMatchingCert() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlSubjectConfTest.class.getResource("client-auth.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
((BindingProvider) port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
try {
port.doubleIt(25);
fail("Failure expected on a non matching cert (SAML -> TLS)");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlSubjectConfTest method testBearer.
//
// Bearer does not require client auth, but it does require an internal signature
//
@org.junit.Test
public void testBearer() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlSubjectConfTest.class.getResource("client-auth.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
// Successful call
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_BEARER);
callbackHandler.setCryptoAlias("morpit");
callbackHandler.setCryptoPassword("password");
callbackHandler.setCryptoPropertiesFile("morpit.properties");
((BindingProvider) port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
int result = port.doubleIt(25);
assertTrue(result == 50);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlSubjectConfTest method testSVNoClientAuthentication.
@org.junit.Test
public void testSVNoClientAuthentication() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlSubjectConfTest.class.getResource("client-noauth.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
// Successful call
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, false);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES);
((BindingProvider) port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
try {
port.doubleIt(25);
fail("Failure expected on no client auth");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlSubjectConfTest method testHOKNoClientAuthentication.
@org.junit.Test
public void testHOKNoClientAuthentication() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlSubjectConfTest.class.getResource("client-noauth.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
// Successful call
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, true);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_HOLDER_KEY);
callbackHandler.setCryptoAlias("morpit");
callbackHandler.setCryptoPassword("password");
callbackHandler.setCryptoPropertiesFile("morpit.properties");
((BindingProvider) port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
try {
port.doubleIt(25);
fail("Failure expected on no client auth");
} catch (javax.xml.ws.soap.SOAPFaultException ex) {
// expected
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
use of org.apache.cxf.systest.ws.saml.client.SamlCallbackHandler in project cxf by apache.
the class SamlSubjectConfTest method testSVClientAuthentication.
//
// SV requires client auth. The server is set up not to require client auth to
// test this. SV does not require an internal signature unlike HOK.
//
@org.junit.Test
public void testSVClientAuthentication() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SamlSubjectConfTest.class.getResource("client-auth.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SamlSubjectConfTest.class.getResource("DoubleItSamlSubjectConf.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItSaml2TransportPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
// Successful call
SamlCallbackHandler callbackHandler = new SamlCallbackHandler(true, false);
callbackHandler.setConfirmationMethod(SAML2Constants.CONF_SENDER_VOUCHES);
((BindingProvider) port).getRequestContext().put(SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler);
int result = port.doubleIt(25);
assertTrue(result == 50);
((java.io.Closeable) port).close();
bus.shutdown(true);
}
Aggregations