Java Code Examples for org.apache.cxf.jaxrs.client.WebClient#getConfig()
The following examples show how to use
org.apache.cxf.jaxrs.client.WebClient#getConfig() .
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: CqApiTest.java From swagger-aem with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost", CqApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 2
Source File: AmbariClientBuilder.java From components with Apache License 2.0 | 5 votes |
/** * Closes the transport level conduit in the client. Reopening a new connection, requires creating a new client * object using the build() method in this builder. * * @param root The resource returned by the build() method of this builder class */ public static void closeClient(ApiRootResource root) { ClientConfiguration config = WebClient.getConfig(root); HTTPConduit conduit = config.getHttpConduit(); if (conduit == null) { throw new IllegalArgumentException("Client is not using the HTTP transport"); } conduit.close(); }
Example 3
Source File: StoreApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 4
Source File: CustomApiTest.java From swagger-aem with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost", CustomApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 5
Source File: ClientInterceptorTest.java From gazpachoquest with GNU General Public License v3.0 | 5 votes |
private QuestionnaireResource getQuestionnaireResource() { QuestionnaireResource questionnaireResource = JAXRSClientFactory.create(BASE_URI, QuestionnaireResource.class, Collections.singletonList(getJacksonProvider()), null); Client client = WebClient.client(questionnaireResource); ClientConfiguration config = WebClient.getConfig(client); String apiKey = "FGFQM8T6YPVSW4Q"; String secret = "39JYOYPWYR46R38OAOTVRZJMEXNJ46HL"; config.getOutInterceptors().add(new HmacAuthInterceptor(apiKey, secret)); return questionnaireResource; }
Example 6
Source File: CustomApiTest.java From swagger-aem with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost", CustomApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 7
Source File: PetApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://petstore.swagger.io:80/v2", PetApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 8
Source File: ResourceProducer.java From gazpachoquest with GNU General Public License v3.0 | 5 votes |
@Produces @GazpachoResource @RequestScoped public QuestionnaireResource createQuestionnairResource(HttpServletRequest request) { RespondentAccount principal = (RespondentAccount) request.getUserPrincipal(); String apiKey = principal.getApiKey(); String secret = principal.getSecret(); logger.info("Getting QuestionnaireResource using api key {}/{} ", apiKey, secret); JacksonJsonProvider jacksonProvider = new JacksonJsonProvider(); ObjectMapper mapper = new ObjectMapper(); // mapper.findAndRegisterModules(); mapper.registerModule(new JSR310Module()); mapper.setSerializationInclusion(Include.NON_EMPTY); mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); jacksonProvider.setMapper(mapper); QuestionnaireResource resource = JAXRSClientFactory.create(BASE_URI, QuestionnaireResource.class, Collections.singletonList(jacksonProvider), null); // proxies // WebClient.client(resource).header("Authorization", "GZQ " + apiKey); Client client = WebClient.client(resource); ClientConfiguration config = WebClient.getConfig(client); config.getOutInterceptors().add(new HmacAuthInterceptor(apiKey, secret)); return resource; }
Example 9
Source File: ActionConfigApiTest.java From opencps-v2 with GNU Affero General Public License v3.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("https://virtserver.swaggerhub.com/binhthgc/opencps/1.0.0", ActionConfigApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 10
Source File: StatisticReportApiTest.java From opencps-v2 with GNU Affero General Public License v3.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("https://virtserver.swaggerhub.com/binhthgc/opencps/1.0.0", StatisticReportApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 11
Source File: StoreApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://petstore.swagger.io/v2", StoreApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 12
Source File: ConsoleApiTest.java From swagger-aem with Apache License 2.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost", ConsoleApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 13
Source File: FakeApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { List<?> providers = Arrays.asList(new JacksonJsonProvider(), new JacksonXMLProvider(), new MultipartProvider()); api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", FakeApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 14
Source File: UserApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { List<?> providers = Arrays.asList(new JacksonJsonProvider(), new JacksonXMLProvider(), new MultipartProvider()); api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", UserApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 15
Source File: RemoteAccessApiTest.java From swaggy-jenkins with MIT License | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("http://localhost", RemoteAccessApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 16
Source File: PetApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { List<?> providers = Arrays.asList(new JacksonJsonProvider(), new JacksonXMLProvider(), new MultipartProvider()); api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", PetApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 17
Source File: StoreApiTest.java From openapi-generator with Apache License 2.0 | 5 votes |
@Before public void setup() { List<?> providers = Arrays.asList(new JacksonJsonProvider(), new JacksonXMLProvider(), new MultipartProvider()); api = JAXRSClientFactory.create("http://localhost:" + serverPort + "/services", StoreApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 18
Source File: MenuConfigApiTest.java From opencps-v2 with GNU Affero General Public License v3.0 | 5 votes |
@Before public void setup() { JacksonJsonProvider provider = new JacksonJsonProvider(); List providers = new ArrayList(); providers.add(provider); api = JAXRSClientFactory.create("https://virtserver.swaggerhub.com/binhthgc/opencps/1.0.0", MenuConfigApi.class, providers); org.apache.cxf.jaxrs.client.Client client = WebClient.client(api); ClientConfiguration config = WebClient.getConfig(client); }
Example 19
Source File: ClientImpl.java From cxf with Apache License 2.0 | 4 votes |
@Override public Builder request() { checkClosed(); Map<String, Object> configProps = getConfiguration().getProperties(); initTargetClientIfNeeded(configProps); ClientProviderFactory pf = ClientProviderFactory.getInstance(WebClient.getConfig(targetClient).getEndpoint()); List<Object> providers = new LinkedList<>(); List<org.apache.cxf.feature.Feature> cxfFeatures = new LinkedList<>(); Configuration cfg = configImpl.getConfiguration(); for (Object p : cfg.getInstances()) { if (p instanceof org.apache.cxf.feature.Feature) { cxfFeatures.add((org.apache.cxf.feature.Feature)p); } else if (!(p instanceof Feature)) { Map<Class<?>, Integer> contracts = cfg.getContracts(p.getClass()); if (contracts == null || contracts.isEmpty()) { providers.add(p); } else { final Class<?> providerCls = ClassHelper.getRealClass(pf.getBus(), p); providers.add(new FilterProviderInfo<Object>(p.getClass(), providerCls, p, pf.getBus(), contracts)); } } } pf.setUserProviders(providers); ClientConfiguration clientCfg = WebClient.getConfig(targetClient); clientCfg.getRequestContext().putAll(configProps); clientCfg.getRequestContext().put(Client.class.getName(), ClientImpl.this); clientCfg.getRequestContext().put(Configuration.class.getName(), getConfiguration()); // Response auto-close Boolean responseAutoClose = getBooleanValue(configProps.get(HTTP_RESPONSE_AUTOCLOSE_PROP)); if (responseAutoClose != null) { clientCfg.getResponseContext().put("response.stream.auto.close", responseAutoClose); } // TLS TLSClientParameters tlsParams = secConfig.getTlsClientParams(); if (tlsParams.getSSLSocketFactory() != null || tlsParams.getTrustManagers() != null || tlsParams.getHostnameVerifier() != null) { clientCfg.getHttpConduit().setTlsClientParameters(tlsParams); } // Executor for the asynchronous calls Object executorServiceProp = configProps.get(AbstractClient.EXECUTOR_SERVICE_PROPERTY); if (executorServiceProp != null) { clientCfg.getResponseContext().put(AbstractClient.EXECUTOR_SERVICE_PROPERTY, executorServiceProp); } setConnectionProperties(configProps, clientCfg); // CXF Features for (org.apache.cxf.feature.Feature cxfFeature : cxfFeatures) { cxfFeature.initialize(clientCfg, clientCfg.getBus()); } // Start building the invocation return new InvocationBuilderImpl(WebClient.fromClient(targetClient), getConfiguration()); }
Example 20
Source File: TrustedIdpOIDCProtocolHandler.java From cxf-fediz with Apache License 2.0 | 4 votes |
private boolean validateSignature(TrustedIdp trustedIdp, JwsJwtCompactConsumer jwtConsumer) throws CertificateException, WSSecurityException, ProcessingException, IOException { // Validate the Signature String sigAlgo = getProperty(trustedIdp, SIGNATURE_ALGORITHM); if (sigAlgo == null || sigAlgo.isEmpty()) { sigAlgo = "RS256"; } JwtToken jwt = jwtConsumer.getJwtToken(); String jwksUri = getProperty(trustedIdp, JWKS_URI); JsonWebKey verifyingKey = null; if (jwksUri != null && jwt.getJwsHeaders() != null && jwt.getJwsHeaders().containsHeader(JoseConstants.HEADER_KEY_ID)) { String kid = (String)jwt.getJwsHeaders().getHeader(JoseConstants.HEADER_KEY_ID); LOG.debug("Attemping to retrieve key id {} from uri {}", kid, jwksUri); List<Object> jsonKeyProviders = new ArrayList<>(); jsonKeyProviders.add(new JsonWebKeysProvider()); WebClient client = WebClient.create(jwksUri, jsonKeyProviders, "cxf-tls.xml"); client.accept("application/json"); ClientConfiguration config = WebClient.getConfig(client); if (LOG.isDebugEnabled()) { config.getOutInterceptors().add(new LoggingOutInterceptor()); config.getInInterceptors().add(new LoggingInInterceptor()); } Response response = client.get(); JsonWebKeys jsonWebKeys = response.readEntity(JsonWebKeys.class); if (jsonWebKeys != null) { verifyingKey = jsonWebKeys.getKey(kid); } } if (verifyingKey != null) { return jwtConsumer.verifySignatureWith(verifyingKey, SignatureAlgorithm.getAlgorithm(sigAlgo)); } X509Certificate validatingCert = CertsUtils.parseX509Certificate(trustedIdp.getCertificate()); if (validatingCert != null) { return jwtConsumer.verifySignatureWith(validatingCert, SignatureAlgorithm.getAlgorithm(sigAlgo)); } LOG.warn("No key supplied to verify the signature of the IdToken"); return false; }