updated smartgears libraries

This commit is contained in:
Alfredo Oliviero 2024-02-26 10:01:47 +01:00
parent ba1db21254
commit 051c448e87
7 changed files with 47 additions and 23 deletions

View File

@ -7,5 +7,6 @@
"command": "clean package",
"debug": false
}
]
],
"java.dependency.packagePresentation": "hierarchical"
}

View File

@ -6,17 +6,12 @@ services:
# montiamo "target" sul percorso delle applicazioni web di Tomcat, permettendo così aggiornamenti automatici del WAR senza necessità di ricostruire il container
# - ./target:/usr/local/tomcat/webapps/
- ./tomcat/webapps:/usr/local/tomcat/webapps/
- ./tomcat/logs:/usr/local/tomcat/logs
ports:
- 8080:8080
- 4954:4954
environment:
- ADMINISTRATION_PORT_ENABLED=true
- DOMAIN_NAME=docker_domain
- JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=0.0.0.0:4954,server=y,suspend=n"
- JPDA_ADDRESS=*:4954

10
pom.xml
View File

@ -110,6 +110,16 @@
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warName>identity-manager</warName>
<outputDirectory>tomcat/webapps</outputDirectory>
</configuration>
</plugin>
<!-- Sphinx plugin'
<plugin>
<groupId>kr.motd.maven</groupId>

View File

@ -16,7 +16,7 @@ import org.gcube.idm.rest.TestRest;
// legge i parametri del service da application.yaml
@Path("idm")
public class IdentityManagerResourceInitializer extends Application {
public class IdentityManagerApplication extends Application {
public Set<Class<?>> getClasses() {
final Set<Class<?>> classes = new HashSet<Class<?>>();

View File

@ -8,12 +8,12 @@ import org.slf4j.LoggerFactory;
/**
* @author Alfredo Oliviero (ISTI - CNR)
*/
public class IdentityManagerdInitializator implements ApplicationManager {
public class IdentityManagerApplicationManager implements ApplicationManager {
/**
* Logger
*/
private static Logger logger = LoggerFactory.getLogger(IdentityManagerdInitializator.class);
private static Logger logger = LoggerFactory.getLogger(IdentityManagerApplicationManager.class);
public static boolean initialised;
@ -23,7 +23,7 @@ public class IdentityManagerdInitializator implements ApplicationManager {
@Override
public synchronized void onInit() {
String context = SecretManagerProvider.instance.get().getContext();
String context = SecretManagerProvider.get().getContext();
logger.trace(
"\n-------------------------------------------------------\n"
@ -50,7 +50,7 @@ public class IdentityManagerdInitializator implements ApplicationManager {
@Override
public synchronized void onShutdown(){
String context = SecretManagerProvider.instance.get().getContext();
String context = SecretManagerProvider.get().getContext();
logger.trace(
"\n-------------------------------------------------------\n"

View File

@ -3,41 +3,59 @@ package org.gcube.idm.rest;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.gcube.common.security.providers.SecretManagerProvider;
import org.gcube.common.security.secrets.Secret;
import org.gcube.idm.IdentityManagerdInitializator;
import org.gcube.idm.IdentityManagerApplicationManager;
import org.gcube.smartgears.annotations.ManagedBy;
import org.gcube.smartgears.utils.InnerMethodName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.webcohesion.enunciate.metadata.rs.RequestHeader;
import com.webcohesion.enunciate.metadata.rs.RequestHeaders;
import com.webcohesion.enunciate.metadata.rs.ResourceGroup;
import com.webcohesion.enunciate.metadata.rs.ResourceLabel;
@ManagedBy(IdentityManagerApplicationManager.class)
@Path("/test")
@ResourceGroup("test")
@ResourceLabel("test")
@RequestHeaders({
@RequestHeader( name = "Authorization", description = "Bearer token, see <a href=\"https://dev.d4science.org/how-to-access-resources\">https://dev.d4science.org/how-to-access-resources</a>")
@RequestHeader(name = "Authorization", description = "Bearer token, see <a href=\"https://dev.d4science.org/how-to-access-resources\">https://dev.d4science.org/how-to-access-resources</a>")
})
@ManagedBy(IdentityManagerdInitializator.class)
public class TestRest {
private final Logger logger = LoggerFactory.getLogger(TestRest.class);
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
InnerMethodName.set("hello");
Secret secret = SecretManagerProvider.get();
String userId = secret.getOwner().getId();
String context = secret.getContext();
logger.info("caller id is {}", userId);
return String.format("Hello %s in context %s", userId, context);
}
@GET
@Path("/prova")
@Produces({"application/json;charset=UTF-8", "application/vnd.api+json"})
public String prova(){
@Produces(MediaType.APPLICATION_JSON)
public String prova() {
logger.info("prova");
return "{'aaa':bbb'}";
}
@GET
@Path("show_context")
@Produces({"application/json;charset=UTF-8", "application/vnd.api+json"})
public String show_context(){
Secret smp = SecretManagerProvider.instance.get();
@Produces(MediaType.APPLICATION_JSON)
public String show_context() {
Secret smp = SecretManagerProvider.get();
String ctx = smp.getContext();
return ctx;
}
}

View File

@ -23,7 +23,7 @@ public class UsersRest {
List<String> usernames = new ArrayList<String>();
try {
String ctx = SecretManagerProvider.instance.get().getContext();
String ctx = SecretManagerProvider.get().getContext();
KeycloakApiClient keycloackApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
List<UserRepresentation> users = null; // searchByRole(keycloackApiClient, roleName);
@ -70,13 +70,13 @@ public class UsersRest {
public String getCurrentProfile() {
// SMARTGEARS Specializza il tracciamento della chiamata su Accounting
InnerMethodName.instance.set("getCurrentProfile");
Owner owner = SecretManagerProvider.instance.get().getOwner();
Owner owner = SecretManagerProvider.get().getOwner();
ApplicationContext appContext = ContextProvider.get();
SimpleCredentials credentials = ((DefaultAuthorizationProvider) appContext.container().authorizationProvider())
.getCredentials();
String ctx = SecretManagerProvider.instance.get().getContext();
String ctx = SecretManagerProvider.get().getContext();
KeycloackApiClient keycloackApiClient = KeycloakAPIFactory.getSingleton().createtKeycloakInstance(ctx);
return null;
}