Updated admin-client to use new token endpoint
This commit is contained in:
parent
71c7d8e48b
commit
1d4e8118f0
3 changed files with 4 additions and 29 deletions
|
@ -1,27 +0,0 @@
|
|||
package org.keycloak.admin.client.resource;
|
||||
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClient;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
|
||||
import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
|
||||
import org.keycloak.admin.client.Config;
|
||||
import org.keycloak.admin.client.token.TokenManager;
|
||||
|
||||
/**
|
||||
* @author rodrigo.sasaki@icarros.com.br
|
||||
*/
|
||||
public class KeycloakAdminFactory {
|
||||
|
||||
private KeycloakAdminFactory(){}
|
||||
|
||||
public static RealmResource getRealm(Config config, TokenManager tokenManager, String realmName){
|
||||
ResteasyClient client = new ResteasyClientBuilder().build();
|
||||
ResteasyWebTarget target = client.target(config.getServerUrl());
|
||||
|
||||
target.register(new BearerAuthFilter(tokenManager.getAccessTokenString()));
|
||||
|
||||
RealmsResource adminRoot = target.proxy(RealmsResource.class);
|
||||
|
||||
return adminRoot.realm(realmName);
|
||||
}
|
||||
|
||||
}
|
|
@ -43,6 +43,7 @@ public class TokenManager {
|
|||
ResteasyWebTarget target = client.target(config.getServerUrl());
|
||||
|
||||
Form form = new Form()
|
||||
.param("grant_type", "password")
|
||||
.param("username", config.getUsername())
|
||||
.param("password", config.getPassword());
|
||||
|
||||
|
@ -64,6 +65,7 @@ public class TokenManager {
|
|||
ResteasyWebTarget target = client.target(config.getServerUrl());
|
||||
|
||||
Form form = new Form()
|
||||
.param("grant_type", "refresh_token")
|
||||
.param("username", config.getUsername())
|
||||
.param("password", config.getPassword());
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ import javax.ws.rs.core.MultivaluedMap;
|
|||
public interface TokenService {
|
||||
|
||||
@POST
|
||||
@Path("/realms/{realm}/protocol/openid-connect/grants/access")
|
||||
@Path("/realms/{realm}/protocol/openid-connect/token")
|
||||
public AccessTokenResponse grantToken(@PathParam("realm") String realm, MultivaluedMap<String, String> map);
|
||||
|
||||
@POST
|
||||
@Path("/realms/{realm}/protocol/openid-connect/refresh")
|
||||
@Path("/realms/{realm}/protocol/openid-connect/token")
|
||||
public AccessTokenResponse refreshToken(@PathParam("realm") String realm, MultivaluedMap<String, String> map);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue