fixed typo, keycloack insted of keycloak
This commit is contained in:
parent
6ffd1975db
commit
5b9bc3d446
|
@ -1,5 +1,6 @@
|
|||
mvn clean package
|
||||
docker build -t idm .
|
||||
docker compose up -d --build --force-recreate
|
||||
|
||||
docker run -it -d -p 8080:8080 --name idm idm
|
||||
docker run -it -d -p 8080:8080 --entrypoint=/bin/bash --name idm idm
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
keycloak
|
||||
|
||||
gruppi:
|
||||
* dev: gcube
|
||||
* pre:
|
||||
* prod:
|
||||
|
||||
|
||||
segnare che bisogna registrarsi su https://next.dev.d4science.org/home
|
|
@ -13,8 +13,8 @@ import javax.ws.rs.core.Response.Status;
|
|||
import org.gcube.common.authorization.library.policies.Users;
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.keycloack.KeycloackApiClient;
|
||||
import org.gcube.keycloack.KeycloakAPIFactory;
|
||||
import org.gcube.keycloak.KeycloakApiClient;
|
||||
import org.gcube.keycloak.KeycloakAPIFactory;
|
||||
import org.gcube.rest.ResponseBean;
|
||||
import org.gcube.smartgears.ContextProvider;
|
||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||
|
@ -51,9 +51,9 @@ public class UsersRest {
|
|||
List<String> usernames = new ArrayList<String>();
|
||||
try {
|
||||
String ctx = SecretManagerProvider.instance.get().getContext();
|
||||
KeycloackApiClient keycloackApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
|
||||
KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
|
||||
|
||||
List<UserRepresentation> users = searchByRole(keycloackApiClient, roleName);
|
||||
List<UserRepresentation> users = searchByRole(keycloakApiClient, roleName);
|
||||
if (users != null) {
|
||||
for (UserRepresentation user : users) {
|
||||
usernames.add(user.getUsername());
|
||||
|
@ -71,11 +71,11 @@ public class UsersRest {
|
|||
|
||||
}
|
||||
|
||||
private static List<UserRepresentation> searchByRole(KeycloackApiClient keycloackApiClient, String roleName) {
|
||||
private static List<UserRepresentation> searchByRole(KeycloakApiClient keycloakApiClient, String roleName) {
|
||||
logger.info("Searching by role: {}", roleName);
|
||||
|
||||
List<ClientRepresentation> clients = keycloackApiClient.kclient.realm(keycloackApiClient.realmName)
|
||||
.clients().findByClientId(keycloackApiClient.clientIdContext);
|
||||
List<ClientRepresentation> clients = keycloakApiClient.kclient.realm(keycloakApiClient.realmName)
|
||||
.clients().findByClientId(keycloakApiClient.clientIdContext);
|
||||
|
||||
String id = "";
|
||||
for (ClientRepresentation client : clients) {
|
||||
|
@ -84,7 +84,7 @@ public class UsersRest {
|
|||
id = client.getId();
|
||||
}
|
||||
|
||||
List<UserRepresentation> users = keycloackApiClient.kclient.realm(keycloackApiClient.realmName)
|
||||
List<UserRepresentation> users = keycloakApiClient.kclient.realm(keycloakApiClient.realmName)
|
||||
.clients()
|
||||
.get(id).roles().get(roleName)
|
||||
.getUserMembers(0, 100000);
|
||||
|
@ -104,7 +104,7 @@ public class UsersRest {
|
|||
.getCredentials();
|
||||
|
||||
String ctx = SecretManagerProvider.instance.get().getContext();
|
||||
KeycloackApiClient keycloackApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
|
||||
KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.keycloack;
|
||||
package org.gcube.keycloak;
|
||||
|
||||
public class ErrorMessages {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.keycloack;
|
||||
package org.gcube.keycloak;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
@ -132,8 +132,7 @@ public class KeycloakAPIFactory {
|
|||
return realm;
|
||||
}
|
||||
|
||||
public KeycloackApiClient createtKeycloakInstance(String context) {
|
||||
// String clientIdContext = KeycloackUtils.getClientIdContext(context);
|
||||
public KeycloakApiClient createtKeycloakInstance(String context) {
|
||||
String realm = this.getRealm();
|
||||
Keycloak keycloak = KeycloakBuilder.builder()
|
||||
.serverUrl(this.getServerURL())
|
||||
|
@ -141,7 +140,7 @@ public class KeycloakAPIFactory {
|
|||
.grantType(OAuth2Constants.CLIENT_CREDENTIALS)
|
||||
.clientId(this.getClientid()) //
|
||||
.clientSecret(this.getPassword()).build();
|
||||
return new KeycloackApiClient(keycloak, realm, context);
|
||||
return new KeycloakApiClient(keycloak, realm, context);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package org.gcube.keycloack;
|
||||
package org.gcube.keycloak;
|
||||
|
||||
import org.keycloak.admin.client.Keycloak;
|
||||
|
||||
public class KeycloackApiClient {
|
||||
public class KeycloakApiClient {
|
||||
public Keycloak kclient;
|
||||
public String realmName;
|
||||
public String clientIdContext;
|
||||
|
@ -12,7 +12,7 @@ public class KeycloackApiClient {
|
|||
return context.replace("/", "%2F");
|
||||
}
|
||||
|
||||
public KeycloackApiClient(Keycloak kclient, String realmName, String context) {
|
||||
public KeycloakApiClient(Keycloak kclient, String realmName, String context) {
|
||||
this.clientIdContext = getClientIdContext(context);
|
||||
this.context = context;
|
||||
this.kclient = kclient;
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.keycloack;
|
||||
package org.gcube.keycloak;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
@ -14,9 +14,9 @@ import org.gcube.common.keycloak.KeycloakClientException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class KeycloackClientParams_UNUSED {
|
||||
public class KeycloakClientParams_UNUSED {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(KeycloackClientParams_UNUSED.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(KeycloakClientParams_UNUSED.class);
|
||||
|
||||
public static final String CATALOGUE_NAME = "IDM";
|
||||
|
||||
|
@ -32,7 +32,7 @@ public class KeycloackClientParams_UNUSED {
|
|||
protected static Entry<String, String> getClientIdAndClientSecret(String context) {
|
||||
try {
|
||||
Properties properties = new Properties();
|
||||
ClassLoader classLoader = KeycloackClientParams_UNUSED.class.getClassLoader();
|
||||
ClassLoader classLoader = KeycloakClientParams_UNUSED.class.getClassLoader();
|
||||
URL url = classLoader.getResource(CLIENT_ID_SECRET_FILENAME);
|
||||
logger.trace("Going to read {} at {}", CLIENT_ID_SECRET_FILENAME, url.toString());
|
||||
InputStream input = classLoader.getResourceAsStream(CLIENT_ID_SECRET_FILENAME);
|
||||
|
@ -90,7 +90,7 @@ public class KeycloackClientParams_UNUSED {
|
|||
return this.context;
|
||||
}
|
||||
|
||||
public KeycloackClientParams_UNUSED(String context) {
|
||||
public KeycloakClientParams_UNUSED(String context) {
|
||||
this.context = context;
|
||||
Entry<String, String> params = getClientIdAndClientSecret(context);
|
||||
this.clientId = params.getKey();
|
|
@ -13,7 +13,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.gxhttp.request.GXHTTPStringRequest;
|
||||
import org.gcube.keycloack.KeycloackClientParams_UNUSED;
|
||||
import org.gcube.keycloak.KeycloakClientParams_UNUSED;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class HTTPUtility {
|
|||
public static GXHTTPStringRequest createGXHTTPStringRequest(String url, String path, boolean post)
|
||||
throws UnsupportedEncodingException {
|
||||
GXHTTPStringRequest gxhttpStringRequest = GXHTTPStringRequest.newRequest(url);
|
||||
gxhttpStringRequest.from(KeycloackClientParams_UNUSED.CATALOGUE_NAME);
|
||||
gxhttpStringRequest.from(KeycloakClientParams_UNUSED.CATALOGUE_NAME);
|
||||
if(post) {
|
||||
gxhttpStringRequest.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue