Example usage for javax.xml.ws Binding getHandlerChain

List of usage examples for javax.xml.ws Binding getHandlerChain

Introduction

In this page you can find the example usage for javax.xml.ws Binding getHandlerChain.

Prototype

public java.util.List<javax.xml.ws.handler.Handler> getHandlerChain();

Source Link

Document

Gets a copy of the handler chain for a protocol binding instance.

Usage

From source file:be.e_contract.mycarenet.xkms2.XKMS2Client.java

/**
 * Main constructor./*from   ww w.jav a 2 s. c om*/
 * 
 * @param location
 *            the URL of the MyCareNet XKMS 2.0 web service.
 */
public XKMS2Client(String location) {
    XMLKeyManagementService service = XKMS2ServiceFactory.newInstance();
    this.keyServicePort = service.getKeyServiceSoapPort();
    BindingProvider bindingProvider = (BindingProvider) this.keyServicePort;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);

    Binding binding = bindingProvider.getBinding();
    @SuppressWarnings("rawtypes")
    List<Handler> handlerChain = binding.getHandlerChain();
    this.proofOfPossessionSignatureSOAPHandler = new ProofOfPossessionSignatureSOAPHandler();
    handlerChain.add(new LoggingHandler());
    handlerChain.add(this.proofOfPossessionSignatureSOAPHandler);
    this.keyBindingAuthenticationSignatureSOAPHandler = new KeyBindingAuthenticationSignatureSOAPHandler();
    handlerChain.add(this.keyBindingAuthenticationSignatureSOAPHandler);
    handlerChain.add(new LoggingHandler());
    binding.setHandlerChain(handlerChain);

    this.objectFactory = new ObjectFactory();
    this.xmldsigObjectFactory = new be.e_contract.mycarenet.jaxb.xmldsig.ObjectFactory();
    try {
        this.datatypeFactory = DatatypeFactory.newInstance();
    } catch (DatatypeConfigurationException e) {
        throw new RuntimeException("DatatypeFactory error: " + e.getMessage(), e);
    }

}

From source file:test.integ.be.fedict.hsm.ws.WebServiceSecurityTest.java

private void addSOAPHandler(SOAPHandler<SOAPMessageContext> soapHandler,
        DigitalSignatureServicePortType dssPort) {
    BindingProvider bindingProvider = (BindingProvider) dssPort;
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.clear();/*from w  ww . j a va 2 s .  c o  m*/
    handlerChain.add(soapHandler);
    handlerChain.add(new LoggingSOAPHandler());
    binding.setHandlerChain(handlerChain);
}

From source file:test.integ.be.fedict.hsm.ws.WebServiceSecurityTest.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);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(new LoggingSOAPHandler());
    binding.setHandlerChain(handlerChain);

    return dssPort;
}

From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactServiceClient.java

protected void registerSoapHandler(SOAPHandler soapHandler) {

    BindingProvider bindingProvider = (BindingProvider) this.port;

    Binding binding = bindingProvider.getBinding();
    @SuppressWarnings("unchecked")
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(soapHandler);//from  ww  w.ja  va  2  s . co  m
    binding.setHandlerChain(handlerChain);
}

From source file:be.fedict.eid.idp.sp.protocol.saml2.artifact.ArtifactServiceClient.java

protected void removeSoapHandler(Class<? extends SOAPHandler> soapHandlerClass) {

    BindingProvider bindingProvider = (BindingProvider) this.port;

    Binding binding = bindingProvider.getBinding();
    @SuppressWarnings("unchecked")
    List<Handler> handlerChain = binding.getHandlerChain();
    Iterator<Handler> iter = handlerChain.iterator();
    while (iter.hasNext()) {
        Handler handler = iter.next();
        if (handler.getClass().isAssignableFrom(soapHandlerClass)) {
            iter.remove();/*from  w  ww.j a v a2 s. co m*/
        }

    }
}

From source file:be.agiv.security.client.IPSTSClient.java

/**
 * Main constructor./*from w ww .  j a  va  2 s  .  c om*/
 * 
 * @param location
 *            the location of the IP-STS WS-Trust web service.
 * @param realm
 *            the AGIV R-STS realm.
 * @param secondaryParametersNodeList
 *            the DOM node list that will be used as SecondaryParameters for
 *            RST requests.
 */
public IPSTSClient(String location, String realm, NodeList secondaryParametersNodeList) {
    this.location = location;
    this.realm = realm;

    Provider jaxwsProvider = Provider.provider();
    LOG.debug("JAX-WS provider: " + jaxwsProvider.getClass().getName());

    SecurityTokenService_Service service = SecurityTokenServiceFactory.getInstance();
    this.port = service.getSecurityTokenServicePort();
    BindingProvider bindingProvider = (BindingProvider) this.port;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    this.wsTrustHandler = new WSTrustHandler();
    this.wsTrustHandler.setSecondaryParameters(secondaryParametersNodeList);
    handlerChain.add(this.wsTrustHandler);
    this.wsAddressingHandler = new WSAddressingHandler();
    handlerChain.add(this.wsAddressingHandler);
    this.wsSecurityHandler = new WSSecurityHandler();
    handlerChain.add(this.wsSecurityHandler);
    handlerChain.add(new LoggingHandler());
    binding.setHandlerChain(handlerChain);

    this.objectFactory = new ObjectFactory();
    this.policyObjectFactory = new be.agiv.security.jaxb.wspolicy.ObjectFactory();
    this.addrObjectFactory = new be.agiv.security.jaxb.wsaddr.ObjectFactory();
    this.wssObjectFactory = new be.agiv.security.jaxb.wsse.ObjectFactory();

    this.secureRandom = new SecureRandom();
    this.secureRandom.setSeed(System.currentTimeMillis());
}

From source file:be.e_contract.dssp.client.DigitalSignatureServiceClient.java

/**
 * Main constructor./*from   w  w  w . j ava2  s. co m*/
 * 
 * @param address
 *            the location of the DSSP web service.
 */
public DigitalSignatureServiceClient(String address) {
    DigitalSignatureService digitalSignatureService = DigitalSignatureServiceFactory.newInstance();
    this.dssPort = digitalSignatureService.getDigitalSignatureServicePort();

    BindingProvider bindingProvider = (BindingProvider) this.dssPort;
    bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);

    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    this.attachmentsSOAPHandler = new AttachmentsLogicalHandler();
    handlerChain.add(this.attachmentsSOAPHandler);
    this.wsSecuritySOAPHandler = new WSSecuritySOAPHandler();
    handlerChain.add(this.wsSecuritySOAPHandler);
    this.wsTrustSOAPHandler = new WSTrustSOAPHandler();
    handlerChain.add(this.wsTrustSOAPHandler);
    // cannot add LoggingSOAPHandler here, else we break SOAP with
    // attachments on Apache CXF
    binding.setHandlerChain(handlerChain);

    this.objectFactory = new ObjectFactory();
    this.wstObjectFactory = new be.e_contract.dssp.ws.jaxb.wst.ObjectFactory();
    this.dsObjectFactory = new be.e_contract.dssp.ws.jaxb.xmldsig.ObjectFactory();
    this.asyncObjectFactory = new be.e_contract.dssp.ws.jaxb.dss.async.ObjectFactory();
    this.wsseObjectFactory = new be.e_contract.dssp.ws.jaxb.wsse.ObjectFactory();
    this.vrObjectFactory = new be.e_contract.dssp.ws.jaxb.dss.vr.ObjectFactory();

    this.secureRandom = new SecureRandom();
    this.secureRandom.setSeed(System.currentTimeMillis());

    try {
        this.certificateFactory = CertificateFactory.getInstance("X.509");
    } catch (CertificateException e) {
        throw new RuntimeException(e);
    }
}

From source file:be.fedict.trust.client.XKMS2Client.java

/**
 * Unregister possible logging SOAP handlers on the given JAX-WS port
 * component./*from w ww. j  a  va 2 s  . c om*/
 */
private void removeLoggerHandler(Object port) {
    BindingProvider bindingProvider = (BindingProvider) port;
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    Iterator<Handler> iter = handlerChain.iterator();
    while (iter.hasNext()) {
        Handler handler = iter.next();
        if (handler instanceof LoggingSoapHandler) {
            iter.remove();
        }
    }
    binding.setHandlerChain(handlerChain);
}

From source file:be.fedict.trust.client.XKMS2Client.java

/**
 * Registers the logging SOAP handler on the given JAX-WS port component.
 *//*from w w  w. ja  va2  s. c  o  m*/
private void registerLoggerHandler(Object port) {
    BindingProvider bindingProvider = (BindingProvider) port;
    Binding binding = bindingProvider.getBinding();
    @SuppressWarnings("rawtypes")
    List<Handler> handlerChain = binding.getHandlerChain();
    handlerChain.add(new LoggingSoapHandler());
    binding.setHandlerChain(handlerChain);
}

From source file:be.fedict.trust.client.XKMS2Client.java

private void registeredWSSecurityHandler(Object port) {
    BindingProvider bindingProvider = (BindingProvider) port;
    Binding binding = bindingProvider.getBinding();
    @SuppressWarnings("rawtypes")
    List<Handler> handlerChain = binding.getHandlerChain();
    this.wsSecurityClientHandler = new WSSecurityClientHandler();
    handlerChain.add(this.wsSecurityClientHandler);
    binding.setHandlerChain(handlerChain);
}