List of usage examples for javax.xml.ws BindingProvider PASSWORD_PROPERTY
String PASSWORD_PROPERTY
To view the source code for javax.xml.ws BindingProvider PASSWORD_PROPERTY.
Click Source Link
From source file:org.apache.axis2.jaxws.client.PropertyValidator.java
/** * Checks to see if the property value is valid given the name of the property and the type that * is expected by JAX-WS./* ww w .j a va2 s . c o m*/ * * @param propName * @param value * @return */ public static boolean validate(String propName, Object value) { if (log.isDebugEnabled()) { String valueText; if (BindingProvider.USERNAME_PROPERTY.equals(propName) || BindingProvider.PASSWORD_PROPERTY.equals(propName)) { valueText = "xxxxxx"; } else if (value == null) { valueText = "null"; } else if (value instanceof String || value instanceof Boolean || value instanceof Integer) { valueText = value.toString(); } else { valueText = JavaUtils.getObjectIdentity(value); } log.debug("validate property=(" + propName + ") with value=(" + valueText + ")"); } Class expectedType = map.get(propName); if (expectedType != null) { if (expectedType.equals(value.getClass())) { return true; } else { if (log.isDebugEnabled()) { log.debug(" not a valid property. Expected a value of type " + expectedType); } return false; } } return true; }
From source file:org.apache.juddi.adminconsole.hub.UddiAdminHub.java
public String verifyLogin() { EnsureConfig();/*from w w w .j av a 2 s . c o m*/ if (style != AuthStyle.UDDI_AUTH) { if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) juddi; context = bp.getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); } FindBusiness fb = new FindBusiness(); fb.setListHead(0); fb.setMaxRows(1); fb.setFindQualifiers(new FindQualifiers()); fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH); fb.getName().add(new Name(UDDIConstants.WILDCARD, null)); try { GetPublisherDetail publisherDetail = new GetPublisherDetail(); publisherDetail.getPublisherId().add((String) session.getAttribute("username")); juddi.getPublisherDetail(publisherDetail); } catch (Exception ex) { return HandleException(ex); } /* bp = (BindingProvider) juddi; context = bp.getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/ return null; } else { if (token != null) { return token; } if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) juddi; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); } GetAuthToken req = new GetAuthToken(); try { if (security == null) { security = transport.getUDDISecurityService(); } } catch (Exception ex) { return HandleException(ex); } if (session.getAttribute("username") != null && session.getAttribute("password") != null) { req.setUserID((String) session.getAttribute("username")); req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key"))); log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN")); try { AuthToken authToken = security.getAuthToken(req); token = authToken.getAuthInfo(); return null; } catch (Exception ex) { return HandleException(ex); } } } return "Unexpected error"; }
From source file:org.apache.juddi.example.partition.SimpleCreateTmodelPartition.java
/** * Gets a UDDI style auth token, otherwise, appends credentials to the * ws proxies (not yet implemented)//from w ww .j a v a 2 s .c o m * * @param username * @param password * @param style * @return */ private String GetAuthKey(String username, String password, AuthStyle style) { switch (style) { case HTTP: ((BindingProvider) publish).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); ((BindingProvider) publish).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); return null; case UDDI_AUTH: try { GetAuthToken getAuthTokenRoot = new GetAuthToken(); getAuthTokenRoot.setUserID(username); getAuthTokenRoot.setCred(password); // Making API call that retrieves the authentication token for the 'root' user. AuthToken rootAuthToken = security.getAuthToken(getAuthTokenRoot); System.out.println(username + " AUTHTOKEN = (don't log auth tokens!)"); return rootAuthToken.getAuthInfo(); } catch (Exception ex) { System.out.println("Could not authenticate with the provided credentials " + ex.getMessage()); } } return null; }
From source file:org.apache.juddi.v3.client.transport.JAXWSTransport.java
/** * Sets the credentials on the RequestContext if the services are * protected by Basic Authentication. The username and password are * obtained from the uddi.xml.//w w w .ja v a 2 s . c o m * * @param requestContext * @throws ConfigurationException */ private void setCredentials(Map<String, Object> requestContext) throws ConfigurationException { UDDIClient client = UDDIClientContainer.getUDDIClient(clientName); Properties properties = client.getClientConfig().getUDDINode(nodeName).getProperties(); if (properties != null) { String username = null; String password = null; if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) { username = properties.getProperty(Property.BASIC_AUTH_USERNAME); } if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) { password = properties.getProperty(Property.BASIC_AUTH_PASSWORD); } String cipher = null; boolean isEncrypted = false; if (properties.containsKey(Property.BASIC_AUTH_PASSWORD_CP)) { cipher = properties.getProperty(Property.BASIC_AUTH_PASSWORD_CP); } if (properties.containsKey(Property.BASIC_AUTH_PASSWORD_IS_ENC)) { isEncrypted = Boolean.parseBoolean(properties.getProperty(Property.BASIC_AUTH_PASSWORD_IS_ENC)); } if (username != null && password != null) { requestContext.put(BindingProvider.USERNAME_PROPERTY, username); if (isEncrypted) { try { requestContext.put(BindingProvider.PASSWORD_PROPERTY, CryptorFactory.getCryptor(cipher).decrypt(password)); } catch (Exception ex) { logger.error("Unable to decrypt password!", ex); } } else { requestContext.put(BindingProvider.PASSWORD_PROPERTY, password); } } } }
From source file:org.apache.juddi.v3.client.transport.SAPRegistryJAXWSTransport.java
/** * Sets the credentials on the RequestContext if the services are protected * by Basic Authentication. The username and password are obtained from the * uddi.xml./*from ww w . j ava 2s .c om*/ * * @param requestContext * @throws ConfigurationException */ private void setCredentials(Map<String, Object> requestContext) throws ConfigurationException { UDDIClerkManager manager = UDDIClientContainer.getUDDIClerkManager(managerName); Properties properties = manager.getClientConfig().getUDDINode(nodeName).getProperties(); String username = null; String password = null; if (properties.containsKey(Property.BASIC_AUTH_USERNAME)) { username = properties.getProperty(Property.BASIC_AUTH_USERNAME); } if (properties.containsKey(Property.BASIC_AUTH_PASSWORD)) { password = properties.getProperty(Property.BASIC_AUTH_PASSWORD); } if (username != null && password != null) { requestContext.put(BindingProvider.USERNAME_PROPERTY, username); requestContext.put(BindingProvider.PASSWORD_PROPERTY, password); } }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
public String verifyLogin() { EnsureConfig();/*from w ww . j a v a2s. co m*/ token = null; if (style != AuthStyle.UDDI_AUTH) { if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) inquiry; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) publish; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) custody; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) subscription; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); } FindBusiness fb = new FindBusiness(); fb.setListHead(0); fb.setMaxRows(1); fb.setFindQualifiers(new FindQualifiers()); fb.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH); fb.getName().add(new Name(UDDIConstants.WILDCARD, null)); try { inquiry.findBusiness(fb); } catch (Exception ex) { return HandleException(ex); } /* bp = (BindingProvider) juddi; context = bp.getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/ return null; } else { if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) inquiry; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) publish; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) custody; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) subscription; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); } GetAuthToken req = new GetAuthToken(); try { if (security == null) { security = transport.getUDDISecurityService(); } } catch (Exception ex) { return HandleException(ex); } if (session.getAttribute("username") != null && session.getAttribute("password") != null) { req.setUserID((String) session.getAttribute("username")); req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key"))); log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN")); try { AuthToken authToken = security.getAuthToken(req); token = authToken.getAuthInfo(); return null; } catch (Exception ex) { return HandleException(ex); } } } return "Unexpected error"; }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private String GetToken() { EnsureConfig();//w w w. j a v a 2 s . co m if (style != AuthStyle.UDDI_AUTH) { if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) inquiry; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) publish; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) custody; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); bp = (BindingProvider) subscription; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.PASSWORD_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key")))); } /* bp = (BindingProvider) juddi; context = bp.getRequestContext(); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute("username")); context.put(BindingProvider.USERNAME_PROPERTY, session.getAttribute(AES.Decrypt("password", (String) properties.get("key"))));*/ return null; } else { if (token != null) { return token; } if (WS_Transport) { BindingProvider bp = null; Map<String, Object> context = null; bp = (BindingProvider) inquiry; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) publish; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) custody; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); bp = (BindingProvider) subscription; context = bp.getRequestContext(); context.remove(BindingProvider.USERNAME_PROPERTY); context.remove(BindingProvider.PASSWORD_PROPERTY); } GetAuthToken req = new GetAuthToken(); try { if (security == null) { security = transport.getUDDISecurityService(); } } catch (Exception ex) { log.error(ex); } if (session != null && session.getAttribute("username") != null && session.getAttribute("password") != null) { req.setUserID((String) session.getAttribute("username")); req.setCred(AES.Decrypt((String) session.getAttribute("password"), (String) properties.get("key"))); log.info("AUDIT: fetching auth token for " + req.getUserID() + " Auth Mode is " + ((security == null) ? "HTTP" : "AUTH_TOKEN")); try { AuthToken authToken = security.getAuthToken(req); token = authToken.getAuthInfo(); } catch (Exception ex) { return HandleException(ex); } } } return token; }
From source file:org.miloss.fgsms.tests.ManualLoadTests.java
public void init(String url, String username, String password, boolean moreOutput) { this.moreOutput = moreOutput; if (url != null) { bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url); } else {/*from w w w . j ava 2s. com*/ bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, cfg.getPCS_URLS().get(0)); } if (username != null) { bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); } else { bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, cfg.getUsername()); } if (password != null) { bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); } else { bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(cfg.getPassword())); } }
From source file:org.nuxeo.adullact.service.AdullactServiceImpl.java
private InterfaceParapheur serviceSOAPFactory() throws ClientException { // in wsdl definitions target name space QName qname = new QName("http://www.adullact.org/spring-ws/iparapheur/1.0", "InterfaceParapheurService"); URL wsdlUrl = AdullactServiceImpl.class.getResource("/wsdl/iparapheur.xml.wsdl"); Service service = Service.create(wsdlUrl, qname); InterfaceParapheurService ifParapheurService = new InterfaceParapheurService(wsdlUrl, qname); InterfaceParapheur ifParapheur = ifParapheurService.getInterfaceParapheurSoap11(); Map<String, Object> requestContext = ((BindingProvider) ifParapheur).getRequestContext(); requestContext.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.TRUE); requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, webServiceBaseURL.toString()); requestContext.put(BindingProvider.USERNAME_PROPERTY, login); requestContext.put(BindingProvider.PASSWORD_PROPERTY, password); return ifParapheur; }
From source file:org.pentaho.di.repository.pur.WebServiceManager.java
@Override @SuppressWarnings("unchecked") public <T> T createService(final String username, final String password, final Class<T> clazz) throws MalformedURLException { final Future<Object> resultFuture; synchronized (serviceCache) { // if this is true, a coder did not make sure that clearServices was called on disconnect if (lastUsername != null && !lastUsername.equals(username)) { throw new IllegalStateException(); }/* w w w . ja v a2 s . c o m*/ final WebServiceSpecification webServiceSpecification = serviceNameMap.get(clazz); final String serviceName = webServiceSpecification.getServiceName(); if (serviceName == null) { throw new IllegalStateException(); } if (webServiceSpecification.getServiceType().equals(ServiceType.JAX_WS)) { // build the url handling whether or not baseUrl ends with a slash // String baseUrl = repositoryMeta.getRepositoryLocation().getUrl(); final URL url = new URL( baseUrl + (baseUrl.endsWith("/") ? "" : "/") + "webservices/" + serviceName + "?wsdl"); //$NON-NLS-1$ //$NON-NLS-2$ String key = url.toString() + '_' + serviceName + '_' + clazz.getName(); if (!serviceCache.containsKey(key)) { resultFuture = executor.submit(new Callable<Object>() { @Override public Object call() throws Exception { Service service = Service.create(url, new QName(NAMESPACE_URI, serviceName)); T port = service.getPort(clazz); // add TRUST_USER if necessary if (StringUtils .isNotBlank(System.getProperty("pentaho.repository.client.attemptTrust"))) { ((BindingProvider) port).getRequestContext().put( MessageContext.HTTP_REQUEST_HEADERS, Collections.singletonMap(TRUST_USER, Collections.singletonList(username))); } else { // http basic authentication ((BindingProvider) port).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, username); ((BindingProvider) port).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password); } // accept cookies to maintain session on server ((BindingProvider) port).getRequestContext() .put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true); // support streaming binary data // TODO mlowery this is not portable between JAX-WS implementations (uses com.sun) ((BindingProvider) port).getRequestContext() .put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 8192); SOAPBinding binding = (SOAPBinding) ((BindingProvider) port).getBinding(); binding.setMTOMEnabled(true); return port; } }); serviceCache.put(key, resultFuture); } else { resultFuture = serviceCache.get(key); } } else { if (webServiceSpecification.getServiceType().equals(ServiceType.JAX_RS)) { String key = baseUrl.toString() + '_' + serviceName + '_' + clazz.getName(); if (!serviceCache.containsKey(key)) { resultFuture = executor.submit(new Callable<Object>() { @Override public Object call() throws Exception { ClientConfig clientConfig = new DefaultClientConfig(); Client client = Client.create(clientConfig); client.addFilter(new HTTPBasicAuthFilter(username, password)); Class<?>[] parameterTypes = new Class<?>[] { Client.class, URI.class }; String factoryClassName = webServiceSpecification.getServiceClass().getName(); factoryClassName = factoryClassName.substring(0, factoryClassName.lastIndexOf("$")); Class<?> factoryClass = Class.forName(factoryClassName); Method method = factoryClass.getDeclaredMethod( webServiceSpecification.getServiceName(), parameterTypes); T port = (T) method.invoke(null, new Object[] { client, new URI(baseUrl + "/plugin") }); return port; } }); serviceCache.put(key, resultFuture); } else { resultFuture = serviceCache.get(key); } } else { resultFuture = null; } } try { if (clazz.isInterface()) { return UnifiedRepositoryInvocationHandler.forObject((T) resultFuture.get(), clazz); } else { return (T) resultFuture.get(); } } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { Throwable cause = e.getCause(); if (cause != null) { if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else if (cause instanceof MalformedURLException) { throw (MalformedURLException) cause; } } throw new RuntimeException(e); } } }