style - code formatting
This commit is contained in:
parent
bacba3984c
commit
cc2d0b74cd
|
@ -10,7 +10,7 @@
|
||||||
"projectName": "identity-manager",
|
"projectName": "identity-manager",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
"hostName": "localhost",
|
"hostName": "localhost",
|
||||||
"port": 5005
|
"port": 5005
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -1,3 +1,3 @@
|
||||||
mvn clean package
|
mvn clean package
|
||||||
docker build -t smartgears-helloworld .
|
docker build -t smartgears-helloworld .
|
||||||
docker run -p 8080:8080 smartgears-helloworld
|
docker run -p 8080:8080 smartgears-helloworld
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
mvn package
|
mvn package
|
||||||
docker build -t smartgears-helloworld .
|
docker build -t smartgears-helloworld .
|
||||||
docker run -p 8080:8080 -p 5005:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" smartgears-helloworld
|
docker run -p 8080:8080 -p 5005:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" smartgears-helloworld
|
||||||
|
|
40
pom.xml
40
pom.xml
|
@ -1,4 +1,6 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.gcube.tools</groupId>
|
<groupId>org.gcube.tools</groupId>
|
||||||
|
@ -90,24 +92,24 @@
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>aspectj-maven-plugin</artifactId>
|
<artifactId>aspectj-maven-plugin</artifactId>
|
||||||
<version>${aspectj-plugin.version}</version>
|
<version>${aspectj-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<complianceLevel>11</complianceLevel>
|
<complianceLevel>11</complianceLevel>
|
||||||
<source>11</source>
|
<source>11</source>
|
||||||
<target>11</target>
|
<target>11</target>
|
||||||
<aspectLibraries>
|
<aspectLibraries>
|
||||||
<aspectLibrary>
|
<aspectLibrary>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
<artifactId>authorization-control-library</artifactId>
|
<artifactId>authorization-control-library</artifactId>
|
||||||
</aspectLibrary>
|
</aspectLibrary>
|
||||||
</aspectLibraries>
|
</aspectLibraries>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>compile</goal>
|
<goal>compile</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
|
@ -6,11 +6,14 @@ import java.util.Set;
|
||||||
import javax.ws.rs.ApplicationPath;
|
import javax.ws.rs.ApplicationPath;
|
||||||
import javax.ws.rs.core.Application;
|
import javax.ws.rs.core.Application;
|
||||||
|
|
||||||
import org.gcube.service.helloworld.services.AuthorizedMethods;
|
import org.gcube.service.helloworld.services.AuthenticatedService;
|
||||||
import org.gcube.service.helloworld.services.ExcludeAuthorization;
|
import org.gcube.service.helloworld.services.ExcludeAuthorizationService;
|
||||||
import org.gcube.service.helloworld.services.HelloService;
|
import org.gcube.service.helloworld.services.HelloService;
|
||||||
import org.gcube.service.helloworld.services.TestAuthorizationService;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Lucio Lelii (ISTI-CNR)
|
||||||
|
*/
|
||||||
|
|
||||||
@ApplicationPath("")
|
@ApplicationPath("")
|
||||||
public class HelloWorld extends Application {
|
public class HelloWorld extends Application {
|
||||||
|
@ -19,9 +22,8 @@ public class HelloWorld extends Application {
|
||||||
final Set<Class<?>> classes = new HashSet<Class<?>>();
|
final Set<Class<?>> classes = new HashSet<Class<?>>();
|
||||||
// register resources classes implementing Servlets
|
// register resources classes implementing Servlets
|
||||||
classes.add(HelloService.class);
|
classes.add(HelloService.class);
|
||||||
classes.add(ExcludeAuthorization.class);
|
classes.add(ExcludeAuthorizationService.class);
|
||||||
classes.add(TestAuthorizationService.class);
|
classes.add(AuthenticatedService.class);
|
||||||
|
|
||||||
return classes;
|
return classes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||||
* to the app declaring it via the @ManagedBy annotation. (@see HelloWorld
|
* to the app declaring it via the @ManagedBy annotation. (@see HelloWorld
|
||||||
* class)
|
* class)
|
||||||
*
|
*
|
||||||
*
|
* @author Lucio Lelii (ISTI-CNR)
|
||||||
* @author lucio
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class HelloWorldManager implements ApplicationManager {
|
public class HelloWorldManager implements ApplicationManager {
|
||||||
|
@ -26,7 +24,7 @@ public class HelloWorldManager implements ApplicationManager {
|
||||||
Logger logger = LoggerFactory.getLogger(HelloWorldManager.class);
|
Logger logger = LoggerFactory.getLogger(HelloWorldManager.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInit() {
|
public void onInit() {
|
||||||
if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
|
if (ContextProvider.get().container().configuration().mode() == Mode.offline) {
|
||||||
logger.debug("init called in offline mode");
|
logger.debug("init called in offline mode");
|
||||||
} else {
|
} else {
|
||||||
|
@ -35,7 +33,7 @@ public class HelloWorldManager implements ApplicationManager {
|
||||||
logger.debug("init called in context {}", secret.getContext());
|
logger.debug("init called in context {}", secret.getContext());
|
||||||
} else {
|
} else {
|
||||||
logger.debug("init called in null context");
|
logger.debug("init called in null context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +47,7 @@ public class HelloWorldManager implements ApplicationManager {
|
||||||
logger.debug("shutDown called in context {}", secret.getContext());
|
logger.debug("shutDown called in context {}", secret.getContext());
|
||||||
} else {
|
} else {
|
||||||
logger.debug("shutDown called in null context");
|
logger.debug("shutDown called in null context");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,18 +8,25 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
|
||||||
public class ContainerConfigurationSerializer extends StdSerializer<ContainerConfiguration> {
|
/**
|
||||||
|
* Jackson serializer for ContainerConfiguration
|
||||||
|
*
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ContainerConfigurationSerializer extends StdSerializer<ContainerConfiguration> {
|
||||||
protected ContainerConfigurationSerializer(Class<ContainerConfiguration> t) {
|
protected ContainerConfigurationSerializer(Class<ContainerConfiguration> t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerConfigurationSerializer(){
|
public ContainerConfigurationSerializer() {
|
||||||
super(ContainerConfiguration.class, true);
|
super(ContainerConfiguration.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ContainerConfiguration configuration, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
public void serialize(ContainerConfiguration configuration, JsonGenerator jgen, SerializerProvider provider)
|
||||||
|
throws IOException {
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
jgen.writeObjectField("mode", configuration.mode());
|
jgen.writeObjectField("mode", configuration.mode());
|
||||||
jgen.writeObjectField("app", configuration.apps());
|
jgen.writeObjectField("app", configuration.apps());
|
||||||
|
@ -33,8 +40,6 @@ public class ContainerConfigurationSerializer extends StdSerializer<ContainerCon
|
||||||
|
|
||||||
jgen.writeObjectField("desc", configuration.toString());
|
jgen.writeObjectField("desc", configuration.toString());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
jgen.writeEndObject();
|
jgen.writeEndObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,22 +8,29 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
|
||||||
public class ContainerContextSerializer extends StdSerializer<ContainerContext> {
|
/**
|
||||||
|
* Jackson serializer for ContainerContext
|
||||||
|
*
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ContainerContextSerializer extends StdSerializer<ContainerContext> {
|
||||||
protected ContainerContextSerializer(Class<ContainerContext> t) {
|
protected ContainerContextSerializer(Class<ContainerContext> t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContainerContextSerializer(){
|
public ContainerContextSerializer() {
|
||||||
super(ContainerContext.class, true);
|
super(ContainerContext.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(ContainerContext ccontext, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
public void serialize(ContainerContext ccontext, JsonGenerator jgen, SerializerProvider provider)
|
||||||
|
throws IOException {
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
jgen.writeStringField("id", ccontext.id());
|
jgen.writeStringField("id", ccontext.id());
|
||||||
// jgen.writeObjectField("configuration.site", ccontext.configuration().site());
|
// jgen.writeObjectField("configuration.site", ccontext.configuration().site());
|
||||||
//jgen.writeObjectField("configuration", ccontext.configuration());
|
// jgen.writeObjectField("configuration", ccontext.configuration());
|
||||||
jgen.writeObjectField("properties", ccontext.properties());
|
jgen.writeObjectField("properties", ccontext.properties());
|
||||||
jgen.writeObjectField("authorizationProvider", ccontext.authorizationProvider());
|
jgen.writeObjectField("authorizationProvider", ccontext.authorizationProvider());
|
||||||
|
|
||||||
|
|
|
@ -7,20 +7,26 @@ import org.gcube.smartgears.security.SimpleCredentials;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||||
|
|
||||||
public class SmartGearSerializator {
|
/**
|
||||||
private static ObjectMapper serializer = null;
|
* Jackson Serialization utils for Smartgear Context classes
|
||||||
|
*
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ContextSerializator {
|
||||||
|
private static ObjectMapper serializer = null;
|
||||||
|
|
||||||
public static ObjectMapper getSerializer() {
|
public static ObjectMapper getSerializer() {
|
||||||
if (serializer == null) {
|
if (serializer == null) {
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
SimpleModule module = new SimpleModule();
|
SimpleModule module = new SimpleModule();
|
||||||
// module.addSerializer(Owner.class, new OwnerSerializer());
|
// module.addSerializer(Owner.class, new OwnerSerializer());
|
||||||
|
|
||||||
module.addSerializer(ContainerConfiguration.class, new ContainerConfigurationSerializer());
|
module.addSerializer(ContainerConfiguration.class, new ContainerConfigurationSerializer());
|
||||||
module.addSerializer(ContainerContext.class, new ContainerContextSerializer());
|
module.addSerializer(ContainerContext.class, new ContainerContextSerializer());
|
||||||
module.addSerializer(SimpleCredentials.class, new SimpleCredentialsSerializer());
|
module.addSerializer(SimpleCredentials.class, new SimpleCredentialsSerializer());
|
||||||
|
|
||||||
|
|
||||||
om.registerModule(module);
|
om.registerModule(module);
|
||||||
serializer = om;
|
serializer = om;
|
||||||
}
|
}
|
|
@ -8,17 +8,23 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jackson serializer for Owner
|
||||||
|
*
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
public class OwnerSerializer extends StdSerializer<Owner> {
|
public class OwnerSerializer extends StdSerializer<Owner> {
|
||||||
|
|
||||||
protected OwnerSerializer(Class<Owner> t) {
|
protected OwnerSerializer(Class<Owner> t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OwnerSerializer(){
|
public OwnerSerializer() {
|
||||||
super(Owner.class, true);
|
super(Owner.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(Owner owner, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
public void serialize(Owner owner, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
|
|
|
@ -8,19 +8,26 @@ import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.databind.SerializerProvider;
|
import com.fasterxml.jackson.databind.SerializerProvider;
|
||||||
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Jackson serializer for SimpleCredentials
|
||||||
|
*
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
public class SimpleCredentialsSerializer extends StdSerializer<SimpleCredentials> {
|
public class SimpleCredentialsSerializer extends StdSerializer<SimpleCredentials> {
|
||||||
|
|
||||||
protected SimpleCredentialsSerializer(Class<SimpleCredentials> t) {
|
protected SimpleCredentialsSerializer(Class<SimpleCredentials> t) {
|
||||||
super(t);
|
super(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SimpleCredentialsSerializer(){
|
public SimpleCredentialsSerializer() {
|
||||||
super(SimpleCredentials.class, true);
|
super(SimpleCredentials.class, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void serialize(SimpleCredentials credentials, JsonGenerator jgen, SerializerProvider provider) throws IOException {
|
public void serialize(SimpleCredentials credentials, JsonGenerator jgen, SerializerProvider provider)
|
||||||
|
throws IOException {
|
||||||
jgen.writeStartObject();
|
jgen.writeStartObject();
|
||||||
jgen.writeStringField("clientId", credentials.getClientID());
|
jgen.writeStringField("clientId", credentials.getClientID());
|
||||||
jgen.writeStringField("secret", "[*****]");
|
jgen.writeStringField("secret", "[*****]");
|
||||||
|
|
|
@ -10,13 +10,18 @@ import org.gcube.common.security.providers.SecretManagerProvider;
|
||||||
import org.gcube.common.security.secrets.Secret;
|
import org.gcube.common.security.secrets.Secret;
|
||||||
import org.gcube.smartgears.utils.InnerMethodName;
|
import org.gcube.smartgears.utils.InnerMethodName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Lucio Le (ISTI - CNR)
|
||||||
|
* @author Alfredo Oliviero (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
|
||||||
@Path("auth")
|
@Path("auth")
|
||||||
public class TestAuthorizationService {
|
public class AuthenticatedService {
|
||||||
|
|
||||||
private static final String ALLOWED_ROLE = "myRole";
|
private static final String ALLOWED_ROLE = "myRole";
|
||||||
private static final String ALLOWED_ROLE_ORG = "OrganizationMember";
|
private static final String ALLOWED_ROLE_ORG = "OrganizationMember";
|
||||||
|
|
||||||
@AuthorizationControl(allowedRoles={ALLOWED_ROLE_ORG})
|
@AuthorizationControl(allowedRoles = { ALLOWED_ROLE_ORG })
|
||||||
@GET
|
@GET
|
||||||
@Path("org_member")
|
@Path("org_member")
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
@ -25,10 +30,12 @@ public class TestAuthorizationService {
|
||||||
Secret secret = SecretManagerProvider.get();
|
Secret secret = SecretManagerProvider.get();
|
||||||
String userId = secret.getOwner().getId();
|
String userId = secret.getOwner().getId();
|
||||||
String context = secret.getContext();
|
String context = secret.getContext();
|
||||||
return String.format("User %s in context %s is authorized to execute this method because he has the correct role", userId,context);
|
return String.format(
|
||||||
|
"User %s in context %s is authorized to execute this method because he has the correct role", userId,
|
||||||
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AuthorizationControl(allowedRoles={ALLOWED_ROLE})
|
@AuthorizationControl(allowedRoles = { ALLOWED_ROLE })
|
||||||
@GET
|
@GET
|
||||||
@Path("")
|
@Path("")
|
||||||
@Produces(MediaType.TEXT_PLAIN)
|
@Produces(MediaType.TEXT_PLAIN)
|
||||||
|
@ -37,7 +44,9 @@ public class TestAuthorizationService {
|
||||||
Secret secret = SecretManagerProvider.get();
|
Secret secret = SecretManagerProvider.get();
|
||||||
String userId = secret.getOwner().getId();
|
String userId = secret.getOwner().getId();
|
||||||
String context = secret.getContext();
|
String context = secret.getContext();
|
||||||
return String.format("User %s in context %s is authorized to execute this method because he has the correct role", userId,context);
|
return String.format(
|
||||||
|
"User %s in context %s is authorized to execute this method because he has the correct role", userId,
|
||||||
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,7 +13,7 @@ import org.gcube.common.security.Owner;
|
||||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||||
import org.gcube.common.security.secrets.Secret;
|
import org.gcube.common.security.secrets.Secret;
|
||||||
import org.gcube.service.helloworld.manager.HelloWorldManager;
|
import org.gcube.service.helloworld.manager.HelloWorldManager;
|
||||||
import org.gcube.service.helloworld.serializers.SmartGearSerializator;
|
import org.gcube.service.helloworld.serializers.ContextSerializator;
|
||||||
import org.gcube.smartgears.ContextProvider;
|
import org.gcube.smartgears.ContextProvider;
|
||||||
import org.gcube.smartgears.annotations.ManagedBy;
|
import org.gcube.smartgears.annotations.ManagedBy;
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
import org.gcube.smartgears.context.container.ContainerContext;
|
||||||
|
@ -24,6 +24,12 @@ import org.slf4j.LoggerFactory;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Lucio Lelii (ISTI-CNR)
|
||||||
|
* @author Alfredo Oliviero (ISTI-CNR)
|
||||||
|
*/
|
||||||
|
|
||||||
@ManagedBy(HelloWorldManager.class)
|
@ManagedBy(HelloWorldManager.class)
|
||||||
@Path("")
|
@Path("")
|
||||||
public class HelloService {
|
public class HelloService {
|
||||||
|
@ -38,23 +44,23 @@ public class HelloService {
|
||||||
Secret secret = SecretManagerProvider.get();
|
Secret secret = SecretManagerProvider.get();
|
||||||
String userId = secret.getOwner().getId();
|
String userId = secret.getOwner().getId();
|
||||||
String context = secret.getContext();
|
String context = secret.getContext();
|
||||||
|
|
||||||
String infrastructureName = ContextProvider.get().container().configuration().infrastructure();
|
String infrastructureName = ContextProvider.get().container().configuration().infrastructure();
|
||||||
logger.info("caller id is {}",userId);
|
logger.info("caller id is {}", userId);
|
||||||
return String.format("Hello %s in context %s in infastructure %s -roles %s", userId,context, infrastructureName, secret.getOwner().getRoles());
|
return String.format("Hello %s in context %s in infastructure %s -roles %s", userId, context,
|
||||||
|
infrastructureName, secret.getOwner().getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("details")
|
@Path("details")
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response details() {
|
public Response details() {
|
||||||
InnerMethodName.set("details");
|
InnerMethodName.set("details");
|
||||||
|
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
|
|
||||||
Secret secret = SecretManagerProvider.get();
|
Secret secret = SecretManagerProvider.get();
|
||||||
|
|
||||||
|
|
||||||
String context = secret.getContext();
|
String context = secret.getContext();
|
||||||
data.put("context", context);
|
data.put("context", context);
|
||||||
|
|
||||||
|
@ -64,7 +70,7 @@ public class HelloService {
|
||||||
ContainerContext container = ContextProvider.get().container();
|
ContainerContext container = ContextProvider.get().container();
|
||||||
data.put("container", container);
|
data.put("container", container);
|
||||||
|
|
||||||
ObjectMapper objectMapper = SmartGearSerializator.getSerializer();
|
ObjectMapper objectMapper = ContextSerializator.getSerializer();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String jsonData = objectMapper.writeValueAsString(data);
|
String jsonData = objectMapper.writeValueAsString(data);
|
||||||
|
@ -75,5 +81,5 @@ public class HelloService {
|
||||||
return Response.serverError().build();
|
return Response.serverError().build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,15 +5,12 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.common.security.Owner;
|
import org.gcube.common.security.Owner;
|
||||||
import org.gcube.service.helloworld.serializers.ContainerConfigurationSerializer;
|
|
||||||
import org.gcube.service.helloworld.serializers.ContainerContextSerializer;
|
|
||||||
import org.gcube.service.helloworld.serializers.SimpleCredentialsSerializer;
|
|
||||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
import org.gcube.smartgears.context.container.ContainerContext;
|
||||||
import org.gcube.smartgears.security.SimpleCredentials;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
/**
|
||||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
*
|
||||||
|
* @author Lucio Lelii (ISTI-CNR)
|
||||||
|
*/
|
||||||
|
|
||||||
public class RestUtils {
|
public class RestUtils {
|
||||||
|
|
||||||
|
@ -45,11 +42,11 @@ public class RestUtils {
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Object> getContainerDict(ContainerContext container){
|
public static Map<String, Object> getContainerDict(ContainerContext container) {
|
||||||
Map<String, Object> data = new HashMap<>();
|
Map<String, Object> data = new HashMap<>();
|
||||||
data.put("id", container.id());
|
data.put("id", container.id());
|
||||||
data.put("configuration", container.configuration());
|
data.put("configuration", container.configuration());
|
||||||
//data.put("lifecycle", container.lifecycle());
|
// data.put("lifecycle", container.lifecycle());
|
||||||
data.put("properties", container.properties());
|
data.put("properties", container.properties());
|
||||||
data.put("authorizationProvider", container.authorizationProvider());
|
data.put("authorizationProvider", container.authorizationProvider());
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in New Issue