List of usage examples for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY
String ENDPOINT_ADDRESS_PROPERTY
To view the source code for javax.xml.ws BindingProvider ENDPOINT_ADDRESS_PROPERTY.
Click Source Link
From source file:test.integ.be.e_contract.mycarenet.cxf.EHealthSTSClientTest.java
@Test public void testCXFRuntime() throws Exception { EHealthSamlStsService service = EHealthSamlStsServiceFactory.newInstance(); EHealthSamlStsPortType port = service.getEHealthSamlStsPort(); BindingProvider bindingProvider = (BindingProvider) port; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://wwwacc.ehealth.fgov.be/sts_1_1/SecureTokenService"); ObjectFactory objectFactory = new ObjectFactory(); RequestType request = objectFactory.createRequestType(); port.attributeQuery(request);//from w ww. j ava 2s . c o m }
From source file:test.integ.be.e_contract.sts.CXFSTSClientTest.java
@Test public void testExampleWebService() throws Exception { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("cxf-https-trust-all.xml"); BusFactory.setDefaultBus(bus);//ww w. ja v a 2s . c o m // get the JAX-WS client URL wsdlLocation = CXFSTSClientTest.class.getResource("/example-localhost-sts.wsdl"); ExampleService exampleService = new ExampleService(wsdlLocation, new QName("urn:be:e-contract:sts:example", "ExampleService")); ExampleServicePortType port = exampleService.getExampleServicePort(); // set the web service address on the client stub BindingProvider bindingProvider = (BindingProvider) port; Map<String, Object> requestContext = bindingProvider.getRequestContext(); final String WS_LOCATION = "https://localhost/iam/example"; // final String WS_LOCATION = "https://www.e-contract.be/iam/example"; requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, WS_LOCATION); requestContext.put(SecurityConstants.STS_CLIENT_SOAP12_BINDING, "true"); requestContext.put(SecurityConstants.SIGNATURE_CRYPTO, new BeIDCrypto()); requestContext.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true"); requestContext.put(SecurityConstants.SIGNATURE_USERNAME, "username"); requestContext.put(SecurityConstants.CALLBACK_HANDLER, new ExampleSecurityPolicyCallbackHandler()); requestContext.put(SecurityConstants.PREFER_WSMEX_OVER_STS_CLIENT_CONFIG, "true"); // invoke the web service String result = port.echo("hello world"); LOGGER.debug("result: " + result); bus.shutdown(true); }
From source file:test.integ.be.e_contract.sts.CXFSTSClientTest.java
@Test public void testSelfSignedCertificateFails() throws Exception { SpringBusFactory bf = new SpringBusFactory(); Bus bus = bf.createBus("cxf-https-trust-all.xml"); BusFactory.setDefaultBus(bus);/* w ww. ja v a2s.c om*/ // get the JAX-WS client URL wsdlLocation = CXFSTSClientTest.class.getResource("/example-localhost-sts.wsdl"); ExampleService exampleService = new ExampleService(wsdlLocation, new QName("urn:be:e-contract:sts:example", "ExampleService")); ExampleServicePortType port = exampleService.getExampleServicePort(); // set the web service address on the client stub BindingProvider bindingProvider = (BindingProvider) port; Map<String, Object> requestContext = bindingProvider.getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://localhost/iam/example"); KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); KeyPair keyPair = keyPairGenerator.generateKeyPair(); PrivateKey privateKey = keyPair.getPrivate(); PublicKey publicKey = keyPair.getPublic(); X509Certificate certificate = getCertificate(privateKey, publicKey); List<X509Certificate> certificates = new LinkedList<>(); certificates.add(certificate); requestContext.put(SecurityConstants.STS_CLIENT_SOAP12_BINDING, "true"); requestContext.put(SecurityConstants.SIGNATURE_CRYPTO, new ClientCrypto(privateKey, certificates)); requestContext.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true"); requestContext.put(SecurityConstants.SIGNATURE_USERNAME, "username"); requestContext.put(SecurityConstants.CALLBACK_HANDLER, new ExampleSecurityPolicyCallbackHandler()); requestContext.put(SecurityConstants.PREFER_WSMEX_OVER_STS_CLIENT_CONFIG, "true"); // invoke the web service try { port.echo("hello world"); fail(); } catch (SOAPFaultException e) { // expected assertTrue(e.getMessage().contains("security token")); } bus.shutdown(true); }
From source file:test.integ.be.fedict.hsm.client.HSMProxyClientTest.java
@Test public void testSecurityAuditGenerationByWSSecurity() throws Exception { DigitalSignatureService digitalSignatureService = DigitalSignatureServiceFactory.getInstance(); DigitalSignatureServicePortType dssPort = digitalSignatureService.getDigitalSignatureServicePort(); BindingProvider bindingProvider = (BindingProvider) dssPort; String location = "http://localhost:8080/hsm-proxy-ws/dss"; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); ObjectFactory objectFactory = new ObjectFactory(); SignRequest signRequest = objectFactory.createSignRequest(); try {//from ww w. j a v a 2s . c o m dssPort.sign(signRequest); fail(); } catch (SOAPFaultException e) { LOG.debug("expected exception: " + e.getMessage()); // expected } }
From source file:test.integ.be.fedict.hsm.ws.WebServiceTest.java
private DigitalSignatureServicePortType getPort() { DigitalSignatureService digitalSignatureService = DigitalSignatureServiceFactory.getInstance(); DigitalSignatureServicePortType dssPort = digitalSignatureService.getDigitalSignatureServicePort(); BindingProvider bindingProvider = (BindingProvider) dssPort; String location = this.baseURL.toString() + "dss"; LOG.debug("location: " + location); bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); return dssPort; }
From source file:test.unit.be.fedict.trust.xkms2.XKMSPortImplTest.java
@Test public void test() throws Exception { int port = getFreePort(); String address = "http://localhost:" + port + "/xkms2"; HttpServer server = HttpServer.create(new InetSocketAddress("localhost", port), 5); ExecutorService threads = Executors.newFixedThreadPool(5); server.setExecutor(threads);/* www. j a v a 2 s .co m*/ server.start(); XKMSPortType xkmsPort = new XKMSPortImpl(); Endpoint endpoint = Endpoint.create(xkmsPort); HttpContext httpContext = server.createContext("/xkms2"); LOG.debug("http context attributes: " + httpContext.getAttributes()); endpoint.publish(httpContext); assertTrue(endpoint.isPublished()); HttpClient httpClient = new HttpClient(); GetMethod getMethod = new GetMethod(address + "?wsdl"); int statusCode = httpClient.executeMethod(getMethod); LOG.debug("status code: " + statusCode); assertEquals(HttpServletResponse.SC_OK, statusCode); LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString()); getMethod = new GetMethod(address + "?wsdl=1"); statusCode = httpClient.executeMethod(getMethod); LOG.debug("status code: " + statusCode); assertEquals(HttpServletResponse.SC_OK, statusCode); LOG.debug("runtime WSDL: " + getMethod.getResponseBodyAsString()); XKMSService xkmsService = XKMSServiceFactory.getInstance(); XKMSPortType xkmsPortClient = xkmsService.getXKMSPort(); BindingProvider bindingProviderClient = (BindingProvider) xkmsPortClient; bindingProviderClient.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address); // EasyMock.replay(mockServletContext); // ValidateResultType validateResult = xkmsPortClient.validate(null); // EasyMock.verify(mockServletContext); }
From source file:uk.ac.open.lts.webmaths.CheckServlet.java
private static void setUrl(Object port, String url) { BindingProvider bp = (BindingProvider) port; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); }