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:be.agiv.security.client.IPSTSClient.java
/** * Main constructor./*ww w. j a v a 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:net.bpelunit.framework.control.deploy.activevos9.ActiveVOSAdministrativeFunctions.java
private void setEndpointForBindingProvider(Object port, String endpoint) { Map<String, Object> requestContext = ((BindingProvider) port).getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint); }
From source file:com.evolveum.midpoint.infra.wsutil.AbstractWebServiceClient.java
protected P createPort() throws Exception { String password = getDefaultPassword(); String username = getDefaultUsername(); String endpointUrl = getDefaultEndpointUrl(); if (commandLine.hasOption('p')) { password = commandLine.getOptionValue('p'); }/* w w w . j a va2s .com*/ if (commandLine.hasOption('u')) { username = commandLine.getOptionValue('u'); } if (commandLine.hasOption('e')) { endpointUrl = commandLine.getOptionValue('e'); } if (verbose) { System.out.println("Username: " + username); System.out.println("Password: <not shown>"); System.out.println("Endpoint URL: " + endpointUrl); } // uncomment this if you want to use Fiddler or any other proxy //ProxySelector.setDefault(new MyProxySelector("127.0.0.1", 8888)); P modelPort = createService().getPort(getPortClass()); BindingProvider bp = (BindingProvider) modelPort; Map<String, Object> requestContext = bp.getRequestContext(); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointUrl); org.apache.cxf.endpoint.Client client = ClientProxy.getClient(modelPort); org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint(); Map<String, Object> wssProps = new HashMap<String, Object>(); if (!commandLine.hasOption('a') || (commandLine.hasOption('a') && WSHandlerConstants.USERNAME_TOKEN.equals(commandLine.getOptionValue('a')))) { wssProps.put(WSHandlerConstants.ACTION, WSHandlerConstants.USERNAME_TOKEN); wssProps.put(WSHandlerConstants.USER, username); wssProps.put(WSHandlerConstants.PASSWORD_TYPE, getPasswordType()); wssProps.put(WSHandlerConstants.PW_CALLBACK_CLASS, ClientPasswordHandler.class.getName()); ClientPasswordHandler.setPassword(password); WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(wssProps); cxfEndpoint.getOutInterceptors().add(wssOut); } else if (commandLine.hasOption('a') && "none".equals(commandLine.getOptionValue('a'))) { // Nothing to do } else { throw new IllegalArgumentException( "Unknown authentication mechanism '" + commandLine.getOptionValue('a') + "'"); } if (commandLine.hasOption('m')) { cxfEndpoint.getInInterceptors().add(new LoggingInInterceptor()); cxfEndpoint.getOutInterceptors().add(new LoggingOutInterceptor()); } return modelPort; }
From source file:be.e_contract.mycarenet.ehbox.EHealthBoxConsultationClient.java
@SuppressWarnings("unchecked") private void configureBindingProvider(BindingProvider bindingProvider, String location) { bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, location); Binding binding = bindingProvider.getBinding(); @SuppressWarnings("rawtypes") List handlerChain = binding.getHandlerChain(); handlerChain.add(this.wsSecuritySOAPHandler); handlerChain.add(this.inboundAttachmentsSOAPHandler); // handlerChain.add(new LoggingHandler()); // LoggingHandler makes CXF fail on the attachments. // https://issues.apache.org/jira/browse/CXF-5496 binding.setHandlerChain(handlerChain); }
From source file:be.e_contract.dssp.client.DigitalSignatureServiceClient.java
/** * Main constructor.//from www . j a v a 2 s .c o 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:de.cosmocode.palava.salesforce.DefaultSalesforceService.java
@Override public Soap connect() throws SalesforceException { LOG.info("Connecting to Salesforce using {}", wsdl.toExternalForm()); final SforceService service = new SforceService(wsdl, Salesforce.SERVICE_NAME); final Soap endpoint = service.getSoap(); assert endpoint instanceof WSBindingProvider : String.format("%s should be an instance of %s", endpoint, WSBindingProvider.class); final WSBindingProvider provider = WSBindingProvider.class.cast(endpoint); final Object address = provider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY); LOG.debug("Connecting to {}", address); LOG.trace("Setting connection timeout to {} {}", connectionTimeout, connectionTimeoutUnit.name().toLowerCase()); final int timeout = (int) connectionTimeoutUnit.toMillis(connectionTimeout); provider.getRequestContext().put("com.sun.xml.ws.request.timeout", timeout); LOG.trace("Enabling Gzip compression"); provider.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, Maps.newHashMap(Salesforce.HTTP_HEADERS)); try {// ww w.j av a 2 s .com LOG.debug("Attempt to login using {}/***", username); final LoginResult result = endpoint.login(username, password + securityToken); final String serverUrl = result.getServerUrl(); LOG.trace("Setting endpoint to {}", serverUrl); provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, serverUrl); final SessionHeader sessionHeader = new SessionHeader(); LOG.trace("Creating new SessionHeader with Id: {}", result.getSessionId()); sessionHeader.setSessionId(result.getSessionId()); final Header header = Headers.create(Salesforce.CONTEXT, sessionHeader); LOG.trace("Setting Header {} in provider {}", header, provider); provider.setOutboundHeaders(header); if (LOG.isTraceEnabled()) { LOG.trace("Logged in as user with ID {}", result.getUserId()); final GetUserInfoResult info = result.getUserInfo(); LOG.trace("Username: {} ({})", info.getUserFullName(), info.getUserName()); LOG.trace("Email: {}", info.getUserEmail()); LOG.trace("Organization: {} [{}]", info.getOrganizationName(), info.getOrganizationId()); LOG.trace("Language: {} / Locale: {}", info.getUserLanguage(), info.getUserLocale()); } } catch (InvalidIdFault e) { throw new SalesforceException("Unable to log into Salesforce", e); } catch (LoginFault e) { throw new SalesforceException("Unable to log into Salesforce", e); } catch (UnexpectedErrorFault e) { throw new SalesforceException("Unable to log into Salesforce", e); } return endpoint; }
From source file:gov.va.ds4p.ds4pmobileportal.pep.XACMLPolicyEnforcement.java
public PolicyEnforcementObject enforceResouce(String purposeOfUse, String actInformationSensitivity, String requestResource) { //if all else fails deny System.out.println("***** VA POLICY ENFORCEMENT REQUEST ********"); this.requestResource = requestResource; this.actInformationSensitivity = actInformationSensitivity; decisionObject = new PolicyEnforcementObject(); requestStart = new Date(); messageId = UUID.randomUUID().toString(); this.purposeOfUse = purposeOfUse; query = new RequestType(); policy = new PolicySetType(); response = new ResponseType(); try {/*from ww w . ja va2 s . c o m*/ getCDAConsentDirectiveFromXDSb(); setXACMLRequestAuthorization(); XACMLPolicyEvaluationServiceService service = new XACMLPolicyEvaluationServiceService(); XACMLPolicyEvaluationService port = service.getXACMLPolicyEvaluationServicePort(); ((BindingProvider) port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pdpEndpoint); response = port.evaluatePolicySet(query, policy); processDecision(); } catch (Exception ex) { ex.printStackTrace(); } requestEnd = new Date(); logEvent(); return decisionObject; }
From source file:at.gv.egiz.pdfas.moa.MOAConnector.java
public byte[] sign(byte[] input, int[] byteRange, SignParameter parameter, RequestedSignature requestedSignature) throws PdfAsException { logger.info("signing with MOA @ " + this.moaEndpoint); /*// w w w. j av a2 s . c om * URL moaUrl; try { moaUrl = new URL(this.moaEndpoint+"?wsdl"); } catch * (MalformedURLException e1) { throw new * PdfAsException("Invalid MOA endpoint!", e1); } */ SignatureCreationService service = new SignatureCreationService(); SignatureCreationPortType creationPort = service.getSignatureCreationPort(); BindingProvider provider = (BindingProvider) creationPort; provider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.moaEndpoint); CreateCMSSignatureRequest request = new CreateCMSSignatureRequest(); request.setKeyIdentifier(this.keyIdentifier.trim()); SingleSignatureInfo sigInfo = new SingleSignatureInfo(); sigInfo.setSecurityLayerConformity(Boolean.TRUE); DataObjectInfo dataObjectInfo = new DataObjectInfo(); dataObjectInfo.setStructure("detached"); DataObject dataObject = new DataObject(); MetaInfoType metaInfoType = new MetaInfoType(); if (parameter.getConfiguration().hasValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG)) { if (IConfigurationConstants.TRUE.equalsIgnoreCase( parameter.getConfiguration().getValue(IConfigurationConstants.SIG_PADES_FORCE_FLAG))) { metaInfoType.setMimeType("application/pdf"); sigInfo.setPAdESConformity(true); } else { metaInfoType.setMimeType("application/pdf"); } } else { metaInfoType.setMimeType("application/pdf"); } dataObject.setMetaInfo(metaInfoType); CMSContentBaseType content = new CMSContentBaseType(); content.setBase64Content(input); dataObject.setContent(content); dataObjectInfo.setDataObject(dataObject); sigInfo.setDataObjectInfo(dataObjectInfo); request.getSingleSignatureInfo().add(sigInfo); requestedSignature.getStatus().getMetaInformations().put(ErrorConstants.STATUS_INFO_SIGDEVICE, SIGNATURE_DEVICE); // TODO: Find a way to get MOA-SPSS Version requestedSignature.getStatus().getMetaInformations().put(ErrorConstants.STATUS_INFO_SIGDEVICEVERSION, "UNKNOWN"); CreateCMSSignatureResponseType response; try { response = creationPort.createCMSSignature(request); } catch (MOAFault e) { logger.warn("MOA signing failed!", e); if (e.getFaultInfo() != null) { throw new PdfAsMOAException(e.getFaultInfo().getErrorCode().toString(), e.getFaultInfo().getInfo(), "", ""); } else { throw new PdfAsMOAException("", e.getMessage(), "", ""); } } if (response.getCMSSignatureOrErrorResponse().size() != 1) { throw new PdfAsException( "Invalid Response Count [" + response.getCMSSignatureOrErrorResponse().size() + "] from MOA!"); } Object resp = response.getCMSSignatureOrErrorResponse().get(0); if (resp instanceof byte[]) { // done the signature! byte[] cmsSignatureData = (byte[]) resp; VerifyResult verifyResult; try { verifyResult = SignatureUtils.verifySignature(cmsSignatureData, input); if (SettingsUtils.getBooleanValue(requestedSignature.getStatus().getSettings(), IConfigurationConstants.KEEP_INVALID_SIGNATURE, false)) { Base64 b64 = new Base64(); requestedSignature.getStatus().getMetaInformations().put(ErrorConstants.STATUS_INFO_INVALIDSIG, b64.encodeToString(cmsSignatureData)); } } catch (PDFASError e) { throw new PdfAsErrorCarrier(e); } if (!StreamUtils.dataCompare(requestedSignature.getCertificate().getFingerprintSHA(), ((X509Certificate) verifyResult.getSignerCertificate()).getFingerprintSHA())) { throw new PdfAsSignatureException("Certificates missmatch!"); } return cmsSignatureData; } else if (resp instanceof ErrorResponseType) { ErrorResponseType err = (ErrorResponseType) resp; throw new PdfAsMOAException("", "", err.getInfo(), err.getErrorCode().toString()); } else { throw new PdfAsException("MOA response is not byte[] nor error but: " + resp.getClass().getName()); } }
From source file:com.clustercontrol.util.EndpointUnit.java
private void setBindingProvider(Object o, String url) { BindingProvider bp = (BindingProvider) o; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userId); bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); bp.getRequestContext().put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192); // Maximum time between establishing a connection and receiving data from the connection (ms) int httpRequestTimeout = EndpointManager.getHttpRequestTimeout(); bp.getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, httpRequestTimeout); if (m_log.isTraceEnabled()) { m_log.trace("ws timeout updated : requestTimeout = " + httpRequestTimeout + ""); }/*from w w w . j a v a 2 s. c o m*/ ((SOAPBinding) bp.getBinding()).setMTOMEnabled(true); }
From source file:be.fedict.eid.dss.client.DigitalSignatureServiceClient.java
private DigitalSignatureServicePortType getPort() { DigitalSignatureService digitalSignatureService = DigitalSignatureServiceFactory.getInstance(); DigitalSignatureServicePortType digitalSignatureServicePort = digitalSignatureService .getDigitalSignatureServicePort(); BindingProvider bindingProvider = (BindingProvider) digitalSignatureServicePort; bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, this.endpointAddress); return digitalSignatureServicePort; }