public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
/** * Set the client-side key store. Key store contains client's private keys, and the certificates with their * corresponding public keys. * <p> * Setting a key store instance resets any {@link #sslContext(javax.net.ssl.SSLContext) SSL context instance} * value previously specified. * </p> * <p> * Note that for improved security of working with password data and avoid storing passwords in Java string * objects, the {@link #keyStore(java.security.KeyStore, char[])} version of the method can be utilized. * Also note that a custom key store is only required if you want to enable a custom setup of a 2-way SSL * connections (client certificate authentication). * </p> * * @param keyStore client-side key store. Must not be {@code null}. * @param password client key password. Must not be {@code null}. * @return an updated client builder instance. * @throws NullPointerException in case any of the supplied parameters is {@code null}. * @see #sslContext * @see #keyStore(java.security.KeyStore, char[]) * @see #trustStore */ public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
/** * Set the client-side key store. Key store contains client's private keys, and the certificates with their * corresponding public keys. * <p> * Setting a key store instance resets any {@link #sslContext(javax.net.ssl.SSLContext) SSL context instance} * value previously specified. * </p> * <p> * Note that for improved security of working with password data and avoid storing passwords in Java string * objects, the {@link #keyStore(java.security.KeyStore, char[])} version of the method can be utilized. * Also note that a custom key store is only required if you want to enable a custom setup of a 2-way SSL * connections (client certificate authentication). * </p> * * @param keyStore client-side key store. Must not be {@code null}. * @param password client key password. Must not be {@code null}. * @return an updated client builder instance. * @throws NullPointerException in case any of the supplied parameters is {@code null}. * @see #sslContext * @see #keyStore(java.security.KeyStore, char[]) * @see #trustStore */ public ClientBuilder keyStore(final KeyStore keyStore, final String password) { return keyStore(keyStore, password.toCharArray()); }
/** * Registers the key store to be used. * * @param keyStore the key store * @param password the password * @return the builder instance */ public ClientBuilderConfigurer keyStore(KeyStore keyStore, char[] password) { builder().keyStore(keyStore, password); return this; }
/** * Registers the key store to be used. * * @param keyStore the key store * @param password the password * @return the builder instance */ public ClientBuilderConfigurer keyStore(KeyStore keyStore, String password) { builder().keyStore(keyStore, password); return this; }
/** * Create custom client with specific keystore. This ignores the need for a truststore. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).build(); }
/** * Create custom client with specific keystore. This ignores the need for a truststore. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).build(); }
/** * Create custom client with specific keystore. This ignores the need for a truststore. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @param clientConfig Client configuration to use when initializing client * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass, ClientConfig clientConfig) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).withConfig(clientConfig).build(); }
/** * Create custom client with specific keystore. This ignores the need for a truststore. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @param clientConfig Client configuration to use when initializing client * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass, ClientConfig clientConfig) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).withConfig(clientConfig).build(); }
/** * Create custom client with specific keystores. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @param trustStore Truststore file * @param trustStorePass Truststore password * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass, String trustStore, String trustStorePass) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); KeyStore tks = KeyStore.getInstance("JKS"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); loadKeyStore(tks, trustStore, trustStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).trustStore(tks).build(); }
/** * Create custom client with specific keystores. * * @param clientKeyStore Client (BOT) keystore * @param clientKeyStorePass Client (BOT) keystore password * @param trustStore Truststore * @param trustStorePass Truststore password * @param clientConfig - HttpClient configuration to use when constructing the client * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(KeyStore clientKeyStore, String clientKeyStorePass, KeyStore trustStore, String trustStorePass, ClientConfig clientConfig) throws Exception { return ClientBuilder.newBuilder().keyStore(clientKeyStore, clientKeyStorePass.toCharArray()).trustStore(trustStore).withConfig(clientConfig).build(); }
/** * Create custom client with specific keystores. * * @param clientKeyStore Client (BOT) keystore * @param clientKeyStorePass Client (BOT) keystore password * @param trustStore Truststore * @param trustStorePass Truststore password * @param clientConfig - HttpClient configuration to use when constructing the client * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(KeyStore clientKeyStore, String clientKeyStorePass, KeyStore trustStore, String trustStorePass, ClientConfig clientConfig) throws Exception { return ClientBuilder.newBuilder().keyStore(clientKeyStore, clientKeyStorePass.toCharArray()).trustStore(trustStore).withConfig(clientConfig).build(); }
/** * Create custom client with specific keystores. * * @param clientKeyStore Client (BOT) keystore file * @param clientKeyStorePass Client (BOT) keystore password * @param trustStore Truststore file * @param trustStorePass Truststore password * @return Custom HttpClient * @throws Exception Generally IOExceptions thrown from instantiation. */ public static Client getClient(String clientKeyStore, String clientKeyStorePass, String trustStore, String trustStorePass) throws Exception { KeyStore cks = KeyStore.getInstance("PKCS12"); KeyStore tks = KeyStore.getInstance("JKS"); loadKeyStore(cks, clientKeyStore, clientKeyStorePass); loadKeyStore(tks, trustStore, trustStorePass); return ClientBuilder.newBuilder().keyStore(cks, clientKeyStorePass.toCharArray()).trustStore(tks).build(); }
public static <T> ClientWrapper<T> httpsInstance(KeyStore keystore, KeyStore truststore, String password, HostnameVerifier hostnameVerifier, Class<T> resultClass) { Client client = ClientBuilder.newBuilder().trustStore(truststore).keyStore(keystore, password.toCharArray()). hostnameVerifier(hostnameVerifier).build(); return new ClientWrapper(client, resultClass); }
/** * Initializes HTTP Client given the application ID. * * @param appId Application identifier * @return HTTP client */ private Client initHttpClient(String appId) { KeystoreProvider keystoreProvider = keystoreProviderFactory.getComponent(); KeystoreSettings appKeystore = keystoreProvider.getApplicationKeystore(appId); final ClientConfig clientConfig = new ClientConfig(); clientConfig.property(ClientProperties.CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT); clientConfig.property(ClientProperties.READ_TIMEOUT, DEFAULT_READ_TIMEOUT); return clientBuilder.withConfig(clientConfig) .keyStore(appKeystore.getData(), appKeystore.getPassword()) .build(); }
@Test public void testGetBook() throws Exception { ClientBuilder builder = ClientBuilder.newBuilder(); try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Truststore.jks", this.getClass())) { KeyStore trustStore = loadStore(keystore, "password"); builder.trustStore(trustStore); } builder.hostnameVerifier(new AllowAllHostnameVerifier()); try (InputStream keystore = ClassLoaderUtils.getResourceAsStream("keys/Morpit.jks", this.getClass())) { KeyStore keyStore = loadStore(keystore, "password"); builder.keyStore(keyStore, "password"); } Client client = builder.build(); client.register(new LoggingFeature()); WebTarget target = client.target("https://localhost:" + PORT + "/bookstore/securebooks/123"); Book b = target.request().accept(MediaType.APPLICATION_XML_TYPE).get(Book.class); assertEquals(123, b.getId()); }