Java Code Examples for org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean#setPassword()
The following examples show how to use
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean#setPassword() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JAXRSClientServerNonSpringBookTest.java From cxf with Apache License 2.0 | 6 votes |
@Test public void testGetBook123UserModelAuthorize() throws Exception { JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress("http://localhost:" + PORT + "/usermodel/bookstore/books"); bean.setUsername("Barry"); bean.setPassword("password"); bean.setModelRef("classpath:org/apache/cxf/systest/jaxrs/resources/resources.xml"); WebClient proxy = bean.createWebClient(); proxy.path("{id}/authorize", 123); Book book = proxy.get(Book.class); assertEquals(123L, book.getId()); }
Example 2
Source File: AmbariClientBuilder.java From components with Apache License 2.0 | 5 votes |
/** * Build a client proxy, for a specific proxy type. * * @param proxyType proxy type class * @return client proxy stub */ protected <T> T build(Class<T> proxyType) { String address = generateAddress(); T rootResource; // Synchronized on the class to correlate with the scope of clientStaticResources // We want to ensure that the shared bean isn't set concurrently in multiple callers synchronized (AmbariClientBuilder.class) { JAXRSClientFactoryBean bean = cleanFactory(clientStaticResources.getUnchecked(proxyType)); bean.setAddress(address); if (username != null) { bean.setUsername(username); bean.setPassword(password); } if (enableLogging) { bean.setFeatures(Arrays.<AbstractFeature> asList(new LoggingFeature())); } rootResource = bean.create(proxyType); } boolean isTlsEnabled = address.startsWith("https://"); ClientConfiguration config = WebClient.getConfig(rootResource); HTTPConduit conduit = (HTTPConduit) config.getConduit(); if (isTlsEnabled) { TLSClientParameters tlsParams = new TLSClientParameters(); if (!validateCerts) { tlsParams.setTrustManagers(new TrustManager[] { new AcceptAllTrustManager() }); } else if (trustManagers != null) { tlsParams.setTrustManagers(trustManagers); } tlsParams.setDisableCNCheck(!validateCn); conduit.setTlsClientParameters(tlsParams); } HTTPClientPolicy policy = conduit.getClient(); policy.setConnectionTimeout(connectionTimeoutUnits.toMillis(connectionTimeout)); policy.setReceiveTimeout(receiveTimeoutUnits.toMillis(receiveTimeout)); return rootResource; }
Example 3
Source File: SelfKeymasterClientContext.java From syncope with Apache License 2.0 | 5 votes |
@ConditionalOnExpression("#{'${keymaster.address}' matches '^http.+'}") @Bean @ConditionalOnMissingBean(name = "selfKeymasterRESTClientFactoryBean") public JAXRSClientFactoryBean selfKeymasterRESTClientFactoryBean() { JAXRSClientFactoryBean restClientFactoryBean = new JAXRSClientFactoryBean(); restClientFactoryBean.setAddress(address); restClientFactoryBean.setUsername(username); restClientFactoryBean.setPassword(password); restClientFactoryBean.setThreadSafe(true); restClientFactoryBean.setInheritHeaders(true); restClientFactoryBean.setFeatures(List.of(new LoggingFeature())); restClientFactoryBean.setProviders( List.of(new JacksonJsonProvider(), new SelfKeymasterClientExceptionMapper())); return restClientFactoryBean; }
Example 4
Source File: CXFOAuth2HttpClientFactory.java From olingo-odata4 with Apache License 2.0 | 5 votes |
private WebClient getAccessTokenService() { final JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean(); bean.setAddress(oauth2TokenServiceURI.toASCIIString()); bean.setUsername("odatajclient"); bean.setPassword("odatajclient"); return bean.createWebClient(). type(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON_TYPE); }
Example 5
Source File: AmbariClientBuilder.java From components with Apache License 2.0 | 4 votes |
private static JAXRSClientFactoryBean cleanFactory(JAXRSClientFactoryBean bean) { bean.setUsername(null); bean.setPassword(null); bean.setFeatures(Arrays.<AbstractFeature> asList()); return bean; }