下面列出了javax.net.ssl.CertPathTrustManagerParameters#javax.xml.ws.BindingProvider 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Test
public void setUserCredentialsInContext_SAML_SP() {
// given
Map<String, Setting> settings = getSettingsForMode("SAML_SP");
BindingProvider client = Mockito.mock(BindingProvider.class);
Map<String, String> context = new HashMap<>();
Mockito.doReturn(context).when(client).getRequestContext();
// when
besDAO.setUserCredentialsInContext(client, USER, PASSWORD, settings);
// then
assertNull(client.getRequestContext().get(
BindingProvider.USERNAME_PROPERTY));
assertNull(client.getRequestContext().get(
BindingProvider.PASSWORD_PROPERTY));
assertEquals(USER,
client.getRequestContext().get(XWSSConstants.USERNAME_PROPERTY));
assertEquals(PASSWORD,
client.getRequestContext().get(XWSSConstants.PASSWORD_PROPERTY));
}
@org.junit.Test
public void testX509SAML2() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = X509AsymmetricBindingTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = X509AsymmetricBindingTest.class.getResource("DoubleItAsymmetric.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItAsymmetricSAML2Port");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
TokenTestUtils.updateSTSPort((BindingProvider)port, STSPORT2);
doubleIt(port, 30);
((java.io.Closeable)port).close();
bus.shutdown(true);
}
public int doubleIt(int numberToDouble) {
// Delegate request to a provider
URL wsdl = DoubleItPortTypeImpl.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2SupportingPort");
DoubleItPortType transportSAML2SupportingPort =
service.getPort(portQName, DoubleItPortType.class);
try {
updateAddressPort(transportSAML2SupportingPort, getPort());
} catch (Exception ex) {
ex.printStackTrace();
}
//
// Get the principal from the request context and construct a SAML Assertion
//
Saml2CallbackHandler callbackHandler = new Saml2CallbackHandler(wsc.getUserPrincipal());
((BindingProvider)transportSAML2SupportingPort).getRequestContext().put(
SecurityConstants.SAML_CALLBACK_HANDLER, callbackHandler
);
return transportSAML2SupportingPort.doubleIt(numberToDouble);
}
@Test
public void getClientForBESTechnologyManager_INTERNAL_userPwdNotInConfig_userInTS()
throws MalformedURLException, BadResultException,
APPlatformException {
// given
Map<String, Setting> proxySettings = getSettingsForMode("INTERNAL");
Map<String, Setting> controllerSettings = getControllerSettings(true,
true, false);
BesDAO besDAO = mockWebServiceSetup(proxySettings, controllerSettings);
ServiceInstance si = getServiceInstanceWithParameters(true, true);
// when
IdentityService client = besDAO.getBESWebService(IdentityService.class,
si);
// then
verify(besDAO, times(1)).setUserCredentialsInContext(
(BindingProvider) client, USER_TM_TechSvc, USER_PWD_TM_TechSvc,
proxySettings);
}
/**
* Set whether SOAP requests should use compression.
*
* @param soapClient the client to set compression settings for
* @param compress whether or not to use compression
*/
@Override
public void setCompression(BindingProvider soapClient, boolean compress) {
Map<String, String> headersMap = Maps.newHashMap();
if (compress) {
headersMap.put("Accept-Encoding", "gzip");
headersMap.put("Content-Encoding", "gzip");
putAllHttpHeaders(soapClient, headersMap);
} else {
@SuppressWarnings("unchecked") // HTTP Headers in JAXWS are always a map of
// String to List of String.
Map<String, List<String>> httpHeaders =
(Map<String, List<String>>) soapClient.getRequestContext().get(
MessageContext.HTTP_REQUEST_HEADERS);
if (httpHeaders != null) {
httpHeaders.remove("Accept-Encoding");
httpHeaders.remove("Content-Encoding");
}
}
}
@Test
public void getUserDetails_givenUser_SSO() throws APPlatformException {
// given
besDAO.configService = confServ;
Map<String, Setting> settings = getSettingsForMode("SAML_SP");
doReturn(settings).when(besDAO.configService)
.getAllProxyConfigurationSettings();
doReturn(idServ).when(besDAO).getBESWebService(
eq(IdentityService.class), any(ServiceInstance.class));
VOUser user = givenUser(null, "mail");
// when
besDAO.getUserDetails(new ServiceInstance(), user, "password");
// then
verify(besDAO).setUserCredentialsInContext(any(BindingProvider.class),
eq(user.getUserId()), eq("password"), eq(settings));
verify(idServ).getCurrentUserDetails();
}
@Test
public void testDisableAll() throws Exception {
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
AddNumbersPortType port = getService().getAddNumbersPort(new AddressingFeature(false));
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
"http://localhost:"
+ PORT + "/jaxws/add");
assertEquals(3, port.addNumbers(1, 2));
String expectedOut = "http://www.w3.org/2005/08/addressing";
String expectedIn = "http://www.w3.org/2005/08/addressing";
assertTrue(output.toString().indexOf(expectedOut) == -1);
assertTrue(input.toString().indexOf(expectedIn) == -1);
}
@Test
public void testSayHi() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceSoapAction");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldService service = new HelloWorldService(wsdl, serviceName);
String response = new String("Bonjour");
HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingInInterceptor());
((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_1"
);
String reply = greeter.sayHi();
assertNotNull("no response received from service", reply);
assertEquals(response, reply);
((java.io.Closeable)greeter).close();
}
private void fillSOAPAction(Packet packet, boolean isAddressingEnabled) {
final boolean p = packet.packetTakesPriorityOverRequestContext;
final String localSoapAction = p ? packet.soapAction : soapAction;
final Boolean localSoapActionUse = p ? (Boolean) packet.invocationProperties.get(BindingProvider.SOAPACTION_USE_PROPERTY)
: soapActionUse;
//JAX-WS-596: Check the semantics of SOAPACTION_USE_PROPERTY before using the SOAPACTION_URI_PROPERTY for
// SoapAction as specified in the javadoc of BindingProvider. The spec seems to be little contradicting with
// javadoc and says that the use property effects the sending of SOAPAction property.
// Since the user has the capability to set the value as "" if needed, implement the javadoc behavior.
if ((localSoapActionUse != null && localSoapActionUse) || (localSoapActionUse == null && isAddressingEnabled)) {
if (localSoapAction != null) {
packet.soapAction = localSoapAction;
}
}
if ((!isAddressingEnabled && (localSoapActionUse == null || !localSoapActionUse)) && localSoapAction != null) {
LOGGER.warning("BindingProvider.SOAPACTION_URI_PROPERTY is set in the RequestContext but is ineffective," +
" Either set BindingProvider.SOAPACTION_USE_PROPERTY to true or enable AddressingFeature");
}
}
private void callGreetMe() {
BindingProvider bp = (BindingProvider)port;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
String request = "World" + ((prefix != null) ? ":" + prefix : "");
String correlationID = null;
if (corrFactory != null) {
correlationID = corrFactory.createCorrealtionID();
requestHeader.setJMSCorrelationID(correlationID);
request += ":" + correlationID;
}
String expected = "Hello " + request;
String response = port.greetMe(request);
Assert.assertEquals("Response didn't match expected request", expected, response);
if (corrFactory != null) {
Map<String, Object> responseContext = bp.getResponseContext();
JMSMessageHeadersType responseHeader =
(JMSMessageHeadersType)responseContext.get(
JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
Assert.assertEquals("Request and Response CorrelationID didn't match",
correlationID, responseHeader.getJMSCorrelationID());
}
}
@Test
public void testSayHi2() throws Exception {
QName serviceName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldServiceSoapAction");
QName portName = new QName("http://cxf.apache.org/hello_world_jms", "HelloWorldPort");
URL wsdl = getWSDLURL("/wsdl/jms_test.wsdl");
HelloWorldService service = new HelloWorldService(wsdl, serviceName);
HelloWorldPortType greeter = service.getPort(portName, HelloWorldPortType.class);
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingOutInterceptor());
ClientProxy.getClient(greeter).getOutInterceptors().add(new LoggingInInterceptor());
((BindingProvider)greeter).getRequestContext().put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
((BindingProvider)greeter).getRequestContext().put(
BindingProvider.SOAPACTION_URI_PROPERTY, "SAY_HI_2"
);
try {
greeter.sayHi();
fail("Failure expected on spoofing attack");
} catch (Exception ex) {
// expected
}
((java.io.Closeable)greeter).close();
}
@Test
public void testDetail() throws Exception {
ByteArrayOutputStream input = setupInLogging();
ByteArrayOutputStream output = setupOutLogging();
Holder<byte[]> photo = new Holder<>("CXF".getBytes());
Holder<Image> image = new Holder<>(getImage("/java.jpg"));
Hello port = getPort();
SOAPBinding binding = (SOAPBinding) ((BindingProvider)port).getBinding();
binding.setMTOMEnabled(true);
port.detail(photo, image);
String expected = "<xop:Include ";
assertTrue(output.toString().indexOf(expected) != -1);
assertTrue(input.toString().indexOf(expected) != -1);
assertEquals("CXF", new String(photo.value));
assertNotNull(image.value);
}
/**
* Create a webservice client using wsdl url
*
* @throws Exception
*/
//START SNIPPET: webservice
@Test
public void remoteCallWithSslClient() throws Exception {
// create the service from the WSDL
final URL url = new URL(base.toExternalForm() + "webservices/CalculatorImpl?wsdl");
final QName calcServiceQName = new QName("http://superbiz.org/wsdl", "CalculatorWsService");
final Service calcService = Service.create(url, calcServiceQName);
assertNotNull(calcService);
// get the port for the service
final CalculatorWs calc = calcService.getPort(CalculatorWs.class);
// switch the target URL for invocation to HTTPS
((BindingProvider) calc).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://localhost:8443/app/webservices/CalculatorImpl");
// add the SSL Client certificate, set the trust store and the hostname verifier
setupTLS(calc);
// call the remote JAX-WS webservice
assertEquals(10, calc.sum(4, 6));
assertEquals(12, calc.multiply(3, 4));
}
public static SecondServiceAT newInstance() throws Exception {
URL wsdlLocation = new URL("http://localhost:8082/Service/SecondServiceAT?wsdl");
QName serviceName = new QName("http://service.ws.sample", "SecondServiceATService");
QName portName = new QName("http://service.ws.sample", "SecondServiceAT");
Service service = Service.create(wsdlLocation, serviceName);
SecondServiceAT client = service.getPort(portName, SecondServiceAT.class);
List<Handler> handlerChain = new ArrayList<>();
JaxWSTxOutboundBridgeHandler txOutboundBridgeHandler = new JaxWSTxOutboundBridgeHandler();
EnabledWSTXHandler wstxHandler = new EnabledWSTXHandler();
handlerChain.add(txOutboundBridgeHandler);
handlerChain.add(wstxHandler);
((BindingProvider)client).getBinding().setHandlerChain(handlerChain);
return client;
}
/**
* Prepare the given JAX-WS port stub, applying properties to it.
* Called by {@link #prepare}.
* @param stub the current JAX-WS port stub
* @see #setUsername
* @see #setPassword
* @see #setEndpointAddress
* @see #setMaintainSession
* @see #setCustomProperties
*/
protected void preparePortStub(Object stub) {
Map<String, Object> stubProperties = new HashMap<>();
String username = getUsername();
if (username != null) {
stubProperties.put(BindingProvider.USERNAME_PROPERTY, username);
}
String password = getPassword();
if (password != null) {
stubProperties.put(BindingProvider.PASSWORD_PROPERTY, password);
}
String endpointAddress = getEndpointAddress();
if (endpointAddress != null) {
stubProperties.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
}
if (isMaintainSession()) {
stubProperties.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE);
}
if (isUseSoapAction()) {
stubProperties.put(BindingProvider.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
}
String soapActionUri = getSoapActionUri();
if (soapActionUri != null) {
stubProperties.put(BindingProvider.SOAPACTION_URI_PROPERTY, soapActionUri);
}
stubProperties.putAll(getCustomProperties());
if (!stubProperties.isEmpty()) {
if (!(stub instanceof BindingProvider)) {
throw new RemoteLookupFailureException("Port stub of class [" + stub.getClass().getName() +
"] is not a customizable JAX-WS stub: it does not implement interface [javax.xml.ws.BindingProvider]");
}
((BindingProvider) stub).getRequestContext().putAll(stubProperties);
}
}
private static void initClient() {
JaxWsProxyFactoryBean clientFactory = new JaxWsProxyFactoryBean();
clientFactory.setServiceClass(AttachmentService.class);
clientFactory.setAddress(ADDRESS);
client = (AttachmentService) clientFactory.create();
//enable MTOM in client
BindingProvider bp = (BindingProvider) client;
SOAPBinding binding = (SOAPBinding) bp.getBinding();
binding.setMTOMEnabled(true);
}
/**
* @deprecated
* The programatic acccess should be done via
* {@link #endpointAddress}. This is for JAX-WS client applications
* that access this property via {@link BindingProvider#ENDPOINT_ADDRESS_PROPERTY}.
*/
@Property(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)
public String getEndPointAddressString() {
if (endpointAddress == null) {
return null;
} else {
return endpointAddress.toString();
}
}
@org.junit.Test
public void testSubjectAlternativeNameMatch() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = HostnameVerificationTest.class.getResource("hostname-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL url = SOAPService.WSDL_LOCATION;
SOAPService service = new SOAPService(url, SOAPService.SERVICE);
assertNotNull("Service is null", service);
final Greeter port = service.getHttpsPort();
assertNotNull("Port is null", port);
updateAddressPort(port, PORT);
// Enable Async
if (async) {
((BindingProvider)port).getRequestContext().put("use.async.http.conduit", true);
}
assertEquals(port.greetMe("Kitty"), "Hello Kitty");
((java.io.Closeable)port).close();
bus.shutdown(true);
}
@org.junit.Test
public void testSendSAML2PublicKey() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = TemplateTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = TemplateTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML2PublicKeyPort");
DoubleItPortType port =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
// Setup STSClient
STSClient stsClient = createSTSClient(bus);
String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
stsClient.setWsdlLocation(wsdlLocation);
((BindingProvider)port).getRequestContext().put(
SecurityConstants.STS_CLIENT, stsClient
);
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
doubleIt(port, 25);
((java.io.Closeable)port).close();
bus.shutdown(true);
}
private void addBasicAuth(Packet context, Map<String, List<String>> reqHeaders) {
String user = (String) context.invocationProperties.get(BindingProvider.USERNAME_PROPERTY);
if (user != null) {
String pw = (String) context.invocationProperties.get(BindingProvider.PASSWORD_PROPERTY);
if (pw != null) {
StringBuilder buf = new StringBuilder(user);
buf.append(":");
buf.append(pw);
String creds = DatatypeConverter.printBase64Binary(buf.toString().getBytes());
reqHeaders.put("Authorization", Collections.singletonList("Basic "+creds));
}
}
}
@org.junit.Test
public void testBinarySecurityToken() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = BinarySecurityTokenTest.class.getResource("client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = BinarySecurityTokenTest.class.getResource("DoubleItTokens.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
// Successful invocation
QName portQName = new QName(NAMESPACE, "DoubleItBinarySecurityTokenPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, PORT);
// Mock up a BinarySecurityToken to add
SecurityToken securityToken = new SecurityToken();
securityToken.setId("_" + UUID.randomUUID().toString());
Document doc = DOMUtils.newDocument();
BinarySecurity binarySecurity = new BinarySecurity(doc);
binarySecurity.setValueType("http://custom-value-type");
binarySecurity.setToken("This is a token".getBytes());
securityToken.setToken(binarySecurity.getElement());
((BindingProvider)port).getRequestContext().put(SecurityConstants.TOKEN, securityToken);
assertEquals(50, port.doubleIt(25));
((java.io.Closeable)port).close();
bus.shutdown(true);
}
private void registerService(BindingProvider bindingProvider) {
Binding binding = bindingProvider.getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(new LoggingHandler());
// set the handler chain again for the changes to take effect
binding.setHandlerChain(handlerChain);
}
private void addBasicAuth(Packet context, Map<String, List<String>> reqHeaders) {
String user = (String) context.invocationProperties.get(BindingProvider.USERNAME_PROPERTY);
if (user != null) {
String pw = (String) context.invocationProperties.get(BindingProvider.PASSWORD_PROPERTY);
if (pw != null) {
StringBuilder buf = new StringBuilder(user);
buf.append(":");
buf.append(pw);
String creds = DatatypeConverter.printBase64Binary(buf.toString().getBytes());
reqHeaders.put("Authorization", Collections.singletonList("Basic "+creds));
}
}
}
@BeforeClass
public static void startManager() throws ConfigurationException {
if (!TckPublisher.isEnabled()) return;
manager = new UDDIClient();
manager.start();
logger.debug("Getting auth tokens..");
try {
Transport transport = manager.getTransport("uddiv3");
UDDISecurityPortType security = transport.getUDDISecurityService();
authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
//Assert.assertNotNull(authInfoJoe);
UDDIPublicationPortType publication = transport.getUDDIPublishService();
inquiry = transport.getUDDIInquiryService();
if (!TckPublisher.isUDDIAuthMode()){
TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
}
tckTModel = new TckTModel(publication, inquiry);
tckBusiness = new TckBusiness(publication, inquiry);
} catch (Exception e) {
logger.error(e.getMessage(), e);
Assert.fail("Could not obtain authInfo token.");
}
JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
}
@org.junit.Test
public void testSaml1CustomClaims() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = ClaimsTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = ClaimsTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItTransportSAML1CustomClaimsPort");
DoubleItPortType transportClaimsPort =
service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(transportClaimsPort, test.getPort());
TokenTestUtils.updateSTSPort((BindingProvider)transportClaimsPort, test.getStsPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(transportClaimsPort);
}
doubleIt(transportClaimsPort, 25);
((java.io.Closeable)transportClaimsPort).close();
bus.shutdown(true);
}
@Test
public void testClientProxyFactory() {
JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean();
cf.setAddress("http://localhost:9000/test");
Greeter greeter = cf.create(Greeter.class);
/* .n.b. don't call call create with an argument and change the SEI. */
Greeter greeter2 = (Greeter) cf.create();
Greeter greeter3 = (Greeter) cf.create();
Client c = (Client)greeter;
Client c2 = (Client)greeter2;
Client c3 = (Client)greeter3;
assertNotSame(c, c2);
assertNotSame(c, c3);
assertNotSame(c3, c2);
assertNotSame(c.getEndpoint(), c2.getEndpoint());
assertNotSame(c.getEndpoint(), c3.getEndpoint());
assertNotSame(c3.getEndpoint(), c2.getEndpoint());
c3.getInInterceptors();
((BindingProvider)greeter).getRequestContext().put("test", "manny");
((BindingProvider)greeter2).getRequestContext().put("test", "moe");
((BindingProvider)greeter3).getRequestContext().put("test", "jack");
assertEquals("manny", ((BindingProvider)greeter).getRequestContext().get("test"));
assertEquals("moe", ((BindingProvider)greeter2).getRequestContext().get("test"));
assertEquals("jack", ((BindingProvider)greeter3).getRequestContext().get("test"));
}
@BeforeClass
public static void startManager() throws ConfigurationException {
if (!TckPublisher.isEnabled()) return;
manager = new UDDIClient();
manager.start();
logger.debug("Getting auth tokens..");
try {
Transport transport = manager.getTransport("uddiv3");
UDDISecurityPortType security = transport.getUDDISecurityService();
authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
//Assert.assertNotNull(authInfoJoe);
UDDIPublicationPortType publication = transport.getUDDIPublishService();
inquiry = transport.getUDDIInquiryService();
if (!TckPublisher.isUDDIAuthMode()){
TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
}
tckTModel = new TckTModel(publication, inquiry);
tckBusiness = new TckBusiness(publication, inquiry);
} catch (Exception e) {
logger.error(e.getMessage(), e);
Assert.fail("Could not obtain authInfo token.");
}
JUDDI_300_MultiNodeIntegrationTest.testSetupReplicationConfig();
}
@Test
public void testFault() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SecurityPolicyTest.class.getResource("https_config_client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = SecurityPolicyTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItFaultPortSignThenEncrypt");
DoubleItPortType pt = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(pt, PORT);
((BindingProvider)pt).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER,
new KeystorePasswordCallback());
((BindingProvider)pt).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES,
"alice.properties");
((BindingProvider)pt).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES,
"bob.properties");
// DOM
try {
pt.doubleIt(5);
fail("SOAPFaultException expected!");
} catch (SOAPFaultException e) {
assertEquals("Foo", e.getFault().getFaultString());
} finally {
((java.io.Closeable)pt).close();
bus.shutdown(true);
}
}
SIPSubmission getSoapClient() {
if (sipSubmission == null) {
SIPSubmissionService service = new SIPSubmissionService();
sipSubmission = service.getSIPSubmissionSOAP();
Map<String, Object> context = ((BindingProvider) sipSubmission).getRequestContext();
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, soapUrl);
context.put(BindingProvider.USERNAME_PROPERTY, user);
context.put(BindingProvider.PASSWORD_PROPERTY, passwd);
}
return sipSubmission;
}
private void addCookies(Packet context, Map<String, List<String>> reqHeaders) throws IOException {
Boolean shouldMaintainSessionProperty =
(Boolean) context.invocationProperties.get(BindingProvider.SESSION_MAINTAIN_PROPERTY);
if (shouldMaintainSessionProperty != null && !shouldMaintainSessionProperty) {
return; // explicitly turned off
}
if (sticky || (shouldMaintainSessionProperty != null && shouldMaintainSessionProperty)) {
Map<String, List<String>> rememberedCookies = cookieJar.get(context.endpointAddress.getURI(), reqHeaders);
processCookieHeaders(reqHeaders, rememberedCookies, "Cookie");
processCookieHeaders(reqHeaders, rememberedCookies, "Cookie2");
}
}