use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project oxAuth by GluuFederation.
the class JwtUtil method getJSONWebKeys.
public static JSONObject getJSONWebKeys(String jwksUri, ClientHttpEngine engine) {
log.debug("Retrieving jwks " + jwksUri + "...");
JSONObject jwks = null;
try {
if (!StringHelper.isEmpty(jwksUri)) {
ClientBuilder clientBuilder = ResteasyClientBuilder.newBuilder();
if (engine != null) {
((ResteasyClientBuilder) clientBuilder).httpEngine(engine);
}
javax.ws.rs.client.Client clientRequest = clientBuilder.build();
try {
Response clientResponse = clientRequest.target(jwksUri).request().buildGet().invoke();
int status = clientResponse.getStatus();
log.debug(String.format("Status: %n%d", status));
if (status == 200) {
jwks = fromJson(clientResponse.readEntity(String.class));
log.debug(String.format("JWK: %s", jwks));
}
} finally {
clientRequest.close();
}
}
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
}
return jwks;
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project openstack4j by ContainX.
the class HttpCommand method initialize.
private void initialize() {
resteasyWebTarget = new ResteasyClientBuilder().httpEngine(ApacheHttpClientEngine.create(request.getConfig())).providerFactory(ResteasyClientFactory.getInstance()).build().target(UriBuilder.fromUri(new EndpointURIFromRequestFunction().apply(request)));
populateQueryParams(request);
resteasyRequest = resteasyWebTarget.request();
populateHeaders(request);
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project wildfly by wildfly.
the class WildFlyClientTracingRegistrarProvider method configure.
@Override
public ClientBuilder configure(ClientBuilder clientBuilder, ExecutorService executorService) {
Tracer tracer = CDI.current().select(Tracer.class).get();
ResteasyClientBuilder resteasyClientBuilder = (ResteasyClientBuilder) clientBuilder;
return resteasyClientBuilder.executorService(new TracedExecutorService(executorService, tracer)).register(new SmallRyeClientTracingFeature(tracer));
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project syndesis-qe by syndesisio.
the class EndpointClient method getClient.
public static Client getClient(ResteasyJackson2Provider jackson2Provider) {
final ApacheHttpClient43Engine engine = new ApacheHttpClient43Engine(createAllTrustingClient());
final ResteasyProviderFactory providerFactory = new LocalResteasyProviderFactory();
providerFactory.register(jackson2Provider).register(// needed for GET application/octet-stream in PublicAPI to export zip
new InputStreamProvider()).register(// needed to POST mutipart form data (necessary for API provider + PublicAPI)
new MultipartFormDataWriter()).register(// needed to serialize text/plain (again for API provider)
new StringTextStar()).register(new ErrorLogger());
ResteasyClientBuilder clientBuilder = (ResteasyClientBuilder) ResteasyClientBuilder.newBuilder();
clientBuilder.providerFactory(providerFactory);
clientBuilder.httpEngine(engine);
return clientBuilder.build();
}
use of org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder in project openremote by openremote.
the class KeycloakIdentityProvider method init.
@Override
public void init(Container container) {
if (httpClient != null) {
return;
}
sessionMaxSeconds = getInteger(container.getConfig(), IDENTITY_SESSION_MAX_MINUTES, IDENTITY_SESSION_MAX_MINUTES_DEFAULT) * 60;
if (sessionMaxSeconds < 60) {
throw new IllegalArgumentException(IDENTITY_SESSION_MAX_MINUTES + " must be more than 1 minute");
}
// Use the same, as a session is never idle because we periodically check if the refresh token is
// still good in frontend code, this check will reset the idle timeout anyway
sessionTimeoutSeconds = sessionMaxSeconds;
sessionOfflineTimeoutSeconds = getInteger(container.getConfig(), IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES, IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES_DEFAULT) * 60;
if (sessionOfflineTimeoutSeconds < 60) {
throw new IllegalArgumentException(IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES + " must be more than 1 minute");
}
keycloakServiceUri = UriBuilder.fromPath("/").scheme("http").host(getString(container.getConfig(), KEYCLOAK_HOST, KEYCLOAK_HOST_DEFAULT)).port(getInteger(container.getConfig(), KEYCLOAK_PORT, KEYCLOAK_PORT_DEFAULT)).path(KEYCLOAK_AUTH_PATH);
LOG.info("Keycloak service URL: " + keycloakServiceUri.build());
ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder().connectTimeout(getInteger(container.getConfig(), KEYCLOAK_CONNECT_TIMEOUT, KEYCLOAK_CONNECT_TIMEOUT_DEFAULT), TimeUnit.MILLISECONDS).readTimeout(getInteger(container.getConfig(), KEYCLOAK_REQUEST_TIMEOUT, KEYCLOAK_REQUEST_TIMEOUT_DEFAULT), TimeUnit.MILLISECONDS).connectionPoolSize(getInteger(container.getConfig(), KEYCLOAK_CLIENT_POOL_SIZE, KEYCLOAK_CLIENT_POOL_SIZE_DEFAULT));
httpClient = WebClient.registerDefaults(clientBuilder).build();
setActiveCredentials(getDefaultKeycloakGrant(container));
keycloakDeploymentCache = createKeycloakDeploymentCache();
keycloakConfigResolver = request -> {
// The realm we authenticate against must be available as a request header
String realm = request.getHeader(REALM_PARAM_NAME);
if (realm == null || realm.length() == 0) {
LOG.finer("No realm in request, no authentication will be attempted: " + request.getURI());
return notAuthenticatedKeycloakDeployment;
}
KeycloakDeployment keycloakDeployment = getKeycloakDeployment(realm, KEYCLOAK_CLIENT_ID);
if (keycloakDeployment == null) {
LOG.fine("No Keycloak deployment available for realm, no authentication will be attempted: " + request.getURI());
return notAuthenticatedKeycloakDeployment;
}
return keycloakDeployment;
};
if (container.isDevMode()) {
authProxyHandler = ProxyHandler.builder().setProxyClient(new LoadBalancingProxyClient().addHost(keycloakServiceUri.clone().replacePath("").build())).setMaxRequestTime(getInteger(container.getConfig(), KEYCLOAK_REQUEST_TIMEOUT, KEYCLOAK_REQUEST_TIMEOUT_DEFAULT)).setNext(ResponseCodeHandler.HANDLE_404).setReuseXForwarded(true).build();
}
// TODO Not a great way to block startup while we wait for other services (Hystrix?)
waitForKeycloak();
LOG.info("Keycloak identity provider available: " + keycloakServiceUri.build());
}
Aggregations