Java Code Examples for org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean#setProviders()

The following examples show how to use org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean#setProviders() . 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: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BookStore createJwsBookStore(String address,
                                     List<?> mbProviders,
                                     boolean encodePayload,
                                     boolean protectHttpHeaders) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    jwsWriter.setProtectHttpHeaders(protectHttpHeaders);
    jwsWriter.setEncodePayload(encodePayload);
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());
    if (mbProviders != null) {
        providers.addAll(mbProviders);
    }
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.signature.properties",
        "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties");
    return bean.create(BookStore.class);
}
 
Example 2
Source File: JaxRsProxyClientConfiguration.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void setJaxrsResources(JAXRSClientFactoryBean factory) {
    Class<?> serviceClass = getServiceClass();
    if (serviceClass != null) {
        factory.setServiceClass(serviceClass);
    } else if (!StringUtils.isEmpty(scanPackages)) {
        try {
            final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
                ClasspathScanner.findClasses(scanPackages, Path.class, Provider.class);
            factory.setServiceClass(
                JAXRSClientFactoryBeanDefinitionParser.getServiceClass(classes.get(Path.class)));
            factory.setProviders(
                JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class)));
        } catch (Exception ex) {
            throw new ServiceConstructionException(ex);
        }
    }
}
 
Example 3
Source File: JaxRsWebClientConfiguration.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Override
protected void setJaxrsResources(JAXRSClientFactoryBean factory) {
    factory.setServiceClass(WebClient.class);

    if (!StringUtils.isEmpty(scanPackages)) {
        try {
            final Map< Class< ? extends Annotation >, Collection< Class< ? > > > classes =
                ClasspathScanner.findClasses(scanPackages, Provider.class);

            factory.setProviders(
                JAXRSClientFactoryBeanDefinitionParser.getProviders(context, classes.get(Provider.class)));
        } catch (Exception ex) {
            throw new ServiceConstructionException(ex);
        }
    }
}
 
Example 4
Source File: JAXRSJwsMultipartTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private JAXRSClientFactoryBean createJAXRSClientFactoryBean(String address,
                                                            boolean bufferPayload,
                                                            boolean useJwsJsonSignatureFormat) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJwsMultipartTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JwsMultipartClientRequestFilter outFilter = new JwsMultipartClientRequestFilter();
    outFilter.setUseJwsJsonSignatureFormat(useJwsJsonSignatureFormat);
    providers.add(outFilter);
    JwsMultipartClientResponseFilter inFilter = new JwsMultipartClientResponseFilter();
    inFilter.setBufferPayload(bufferPayload);
    providers.add(inFilter);
    providers.add(new JwsDetachedSignatureProvider());
    bean.setProviders(providers);
    return bean;
}
 
Example 5
Source File: JAXRSJwsJsonTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BookStore createBookStore(String address,
                                  Map<String, Object> mapProperties,
                                  List<?> extraProviders,
                                  boolean encodePayload) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJwsJsonTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JwsJsonWriterInterceptor writer = new JwsJsonWriterInterceptor();
    writer.setUseJwsJsonOutputStream(true);
    writer.setEncodePayload(encodePayload);
    providers.add(writer);
    providers.add(new JwsJsonClientResponseFilter());
    if (extraProviders != null) {
        providers.addAll(extraProviders);
    }
    bean.setProviders(providers);
    bean.getProperties(true).putAll(mapProperties);
    return bean.create(BookStore.class);
}
 
Example 6
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testJwsJwkEC() throws Exception {
    String address = "https://localhost:" + PORT + "/jwsjwkec";
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.signature.out.properties",
        "org/apache/cxf/systest/jaxrs/security/jws.ec.private.properties");
    bean.getProperties(true).put("rs.security.signature.in.properties",
        "org/apache/cxf/systest/jaxrs/security/jws.ec.public.properties");
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 7
Source File: RestClientBuilder.java    From microshed-testing with Apache License 2.0 6 votes vote down vote up
public <T> T build(Class<T> clazz) {
    // Apply default values if unspecified
    if (appContextRoot == null)
        appContextRoot = ApplicationEnvironment.Resolver.load().getApplicationURL();
    if (jaxrsPath == null)
        jaxrsPath = locateApplicationPath(clazz);
    if (providers == null)
        providers = Collections.singletonList(JsonBProvider.class);

    JAXRSClientFactoryBean bean = new org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean();
    String basePath = join(appContextRoot, jaxrsPath);
    LOG.info("Building rest client for " + clazz + " with base path: " + basePath + " and providers: " + providers);
    bean.setResourceClass(clazz);
    bean.setProviders(providers);
    bean.setAddress(basePath);
    bean.setHeaders(headers);
    return bean.create(clazz);
}
 
Example 8
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void doTestJweJwkAesCbcHMac(String propFile) throws Exception {
    String address = "https://localhost:" + PORT + "/jwejwkaescbchmac";
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    providers.add(new JweClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.encryption.properties", propFile);
    PrivateKeyPasswordProvider provider =
        new PrivateKeyPasswordProviderImpl("Thus from my lips, by yours, my sin is purged.");
    bean.getProperties(true).put("rs.security.key.password.provider", provider);
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 9
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testJweJwkAesWrap() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejwkaeswrap";
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    providers.add(new JweClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.encryption.properties",
                                 "org/apache/cxf/systest/jaxrs/security/secret.jwk.properties");
    bean.getProperties(true).put("jose.debug", true);
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 10
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BookStore createJweBookStore(String address,
                                  List<?> mbProviders) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    providers.add(new JweClientResponseFilter());
    if (mbProviders != null) {
        providers.addAll(mbProviders);
    }
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.encryption.out.properties",
                                 "org/apache/cxf/systest/jaxrs/security/bob.jwk.properties");
    bean.getProperties(true).put("rs.security.encryption.in.properties",
                                 "org/apache/cxf/systest/jaxrs/security/alice.jwk.properties");
    return bean.create(BookStore.class);
}
 
Example 11
Source File: JAXRSJweJsonTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
private BookStore createBookStore(String address, String propLoc) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJsonTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweJsonWriterInterceptor writer = new JweJsonWriterInterceptor();
    providers.add(writer);
    providers.add(new JweJsonClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put(JoseConstants.RSSEC_ENCRYPTION_PROPS,
                                 propLoc);
    return bean.create(BookStore.class);
}
 
Example 12
Source File: JAXRSUtilities.java    From microprofile-sandbox with Apache License 2.0 6 votes vote down vote up
public static <T> T createRestClient(Class<T> clazz, String appContextRoot, String applicationPath, String jwt) {
    Objects.requireNonNull(appContextRoot, "Supplied 'appContextRoot' must not be null");
    Objects.requireNonNull(applicationPath, "Supplied 'applicationPath' must not be null");
    String basePath = join(appContextRoot, applicationPath);
    // TODO: Allow the provider list to be customized
    List<Class<?>> providers = Collections.singletonList(JsonBProvider.class);
    LOGGER.info("Building rest client for " + clazz + " with base path: " + basePath + " and providers: " + providers);
    JAXRSClientFactoryBean bean = new org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean();
    bean.setProviders(providers);
    bean.setAddress(basePath);
    if(jwt != null && jwt.length()>0) {
     Map headers = new HashMap();
     headers.put("Authorization", "Bearer " + jwt);
     bean.setHeaders(headers);
    }
    bean.setResourceClass(clazz);
    return bean.create(clazz);        
    //return JAXRSClientFactory.create(basePath, clazz, providers);
}
 
Example 13
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testJweRsaJwsRsaEncryptThenSign() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejwsrsaencrsign";

    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new EncrSignJweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    JwsWriterInterceptor jwsWriter = new EncrSignJwsWriterInterceptor();
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.encryption.out.properties", SERVER_JWEJWS_PROPERTIES);
    bean.getProperties(true).put("rs.security.signature.out.properties", CLIENT_JWEJWS_PROPERTIES);
    PrivateKeyPasswordProvider provider = new PrivateKeyPasswordProviderImpl();
    bean.getProperties(true).put("rs.security.signature.key.password.provider", provider);
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 14
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testJweRsaJwsRsaCert() throws Exception {
    String address = "https://localhost:" + PORT + "/jwejwsrsacert";

    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    providers.add(new JweClientResponseFilter());
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());

    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.keystore.file",
                                 "org/apache/cxf/systest/jaxrs/security/certs/jwkPublicSet.txt");
    bean.getProperties(true).put("rs.security.signature.out.properties", CLIENT_JWEJWS_PROPERTIES);
    bean.getProperties(true).put("rs.security.encryption.in.properties", CLIENT_JWEJWS_PROPERTIES);
    PrivateKeyPasswordProvider provider = new PrivateKeyPasswordProviderImpl();
    bean.getProperties(true).put("rs.security.signature.key.password.provider", provider);
    bean.getProperties(true).put("rs.security.decryption.key.password.provider", provider);
    BookStore bs = bean.create(BookStore.class);

    WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jwe.out", "AliceCert");
    WebClient.getConfig(bs).getRequestContext().put("rs.security.keystore.alias.jws.in", "AliceCert");
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 15
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void doTestJwsJwkRSA(String address,
                             boolean includePublicKey,
                             boolean includeKeyId) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.signature.out.properties",
        "org/apache/cxf/systest/jaxrs/security/alice.jwk.properties");
    bean.getProperties(true).put("rs.security.signature.in.properties",
        "org/apache/cxf/systest/jaxrs/security/bob.jwk.properties");
    if (includePublicKey) {
        bean.getProperties(true).put("rs.security.signature.include.public.key", true);
    }
    if (includeKeyId) {
        bean.getProperties(true).put("rs.security.signature.include.key.id", true);
    }
    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 16
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
private BookStore createJweJwsBookStore(String address,
                             JwsSignatureProvider jwsSigProvider,
                             List<?> mbProviders) throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    providers.add(jweWriter);
    providers.add(new JweClientResponseFilter());
    JwsWriterInterceptor jwsWriter = new JwsWriterInterceptor();
    if (jwsSigProvider != null) {
        jwsWriter.setSignatureProvider(jwsSigProvider);
    }
    jwsWriter.setUseJwsOutputStream(true);
    providers.add(jwsWriter);
    providers.add(new JwsClientResponseFilter());
    if (mbProviders != null) {
        providers.addAll(mbProviders);
    }
    bean.setProviders(providers);
    bean.getProperties(true).put("rs.security.encryption.out.properties", SERVER_JWEJWS_PROPERTIES);
    bean.getProperties(true).put("rs.security.signature.out.properties", CLIENT_JWEJWS_PROPERTIES);
    bean.getProperties(true).put("rs.security.encryption.in.properties", CLIENT_JWEJWS_PROPERTIES);
    bean.getProperties(true).put("rs.security.signature.in.properties", SERVER_JWEJWS_PROPERTIES);
    PrivateKeyPasswordProvider provider = new PrivateKeyPasswordProviderImpl();
    bean.getProperties(true).put("rs.security.signature.key.password.provider", provider);
    bean.getProperties(true).put("rs.security.decryption.key.password.provider", provider);
    return bean.create(BookStore.class);
}
 
Example 17
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testJweAesGcmDirect() throws Exception {
    String address = "https://localhost:" + PORT + "/jweaesgcmdirect";
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    // writer
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);
    // reader
    JweClientResponseFilter jweReader = new JweClientResponseFilter();

    providers.add(jweWriter);
    providers.add(jweReader);
    bean.setProviders(providers);

    bean.getProperties(true).put("rs.security.encryption.properties",
                                 "org/apache/cxf/systest/jaxrs/security/jwe.direct.properties");

    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 18
Source File: JAXRSJweJwsTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testJweAesCbcHmac() throws Exception {
    String address = "https://localhost:" + PORT + "/jweaescbchmac";
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = JAXRSJweJwsTest.class.getResource("client.xml");
    Bus springBus = bf.createBus(busFile.toString());
    bean.setBus(springBus);
    bean.setServiceClass(BookStore.class);
    bean.setAddress(address);
    List<Object> providers = new LinkedList<>();
    // writer
    JweWriterInterceptor jweWriter = new JweWriterInterceptor();
    jweWriter.setUseJweOutputStream(true);

    final String cekEncryptionKey = "GawgguFyGrWKav7AX4VKUg";
    AesWrapKeyEncryptionAlgorithm keyEncryption =
        new AesWrapKeyEncryptionAlgorithm(cekEncryptionKey, KeyAlgorithm.A128KW);
    jweWriter.setEncryptionProvider(new AesCbcHmacJweEncryption(ContentAlgorithm.A128CBC_HS256,
                                                                keyEncryption));

    // reader
    JweClientResponseFilter jweReader = new JweClientResponseFilter();
    jweReader.setDecryptionProvider(new AesCbcHmacJweDecryption(
                                new AesWrapKeyDecryptionAlgorithm(cekEncryptionKey)));

    providers.add(jweWriter);
    providers.add(jweReader);
    bean.setProviders(providers);

    BookStore bs = bean.create(BookStore.class);
    String text = bs.echoText("book");
    assertEquals("book", text);
}
 
Example 19
Source File: SelfKeymasterClientContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
@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 20
Source File: IdentityManagementEndpointUtil.java    From carbon-identity-framework with Apache License 2.0 5 votes vote down vote up
public static <T> T create(String baseAddress, Class<T> cls, List<?> providers, String configLocation,
                           Map<String, String> headers) {

    JAXRSClientFactoryBean bean = getBean(baseAddress, cls, configLocation, headers);
    bean.setProviders(providers);
    return bean.create(cls, new Object[0]);
}