updated path and config

This commit is contained in:
Alfredo Oliviero 2024-02-13 14:50:45 +01:00
parent 182f890e9c
commit 9c6fa54d97
6 changed files with 45 additions and 47 deletions

View File

@ -2,7 +2,12 @@
<web-app> <web-app>
<servlet> <servlet>
<servlet-name>org.gcube.idm.IdentityManagerResourceInitializer</servlet-name> <servlet-name>org.gcube.idm.IdentityManagerResourceInitializer</servlet-name>
<servlet-class>org.gcube.idm.IdentityManagerResourceInitializer</servlet-class>
</servlet> </servlet>
<context-param>
<param-name>resolver-basepath</param-name>
<param-value>https://data-d.d4science.org/shub</param-value>
</context-param>
<servlet-mapping> <servlet-mapping>
<servlet-name>org.gcube.idm.IdentityManagerResourceInitializer</servlet-name> <servlet-name>org.gcube.idm.IdentityManagerResourceInitializer</servlet-name>
<url-pattern>/*</url-pattern> <url-pattern>/*</url-pattern>

14
pom.xml
View File

@ -11,7 +11,7 @@
<artifactId>identity-manager</artifactId> <artifactId>identity-manager</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>Identity Manager Service</name> <name>identity-manager</name>
<description>Identity Manager Smargears Service</description> <description>Identity Manager Smargears Service</description>
<properties> <properties>
@ -19,7 +19,7 @@
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
<webappDirectory> <webappDirectory>
${project.basedir}${file.separator}src${file.separator}main${file.separator}webapp${file.separator}WEB-INF</webappDirectory> ${project.basedir}${file.separator}gcube${file.separator}extra-resources${file.separator}WEB-INF</webappDirectory>
<enunciate.version>2.14.0</enunciate.version> <enunciate.version>2.14.0</enunciate.version>
</properties> </properties>
@ -81,10 +81,6 @@
<artifactId>common-scope-maps</artifactId> <artifactId>common-scope-maps</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>keycloak-client</artifactId> <artifactId>keycloak-client</artifactId>
@ -95,11 +91,6 @@
<version>21.0.1</version> <version>21.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.core</groupId> <groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId> <artifactId>common-encryption</artifactId>
@ -220,6 +211,7 @@
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>
<configuration> <configuration>
<attachClasses>true</attachClasses> <attachClasses>true</attachClasses>
<warName>../webapps/identity-manager</warName>
</configuration> </configuration>
</plugin> </plugin>

View File

@ -1,6 +1,7 @@
package org.gcube.idm; package org.gcube.idm;
import javax.ws.rs.ApplicationPath; import javax.ws.rs.ApplicationPath;
import javax.ws.rs.Path;
import org.gcube.idm.rest.TestRest; import org.gcube.idm.rest.TestRest;
import org.gcube.idm.rest.UsersRest; import org.gcube.idm.rest.UsersRest;
@ -11,11 +12,8 @@ import org.glassfish.jersey.server.ResourceConfig;
* @author Alfredo Oliviero (ISTI - CNR) * @author Alfredo Oliviero (ISTI - CNR)
*/ */
// SMARTGEARS
// legge i parametri del service da application.yaml
@ApplicationPath("/") @ApplicationPath("/")
//@Path("identity-manager")
@ManagedBy(IdentityManagerdInitializator.class) @ManagedBy(IdentityManagerdInitializator.class)
public class IdentityManagerResourceInitializer extends ResourceConfig { public class IdentityManagerResourceInitializer extends ResourceConfig {

View File

@ -2,6 +2,8 @@ package org.gcube.idm;
import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.smartgears.ApplicationManager; import org.gcube.smartgears.ApplicationManager;
import org.gcube.smartgears.ContextProvider;
import org.gcube.smartgears.context.application.ApplicationContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -23,7 +25,7 @@ public class IdentityManagerdInitializator implements ApplicationManager {
@Override @Override
public synchronized void onInit() { public synchronized void onInit() {
String context = SecretManagerProvider.instance.get().getContext(); ApplicationContext context = ContextProvider.get();
logger.info( logger.info(
"\n-------------------------------------------------------\n" "\n-------------------------------------------------------\n"
@ -50,7 +52,7 @@ public class IdentityManagerdInitializator implements ApplicationManager {
@Override @Override
public synchronized void onShutdown(){ public synchronized void onShutdown(){
String context = SecretManagerProvider.instance.get().getContext(); ApplicationContext context = ContextProvider.get();
logger.trace( logger.trace(
"\n-------------------------------------------------------\n" "\n-------------------------------------------------------\n"

View File

@ -18,7 +18,7 @@ import com.webcohesion.enunciate.metadata.rs.ResourceLabel;
public class TestRest { public class TestRest {
@GET @GET
@Path("/prova") @Path("prova")
@Produces({"application/json;charset=UTF-8", "application/vnd.api+json"}) @Produces({"application/json;charset=UTF-8", "application/vnd.api+json"})
public String test(){ public String test(){
return "{}"; return "{}";

View File

@ -11,17 +11,10 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status; import javax.ws.rs.core.Response.Status;
import org.gcube.common.authorization.library.policies.Users; import org.gcube.common.authorization.library.policies.Users;
import org.gcube.common.security.Owner;
import org.gcube.common.security.providers.SecretManagerProvider; import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.keycloak.KeycloakApiClient;
import org.gcube.keycloak.KeycloakAPIFactory; import org.gcube.keycloak.KeycloakAPIFactory;
import org.gcube.keycloak.KeycloakApiClient;
import org.gcube.rest.ResponseBean; 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.ClientRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -50,8 +43,8 @@ public class UsersRest {
List<String> usernames = new ArrayList<String>(); List<String> usernames = new ArrayList<String>();
try { try {
String ctx = SecretManagerProvider.instance.get().getContext(); String currentContext = SecretManagerProvider.instance.get().getContext();
KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx); KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(currentContext);
List<UserRepresentation> users = searchByRole(keycloakApiClient, roleName); List<UserRepresentation> users = searchByRole(keycloakApiClient, roleName);
if (users != null) { if (users != null) {
@ -96,15 +89,17 @@ public class UsersRest {
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public String getCurrentProfile() { public String getCurrentProfile() {
// SMARTGEARS Specializza il tracciamento della chiamata su Accounting // SMARTGEARS Specializza il tracciamento della chiamata su Accounting
InnerMethodName.instance.set("getCurrentProfile"); // InnerMethodName.instance.set("getCurrentProfile");
Owner owner = SecretManagerProvider.instance.get().getOwner(); // Owner owner = SecretManagerProvider.instance.get().getOwner();
//
ApplicationContext appContext = ContextProvider.get(); // ApplicationContext appContext = ContextProvider.get();
SimpleCredentials credentials = ((DefaultAuthorizationProvider) appContext.container().authorizationProvider()) // SimpleCredentials credentials = ((DefaultAuthorizationProvider)
.getCredentials(); // appContext.container().authorizationProvider())
// .getCredentials();
String ctx = SecretManagerProvider.instance.get().getContext(); //
KeycloakApiClient keycloakApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx); // String ctx = SecretManagerProvider.instance.get().getContext();
// KeycloakApiClient keycloakApiClient =
// KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
return null; return null;
} }
@ -112,42 +107,48 @@ public class UsersRest {
@Path("/get-email") @Path("/get-email")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public String getCurrentEmail() { public String getCurrentEmail() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
@GET @GET
@Path("/get-fullname") @Path("/get-fullname")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public String getCurrentFullname() { public String getCurrentFullname() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
@GET @GET
@Path("/get-all-usernames") @Path("/get-all-usernames")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public String getAllUsernames() { public String getAllUsernames() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
@GET @GET
@Path("/get-all-fullnames-and-usernames") @Path("/get-all-fullnames-and-usernames")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public String getAllUsernamesFullnames() { public String getAllUsernamesFullnames() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
@GET @GET
@Path("/user-exists") @Path("/user-exists")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public boolean checkUserExists() { public Boolean checkUserExists() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
@GET @GET
@Path("/get-oauth-profile") @Path("/get-oauth-profile")
@Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" }) @Produces({ "application/json;charset=UTF-8", "application/vnd.api+json" })
public boolean getCurrentOAuthProfile() { public String getCurrentOAuthProfile() {
throw new NotImplementedYetException(); // throw new NotImplementedYetException\(\);
return null;
} }
} }