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.agiv.security.ClaimsAwareServiceTest.java
@Test public void testSecurityFrameworkSTSListener() { // setup/*w w w . j a v a 2s . com*/ Service service = ClaimsAwareServiceFactory.getInstance(); IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ClaimsAwareServiceFactory.SERVICE_LOCATION); AGIVSecurity agivSecurity = new AGIVSecurity( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword()); agivSecurity.enable(bindingProvider, false, ClaimsAwareServiceFactory.SERVICE_REALM); STSTestListener testListener = new STSTestListener(); agivSecurity.addSTSListener(testListener); // operate iservice.getData(0); // verify assertTrue(testListener.isCalledIpSts()); assertTrue(testListener.isCalledRSts()); assertFalse(testListener.isCalledSCT()); // setup testListener.reset(); // operate iservice.getData(0); // verify assertFalse(testListener.isCalledIpSts()); assertFalse(testListener.isCalledRSts()); assertFalse(testListener.isCalledSCT()); // setup testListener.reset(); agivSecurity.cancelSecureConversationTokens(); // operate iservice.getData(0); // verify assertFalse(testListener.isCalledIpSts()); assertFalse(testListener.isCalledRSts()); assertFalse(testListener.isCalledSCT()); }
From source file:test.integ.be.agiv.security.ClaimsAwareServiceTest.java
@Test public void testSecurityFrameworkExternalIPSTS() { Service service = ClaimsAwareServiceFactory.getInstance(); // WS-Addressing via JAX-WS IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ClaimsAwareServiceFactory.SERVICE_LOCATION); ExternalTestIPSTSClient externalIpStsClient = new ExternalTestIPSTSClient(); AGIVSecurity agivSecurity = new AGIVSecurity(externalIpStsClient, "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13"); agivSecurity.enable(bindingProvider, false, ClaimsAwareServiceFactory.SERVICE_REALM); iservice.getData(0);//from w ww. java 2 s .c o m // verify assertTrue(externalIpStsClient.isCalled()); }
From source file:test.integ.be.agiv.security.ClaimsAwareServiceTest.java
@Test public void testSecurityFrameworkViaProxy() { Service service = ClaimsAwareServiceFactory.getInstance(); // WS-Addressing via JAX-WS IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, ClaimsAwareServiceFactory.SERVICE_LOCATION); AGIVSecurity agivSecurity = new AGIVSecurity( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword()); agivSecurity.setProxy("localhost", 3128, Type.SOCKS); agivSecurity.enable(bindingProvider, false, ClaimsAwareServiceFactory.SERVICE_REALM); LOG.debug("calling getData"); iservice.getData(0);/*from w w w .j a v a2 s.c o m*/ agivSecurity.cancelSecureConversationTokens(); }
From source file:test.integ.be.agiv.security.CrabReadTest.java
@Test public void testIPSTS() throws Exception { InputStream wsdlInputStream = CrabReadTest.class.getResourceAsStream("/CrabReadService.wsdl"); assertNotNull(wsdlInputStream);/*w ww .j a v a 2s . c o m*/ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document wsdlDocument = documentBuilder.parse(wsdlInputStream); NodeList requestSecurityTokenTemplateNodeList = wsdlDocument .getElementsByTagNameNS(WSConstants.WS_SECURITY_POLICY_NAMESPACE, "RequestSecurityTokenTemplate"); assertEquals(1, requestSecurityTokenTemplateNodeList.getLength()); Element requestSecurityTokenTemplateElement = (Element) requestSecurityTokenTemplateNodeList.item(0); LOG.debug("RequestSecurityTokenTemplate: " + toString(requestSecurityTokenTemplateElement)); NodeList secondaryParametersNodeList = requestSecurityTokenTemplateElement.getChildNodes(); IPSTSClient ipstsClient = new IPSTSClient( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/CertificateMessage", AGIVSecurity.BETA_REALM); // // urn:agiv.be/crab/beta SecurityToken ipStsSecurityToken = ipstsClient.getSecuritytoken(this.config.getCertificate(), this.config.getPrivateKey()); RSTSClient rstsClient = new RSTSClient( "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13"); SecurityToken rStsSecurityToken = rstsClient.getSecurityToken(ipStsSecurityToken, "urn:agiv.be/crab/beta"); LOG.debug("R-STS token received"); SecureConversationClient secureConversationClient = new SecureConversationClient( "http://crab.beta.agiv.be/Read/CrabReadService.svc/wsfedsc"); SecurityToken secureConversationToken = secureConversationClient .getSecureConversationToken(rStsSecurityToken); CrabReadService crabReadService = new CrabReadService(); ICrabRead iCrabRead = crabReadService.getWS2007FederationHttpBindingICrabRead(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iCrabRead; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://crab.beta.agiv.be/Read/CrabReadService.svc/wsfedsc"); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); WSSecurityHandler wsSecurityHandler = new WSSecurityHandler(); SecureConversationTokenTestProvider secureConversationTokenProvider = new SecureConversationTokenTestProvider( secureConversationToken); handlerChain.add(new SecureConversationHandler(secureConversationTokenProvider, wsSecurityHandler, "urn:agiv.be/crab/beta")); handlerChain.add(wsSecurityHandler); iCrabRead.findStraat("Vilvoorde", "Blaesenbergstraat"); }
From source file:test.integ.be.agiv.security.CXFTest.java
@Test public void testCXFWSSecurityPolicy() throws Exception { URL wsdlLocation = new URL("https://auth.beta.agiv.be/ClaimsAwareService/Service.svc?wsdl"); QName serviceName = new QName("http://tempuri.org/", "Service"); Service service = new Service(wsdlLocation, serviceName); IService iservice = service.getBasicHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc/basic"); bindingProvider.getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new UTCallbackHandler()); bindingProvider.getRequestContext().put(SecurityConstants.USERNAME, this.config.getUsername()); List<Handler> handlerChain = bindingProvider.getBinding().getHandlerChain(); handlerChain.add(new LoggingHandler()); bindingProvider.getBinding().setHandlerChain(handlerChain); iservice.getData(0);/* w ww. j a va 2s . c o m*/ }
From source file:test.integ.be.agiv.security.CXFTest.java
/** * Because of a bug in cxf-rt-ws-mex (retrieval over SOAP 1.1 while endpoint * is a SOAP 1.2) we disabled WS-Policy via cxf.xml *//* www.j a v a 2 s .c om*/ @Test public void testClaimsAwareService() { Service service = ClaimsAwareServiceFactory.getInstance(); // WS-Addressing via JAX-WS IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc"); AGIVSecurity agivSecurity = new AGIVSecurity( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword()); agivSecurity.enable(bindingProvider, false); agivSecurity.enable(bindingProvider, false); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); SecurityToken secureConversationToken = agivSecurity.getSecureConversationTokens().values().iterator() .next(); agivSecurity.cancelSecureConversationTokens(); iservice.getData(0); SecurityToken secureConversationToken2 = agivSecurity.getSecureConversationTokens().values().iterator() .next(); assertFalse(secureConversationToken.getAttachedReference() .equals(secureConversationToken2.getAttachedReference())); }
From source file:test.integ.be.agiv.security.CXFTest.java
/** * Not working.//from ww w . j a v a 2 s .c om */ @Test public void testClaimsAwareServiceProxy() { JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean(); // factory.setServiceClass(Service.class); factory.setWsdlLocation("classpath:/ClaimsAwareService.wsdl"); QName serviceName = new QName("http://tempuri.org/", "Service"); factory.setServiceName(serviceName); List<AbstractFeature> features = new LinkedList<AbstractFeature>(); WSPolicyFeature wsPolicyFeature = new WSPolicyFeature(); wsPolicyFeature.setEnabled(false); wsPolicyFeature.setAlternativeSelector(null); features.add(wsPolicyFeature); WSAddressingFeature wsAddressingFeature = new WSAddressingFeature(); features.add(wsAddressingFeature); factory.setFeatures(features); IService iservice = (IService) factory.create(IService.class); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc"); AGIVSecurity agivSecurity = new AGIVSecurity( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword()); agivSecurity.enable(bindingProvider, false); agivSecurity.enable(bindingProvider, false); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); SecurityToken secureConversationToken = agivSecurity.getSecureConversationTokens().values().iterator() .next(); agivSecurity.cancelSecureConversationTokens(); iservice.getData(0); SecurityToken secureConversationToken2 = agivSecurity.getSecureConversationTokens().values().iterator() .next(); assertFalse(secureConversationToken.getAttachedReference() .equals(secureConversationToken2.getAttachedReference())); }
From source file:test.integ.be.agiv.security.CXFTest.java
/** * Not working./* w w w. java2s . com*/ */ @Test public void testClaimsAwareServiceBus() { Bus bus = BusFactory.getDefaultBus(); for (Feature feature : bus.getFeatures()) { LOG.debug("feature: " + feature); if (feature instanceof WSPolicyFeature) { LOG.debug("WS-Policy feature detected"); WSPolicyFeature wsPolicyFeature = (WSPolicyFeature) feature; wsPolicyFeature.setEnabled(false); // doesn't work } } BusFactory.setThreadDefaultBus(bus); Service service = ClaimsAwareServiceFactory.getInstance(); // WS-Addressing via JAX-WS IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc"); AGIVSecurity agivSecurity = new AGIVSecurity( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, this.config.getUsername(), this.config.getPassword()); agivSecurity.enable(bindingProvider, false); agivSecurity.enable(bindingProvider, false); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); LOG.debug("calling getData"); iservice.getData(0); SecurityToken secureConversationToken = agivSecurity.getSecureConversationTokens().values().iterator() .next(); agivSecurity.cancelSecureConversationTokens(); iservice.getData(0); SecurityToken secureConversationToken2 = agivSecurity.getSecureConversationTokens().values().iterator() .next(); assertFalse(secureConversationToken.getAttachedReference() .equals(secureConversationToken2.getAttachedReference())); }
From source file:test.integ.be.agiv.security.GipodTest.java
@Test public void testGipodManualSecurity() throws Exception { InputStream wsdlInputStream = CrabReadTest.class.getResourceAsStream("/GipodService.wsdl"); assertNotNull(wsdlInputStream);/*w w w .j ava2 s .co m*/ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document wsdlDocument = documentBuilder.parse(wsdlInputStream); NodeList requestSecurityTokenTemplateNodeList = wsdlDocument .getElementsByTagNameNS(WSConstants.WS_SECURITY_POLICY_NAMESPACE, "RequestSecurityTokenTemplate"); assertEquals(1, requestSecurityTokenTemplateNodeList.getLength()); Element requestSecurityTokenTemplateElement = (Element) requestSecurityTokenTemplateNodeList.item(0); NodeList secondaryParametersNodeList = requestSecurityTokenTemplateElement.getChildNodes(); IPSTSClient ipstsClient = new IPSTSClient( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", AGIVSecurity.BETA_REALM, secondaryParametersNodeList); SecurityToken ipStsSecurityToken = ipstsClient.getSecurityToken(this.config.getUsername(), this.config.getPassword()); RSTSClient rstsClient = new RSTSClient( "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13"); SecurityToken rStsSecurityToken = rstsClient.getSecurityToken(ipStsSecurityToken, "urn:agiv.be/gipodbeta"); // "https://wsgipod.beta.agiv.be/SOAP/GipodService.svc"); WSSecurityHandler wsSecurityHandler = new WSSecurityHandler(); TestSecurityTokenProvider securityTokenProvider = new TestSecurityTokenProvider(); securityTokenProvider.addSecurityToken("https://wsgipod.beta.agiv.be/SOAP/GipodService.svc", rStsSecurityToken); AuthenticationHandler authenticationHandler = new AuthenticationHandler(securityTokenProvider, wsSecurityHandler, null); GipodService service = new GipodService(); IGipodService iGipodService = service.getWS2007FederationHttpBindingIGipodService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iGipodService; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://wsgipod.beta.agiv.be/SOAP/GipodService.svc"); Binding binding = bindingProvider.getBinding(); List<Handler> handlerChain = binding.getHandlerChain(); handlerChain.add(authenticationHandler); handlerChain.add(wsSecurityHandler); binding.setHandlerChain(handlerChain); iGipodService.getListLand(); }
From source file:test.integ.be.agiv.security.metro.MetroTest.java
@Test public void testClaimsAwareService() { URL wsdlLocation = SecurityTokenService_Service.class.getResource("/ClaimsAwareService-metro.wsdl"); QName serviceName = new QName("http://tempuri.org/", "Service"); Service service = new Service(wsdlLocation, serviceName); // WS-Addressing via JAX-WS IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "https://auth.beta.agiv.be/ClaimsAwareService/Service.svc"); LOG.debug("calling getData"); iservice.getData(0);//from w w w .j a va 2s. co m }