public void setupAuthenticationCredentials(final String userName, final String password) { final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic( Objects.requireNonNull(userName), Objects.requireNonNull(password) ); client.register(feature); }
/** * Create the http authentication feature in basic preemptive authentication mode initialized with credentials. * * @param username Username. * @param password Password as {@code byte array}. * @return Http authentication feature configured in basic mode. */ public static HttpAuthenticationFeature basic(String username, byte[] password) { return build(Mode.BASIC_PREEMPTIVE, username, password); }
public Client addAuthType(Client client, Parameters p) throws SvcLogicException { if (p.authtype == AuthType.Unspecified) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else if (p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null) { if (p.authtype == AuthType.DIGEST) { if (p.restapiUser != null && p.restapiPassword != null) { client.register(HttpAuthenticationFeature.digest(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException( client.register(HttpAuthenticationFeature.basic(p.restapiUser, p.restapiPassword)); } else { throw new SvcLogicException(
HttpAuthenticationFeature basicAuth = HttpAuthenticationFeature.basicBuilder() .credentials(builder.clientId, builder.clientSecret) .build();
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
@Override protected EurekaHttpClient getEurekaHttpClient(URI serviceURI) { Jersey2ApplicationClientFactoryBuilder factoryBuilder = Jersey2ApplicationClientFactory.newBuilder(); if (serviceURI.getUserInfo() != null) { factoryBuilder.withFeature(HttpAuthenticationFeature.basicBuilder().build()); } TransportClientFactory clientFactory = factoryBuilder.build(); jersey2HttpClient = (AbstractJersey2EurekaHttpClient) clientFactory.newClient(new DefaultEndpoint(serviceURI.toString())); return jersey2HttpClient; } }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
private ClientConfig _setCredentials(String userId, String password) { HttpAuthenticationFeature httpAuthenticationFeature = HttpAuthenticationFeature.basic(userId, password); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(httpAuthenticationFeature); return clientConfig; }
/** * Create the http authentication feature in basic preemptive authentication mode initialized with credentials. * * @param username Username. * @param password Password as {@code byte array}. * @return Http authentication feature configured in basic mode. */ public static HttpAuthenticationFeature basic(String username, byte[] password) { return build(Mode.BASIC_PREEMPTIVE, username, password); }
private Client newHttpClient() { final HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder() .credentials(username, password).build(); final ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); return ClientBuilder.newClient(clientConfig); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
@Override public void setConf(Configuration conf) { super.setConf(conf); if (conf == null) { // Configured gets passed null before real conf. Why? I don't know. return; } serverHostname = conf.get(REST_API_CLUSTER_MANAGER_HOSTNAME, DEFAULT_SERVER_HOSTNAME); serverUsername = conf.get(REST_API_CLUSTER_MANAGER_USERNAME, DEFAULT_SERVER_USERNAME); serverPassword = conf.get(REST_API_CLUSTER_MANAGER_PASSWORD, DEFAULT_SERVER_PASSWORD); clusterName = conf.get(REST_API_CLUSTER_MANAGER_CLUSTER_NAME, DEFAULT_CLUSTER_NAME); // Add filter to Client instance to enable server authentication. client.register(HttpAuthenticationFeature.basic(serverUsername, serverPassword)); }
/** * Create the http authentication feature in basic preemptive authentication mode initialized with credentials. * * @param username Username. * @param password Password as {@link String}. * @return Http authentication feature configured in basic mode. */ public static HttpAuthenticationFeature basic(String username, String password) { return build(Mode.BASIC_PREEMPTIVE, username, password); }
HttpAuthenticationFeature httpAuthenticationFeature() { return HttpAuthenticationFeature .basicBuilder() .credentials("api", apiKey()) .build(); } }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
client.property(ClientProperties.CONNECT_TIMEOUT, 2000) .register(new MoxyJsonFeature()) .register(HttpAuthenticationFeature.basic(App.getTwitterUserName(), App.getTwitterUserPassword())) .register(GZipEncoder.class);
/** * Create the http authentication feature in combined mode supporting both, * basic and digest authentication. * * @param username Username. * @param password Password as {@code byte array}. * @return Http authentication feature configured in digest mode. */ public static HttpAuthenticationFeature universal(String username, byte[] password) { return build(Mode.UNIVERSAL, username, password); }
private void setupClient() { HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder() .credentials(username, password).build(); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); clientConfig.register(JsonToMapProvider.class); client = ClientBuilder.newClient(clientConfig); }
@Override public HttpAuthenticationFeature build() { return new HttpAuthenticationFeature(mode, usernameBasic == null ? null : new HttpAuthenticationFilter.Credentials(usernameBasic, passwordBasic), usernameDigest == null ? null : new HttpAuthenticationFilter.Credentials(usernameDigest, passwordDigest)); }
private static Client initializeClient(DirectoryServerConfiguration directoryServerConfiguration) throws CertificateException { KeyStore trustStore = initializeKeyStore(directoryServerConfiguration.getReplicationCaCertificate()); SSLContext sslContext = SslConfigurator.newInstance() .securityProtocol("TLSv1.2") .trustStore(trustStore) .createSSLContext(); return ClientBuilder.newBuilder() .register(HttpAuthenticationFeature.basic("signal", directoryServerConfiguration.getReplicationPassword().getBytes())) .sslContext(sslContext) .build(); }