use of javax.ws.rs.client.ClientBuilder in project muikku by otavanopisto.
the class RestClient method createrRestClient.
/**
* Creater rest client.
*
* @return the client
* @throws KeyManagementException
* the key management exception
* @throws NoSuchAlgorithmException
* the no such algorithm exception
*/
private Client createrRestClient() throws KeyManagementException, NoSuchAlgorithmException {
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
ClientBuilder builder = clientBuilder.register(new JacksonConfigurator());
return builder.build();
}
use of javax.ws.rs.client.ClientBuilder in project keycloak by keycloak.
the class MutualTLSUtils method executeUserInfoRequestInGetMethod.
public static Response executeUserInfoRequestInGetMethod(String accessToken, boolean isKeystoreUsed, String keystorePath, String keystorePassward) {
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
KeyStore keystore = null;
// Load the keystore file
if (isKeystoreUsed) {
try {
if (keystorePath != null) {
keystore = KeystoreUtil.loadKeyStore(keystorePath, keystorePassward);
clientBuilder.keyStore(keystore, keystorePassward);
} else {
keystore = KeystoreUtil.loadKeyStore(DEFAULT_KEYSTOREPATH, DEFAULT_KEYSTOREPASSWORD);
clientBuilder.keyStore(keystore, DEFAULT_KEYSTOREPASSWORD);
}
} catch (Exception e) {
e.printStackTrace();
}
}
Client client = clientBuilder.build();
WebTarget userInfoTarget = null;
try {
userInfoTarget = UserInfoClientUtil.getUserInfoWebTarget(client);
} finally {
client.close();
}
return userInfoTarget.request().header(HttpHeaders.AUTHORIZATION, "bearer " + accessToken).get();
}
Aggregations