Example usage for javax.xml.ws BindingProvider getBinding

List of usage examples for javax.xml.ws BindingProvider getBinding

Introduction

In this page you can find the example usage for javax.xml.ws BindingProvider getBinding.

Prototype

Binding getBinding();

Source Link

Document

Get the Binding for this binding provider.

Usage

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);//from   ww  w . j av a  2s . com
}

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);/*from w  w  w .ja  v a  2  s. c om*/

    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();
}