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:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java

/**
 * Update document in DTL/*w ww  .j a v a2 s . co  m*/
 * @param docData The docment data
 * @param docId The document ID
 * @param signResponse The signature response
 * @return True if successful
 * @throws SimpleException
 */
private boolean updateDocumentInDtl(byte[] docData, String docId, String signResponse) throws Exception {
    boolean success = false;
    URL url = null;
    try {
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        success = docservice.updateDocument(docId, signResponse, docData);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in updateDocumentInDtl", e);
    }

    return success;
}

From source file:at.gv.egovernment.moa.id.protocols.stork2.attributeproviders.SignedDocAttributeRequestProvider.java

/**
   * Get document from DTL//from  w w  w .  ja va  2 s. c o m
   * @param transferRequest The transfer request (attribute query)
   * @param eDtlUrl The DTL url of external DTL
   * @return the document data
   * @throws SimpleException
   */
private byte[] getDocumentFromDtl(String transferRequest, String eDtlUrl) throws Exception {
    URL url = null;
    try {
        Logger.debug("getDocumentFromDtl:" + dtlUrl);
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        if (eDtlUrl.equalsIgnoreCase(dtlUrl))
            return docservice.getDocument(transferRequest, "");
        else
            return docservice.getDocument(transferRequest, eDtlUrl);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in getDocumentFromDtl", e);
    }
}

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

/**
 * Registers the logging SOAP handler on the given JAX-WS port component.
 *///  w w  w .  j  a va 2s .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);
}

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

/**
 * Unregister possible logging SOAP handlers on the given JAX-WS port
 * component./* w ww . j  a v a2  s  .co m*/
 */
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.eid.dss.client.DigitalSignatureServiceClient.java

/**
 * Registers the logging SOAP handler on the given JAX-WS port component.
 * /*from w  ww . j a  va  2  s .c  o  m*/
 * @param logToFile
 *            log to file or not
 */
protected void registerLoggerHandler(boolean logToFile) {

    BindingProvider bindingProvider = (BindingProvider) this.port;

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

From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java

/**
 * Unregister possible logging SOAP handlers on the given JAX-WS port
 * component./*  w  ww . j  av a2 s .c  o  m*/
 */
protected void removeLoggerHandler() {

    BindingProvider bindingProvider = (BindingProvider) this.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();
        }

    }
}

From source file:at.gv.egovernment.moa.id.auth.servlet.PEPSConnectorServlet.java

/**
   * Get document from DTL//www .j a  va  2s.com
   * @param transferRequest The transfer request (attribute query)
   * @param eDtlUrl The DTL url of external DTL
   * @return the document data
   * @throws SimpleException
   */
private byte[] getDocumentFromDtl(String transferRequest, String eDtlUrl) throws Exception {
    URL url = null;
    try {
        Logger.debug("getDocumentFromDtl, dtlUrl:'" + dtlUrl + "' eDtlUrl:'" + eDtlUrl + "'");
        url = new URL(dtlUrl);
        QName qname = new QName("http://stork.eu", "DocumentService");

        Service service = Service.create(url, qname);
        DocumentService docservice = service.getPort(DocumentService.class);

        BindingProvider bp = (BindingProvider) docservice;
        SOAPBinding binding = (SOAPBinding) bp.getBinding();
        binding.setMTOMEnabled(true);

        if (eDtlUrl.equalsIgnoreCase(dtlUrl))
            return docservice.getDocument(transferRequest, "");
        else
            return docservice.getDocument(transferRequest, eDtlUrl);
    } catch (Exception e) {
        e.printStackTrace();
        throw new Exception("Error in getDocumentFromDtl", e);
    }
}

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

/**
 * Main constructor./*  ww  w .j a va 2 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.agiv.security.AGIVSecurity.java

/**
 * Disable the AGIV Security framework on the given JAX-WS port.
 * <p/>/*from  w w  w  .j a v  a  2  s . c  om*/
 * Can be used when the JAX-WS stubs are managed by some container and the
 * container strategy is to pool JAX-WS stub instances.
 * 
 * @param bindingProvider
 *            the JAX-WS port.
 * @see AGIVSecurity#enable(BindingProvider)
 * @see AGIVSecurity#enable(BindingProvider, String)
 */
public void disable(BindingProvider bindingProvider) {
    LOG.debug("disabling AGIV security...");
    Binding binding = bindingProvider.getBinding();
    List<Handler> handlerChain = binding.getHandlerChain();
    Iterator<Handler> handlerIterator = handlerChain.iterator();
    while (handlerIterator.hasNext()) {
        Handler handler = handlerIterator.next();
        if (handler instanceof AGIVSOAPHandler) {
            handlerIterator.remove();
            continue;
        }
    }
    binding.setHandlerChain(handlerChain);
}