i need to set the proxy in a java software that use keycloak-admin-client library (that use org.jboss.resteasy and apache.http).
It seems to ignore the -DproxyHost=127.0.0.1 -DproxyPort=8888 JVM configurations. I also tries with org.jboss.resteasy.jaxrs.client.proxy.host property.
Can you help me?
Version of KC dependency:
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>9.0.4</version>
</dependency>
Here the code to generate KC instance:
private Keycloak getKeycloakInstance() {
return KeycloakBuilder.builder()
.serverUrl(KEYCLOAK_SERVER_URL)
.realm(KEYCLOAK_REALM)
.username(KEYCLOAK_USERNAME)
.password(KEYCLOAK_PASSWORD)
.grantType(OAuth2Constants.PASSWORD)
.clientId(KEYCLOAK_ADMIN_CLI)
.clientSecret(KEYCLOAK_ADMIN_SECRET)
.build();
}
And here same examples of utilization:
Keycloak keycloak = getKeycloakInstance();
RealmResource realmResource = keycloak.realm(KEYCLOAK_REALM);
List<ClientRepresentation> findByClientId = realmResource.clients().findByClientId(KEYCLOAK_ADMIN_CLI);
UsersResource userRessource = realmResource.users();
List<UserRepresentation> userToModifyList = userRessource.search(USERNAME);
i found a solution, just pass pass a Resteasyclient to the KeycloakBuilderas follows:
private Keycloak getKeycloakInstance() {
return KeycloakBuilder.builder()
.serverUrl(KEYCLOAK_SERVER_URL)
.realm(KEYCLOAK_REALM)
.username(KEYCLOAK_USERNAME)
.password(KEYCLOAK_PASSWORD)
.grantType(OAuth2Constants.PASSWORD)
.clientId(KEYCLOAK_ADMIN_CLI)
.clientSecret(KEYCLOAK_ADMIN_SECRET)
.resteasyClient(new ResteasyClientBuilder().defaultProxy("localhost", 8888, "http").build())
.build();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.