diff --git a/src/main/webapp/WEB-INF/web.xml b/gcube/web.xml similarity index 56% rename from src/main/webapp/WEB-INF/web.xml rename to gcube/web.xml index d53b9d1..564d80d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/gcube/web.xml @@ -2,9 +2,14 @@ org.gcube.idm.IdentityManagerResourceInitializer + org.gcube.idm.IdentityManagerResourceInitializer + + resolver-basepath + https://data-d.d4science.org/shub + org.gcube.idm.IdentityManagerResourceInitializer /* - \ No newline at end of file + diff --git a/pom.xml b/pom.xml index 40d554f..bf88c82 100644 --- a/pom.xml +++ b/pom.xml @@ -7,11 +7,11 @@ maven-parent 1.2.0 - org.gcube.idm + org.gcube.idm identity-manager 1.0.0-SNAPSHOT war - Identity Manager Service + identity-manager Identity Manager Smargears Service @@ -19,7 +19,7 @@ 11 11 - ${project.basedir}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF + ${project.basedir}${file.separator}gcube${file.separator}extra-resources${file.separator}WEB-INF 2.14.0 @@ -81,10 +81,6 @@ common-scope-maps - - - - org.gcube.common keycloak-client @@ -95,11 +91,6 @@ 21.0.1 - - - - - org.gcube.core common-encryption @@ -220,6 +211,7 @@ maven-war-plugin true + ../webapps/identity-manager diff --git a/src/main/java/org/gcube/idm/IdentityManagerResourceInitializer.java b/src/main/java/org/gcube/idm/IdentityManagerResourceInitializer.java index b6bb515..1f6f1cc 100644 --- a/src/main/java/org/gcube/idm/IdentityManagerResourceInitializer.java +++ b/src/main/java/org/gcube/idm/IdentityManagerResourceInitializer.java @@ -1,6 +1,7 @@ package org.gcube.idm; import javax.ws.rs.ApplicationPath; +import javax.ws.rs.Path; import org.gcube.idm.rest.TestRest; import org.gcube.idm.rest.UsersRest; @@ -11,11 +12,8 @@ import org.glassfish.jersey.server.ResourceConfig; * @author Alfredo Oliviero (ISTI - CNR) */ - - // SMARTGEARS -// legge i parametri del service da application.yaml - @ApplicationPath("/") +//@Path("identity-manager") @ManagedBy(IdentityManagerdInitializator.class) public class IdentityManagerResourceInitializer extends ResourceConfig { diff --git a/src/main/java/org/gcube/idm/IdentityManagerdInitializator.java b/src/main/java/org/gcube/idm/IdentityManagerdInitializator.java index 554c31f..4fe3935 100644 --- a/src/main/java/org/gcube/idm/IdentityManagerdInitializator.java +++ b/src/main/java/org/gcube/idm/IdentityManagerdInitializator.java @@ -2,6 +2,8 @@ package org.gcube.idm; import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.smartgears.ApplicationManager; +import org.gcube.smartgears.ContextProvider; +import org.gcube.smartgears.context.application.ApplicationContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +25,7 @@ public class IdentityManagerdInitializator implements ApplicationManager { @Override public synchronized void onInit() { - String context = SecretManagerProvider.instance.get().getContext(); + ApplicationContext context = ContextProvider.get(); logger.info( "\n-------------------------------------------------------\n" @@ -50,7 +52,7 @@ public class IdentityManagerdInitializator implements ApplicationManager { @Override public synchronized void onShutdown(){ - String context = SecretManagerProvider.instance.get().getContext(); + ApplicationContext context = ContextProvider.get(); logger.trace( "\n-------------------------------------------------------\n" diff --git a/src/main/java/org/gcube/idm/rest/TestRest.java b/src/main/java/org/gcube/idm/rest/TestRest.java index 793cedc..e9a4530 100644 --- a/src/main/java/org/gcube/idm/rest/TestRest.java +++ b/src/main/java/org/gcube/idm/rest/TestRest.java @@ -18,7 +18,7 @@ import com.webcohesion.enunciate.metadata.rs.ResourceLabel; public class TestRest { @GET - @Path("/prova") + @Path("prova") @Produces({"application/json;charset=UTF-8", "application/vnd.api+json"}) public String test(){ return "{}"; diff --git a/src/main/java/org/gcube/idm/rest/UsersRest.java b/src/main/java/org/gcube/idm/rest/UsersRest.java index 943a2a0..9507201 100644 --- a/src/main/java/org/gcube/idm/rest/UsersRest.java +++ b/src/main/java/org/gcube/idm/rest/UsersRest.java @@ -11,17 +11,10 @@ import javax.ws.rs.core.Response; 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.keycloak.KeycloakApiClient; import org.gcube.keycloak.KeycloakAPIFactory; +import org.gcube.keycloak.KeycloakApiClient; import org.gcube.rest.ResponseBean; -import org.gcube.smartgears.ContextProvider; -import org.gcube.smartgears.context.application.ApplicationContext; -import org.gcube.smartgears.security.SimpleCredentials; -import org.gcube.smartgears.security.defaults.DefaultAuthorizationProvider; -import org.gcube.smartgears.utils.InnerMethodName; -import org.jboss.resteasy.spi.NotImplementedYetException; import org.keycloak.representations.idm.ClientRepresentation; import org.keycloak.representations.idm.UserRepresentation; import org.slf4j.LoggerFactory; @@ -50,8 +43,8 @@ public class UsersRest { List usernames = new ArrayList(); try { - String ctx = SecretManagerProvider.instance.get().getContext(); - KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx); + String currentContext = SecretManagerProvider.instance.get().getContext(); + KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(currentContext); List users = searchByRole(keycloakApiClient, roleName); if (users != null) { @@ -96,15 +89,17 @@ public class UsersRest { @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) public String getCurrentProfile() { // SMARTGEARS Specializza il tracciamento della chiamata su Accounting - InnerMethodName.instance.set("getCurrentProfile"); - Owner owner = SecretManagerProvider.instance.get().getOwner(); - - ApplicationContext appContext = ContextProvider.get(); - SimpleCredentials credentials = ((DefaultAuthorizationProvider) appContext.container().authorizationProvider()) - .getCredentials(); - - String ctx = SecretManagerProvider.instance.get().getContext(); - KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx); + // InnerMethodName.instance.set("getCurrentProfile"); + // Owner owner = SecretManagerProvider.instance.get().getOwner(); + // + // ApplicationContext appContext = ContextProvider.get(); + // SimpleCredentials credentials = ((DefaultAuthorizationProvider) + // appContext.container().authorizationProvider()) + // .getCredentials(); + // + // String ctx = SecretManagerProvider.instance.get().getContext(); + // KeycloakApiClient keycloakApiClient = + // KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx); return null; } @@ -112,42 +107,48 @@ public class UsersRest { @Path("/get-email") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) public String getCurrentEmail() { - throw new NotImplementedYetException(); + // throw new NotImplementedYetException\(\); + return null; } @GET @Path("/get-fullname") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) public String getCurrentFullname() { - throw new NotImplementedYetException(); + // throw new NotImplementedYetException\(\); + return null; } @GET @Path("/get-all-usernames") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) public String getAllUsernames() { - throw new NotImplementedYetException(); + // throw new NotImplementedYetException\(\); + return null; } @GET @Path("/get-all-fullnames-and-usernames") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) public String getAllUsernamesFullnames() { - throw new NotImplementedYetException(); + // throw new NotImplementedYetException\(\); + return null; } @GET @Path("/user-exists") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) - public boolean checkUserExists() { - throw new NotImplementedYetException(); + public Boolean checkUserExists() { + // throw new NotImplementedYetException\(\); + return null; } @GET @Path("/get-oauth-profile") @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) - public boolean getCurrentOAuthProfile() { - throw new NotImplementedYetException(); + public String getCurrentOAuthProfile() { + // throw new NotImplementedYetException\(\); + return null; } }