Compare commits
6 Commits
d89f456247
...
d17292c1b9
Author | SHA1 | Date |
---|---|---|
Alfredo Oliviero | d17292c1b9 | |
Alfredo Oliviero | debf091afa | |
lucio | feaac84e80 | |
lucio | c91ac3810b | |
lucio | 42ae8c5d3d | |
lucio | 639f76cbe4 |
|
@ -1,7 +1,4 @@
|
|||
{
|
||||
// Usare IntelliSense per informazioni sui possibili attributi.
|
||||
// Al passaggio del mouse vengono visualizzate le descrizioni degli attributi esistenti.
|
||||
// Per altre informazioni, visitare: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java11-tomcat9
|
||||
ARG JAVA_VERSION=11
|
||||
FROM d4science/smartgears-distribution:4.0.0-SNAPSHOT-java$JAVA_VERSION-tomcat10.1.19
|
||||
#FROM smartgears-distribution:4.0.0-SNAPSHOT-java$JAVA_VERSION-tomcat10.1.19
|
||||
|
||||
COPY ./docker/logback.xml /etc/
|
||||
COPY ./docker/container.ini /etc/
|
||||
|
|
|
@ -41,7 +41,6 @@ start the docker container
|
|||
|
||||
test urls (replace {{TOKEN}} with your token):
|
||||
|
||||
|
||||
http://localhost:8081/helloworld/guest
|
||||
|
||||
http://localhost:8080/helloworld/details?gcube-token={{TOKEN}}
|
||||
|
@ -51,6 +50,11 @@ http://localhost:8080/helloworld/auth?gcube-token={{TOKEN}} (checks for myRole r
|
|||
http://localhost:8080/helloworld/auth/orm_member?gcube-token={{TOKEN}} (checks for OrganizationMember role)
|
||||
|
||||
|
||||
GUBE state:
|
||||
http://localhost:8081/helloworld/gcube/resource/metrics
|
||||
http://localhost:8081/helloworld/gcube/resource/health
|
||||
|
||||
|
||||
### Authentication:
|
||||
|
||||
#### GCUBE-TOKEN param
|
||||
|
|
|
@ -1,8 +1,68 @@
|
|||
mvn clean package
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
accepted_java_versions=(11 17)
|
||||
|
||||
################################################################################
|
||||
# Help #
|
||||
################################################################################
|
||||
Help()
|
||||
{
|
||||
# Display Help
|
||||
echo "build, create and run in docker the helloworld service"
|
||||
echo
|
||||
echo "Syntax: buildDistribution [-n arg] [-p arg] [-j arg] [-d arg?] [-h]"
|
||||
echo "options:"
|
||||
echo "-n arg specifies the docker image name (default is smartgears-helloworld)."
|
||||
echo "-p arg specifies the port to be exposed for the docker container to access the service (default 8081)"
|
||||
echo "-j arg specify java version (default is 11)"
|
||||
echo " accepted version are: ${accepted_java_versions[@]}"
|
||||
echo "-d arg? enable java debug mode"
|
||||
echo " arg is the debug port (default is 5005)"
|
||||
echo "-h Print this Help."
|
||||
echo
|
||||
}
|
||||
|
||||
################################################################################
|
||||
################################################################################
|
||||
# Main program #
|
||||
################################################################################
|
||||
################################################################################
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
NAME=smartgears-helloworld
|
||||
PORT=8081
|
||||
DEBUG_PORT=5001
|
||||
DEBUG_PORT=5005
|
||||
debug=false
|
||||
compile=false
|
||||
java_version=11
|
||||
|
||||
while getopts n:p:j:d?h flag
|
||||
do
|
||||
echo ${flag};
|
||||
case "${flag}" in
|
||||
n) NAME=${OPTARG};;
|
||||
p) PORT=${OPTARG};;
|
||||
d) debug=true && DEBUG_PORT=${OPTARG:-5005};;
|
||||
j) if [[ ${accepted_java_versions[@]} =~ ${OPTARG} ]]
|
||||
then java_version=${OPTARG};
|
||||
else echo "Invalid java version" && echo "accepted version are: ${accepted_java_versions[@]}" && exit 1;
|
||||
fi;;
|
||||
h) Help && exit 0 ;;
|
||||
*) echo "Invalid option" && exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
mvn clean package
|
||||
|
||||
docker build -t $NAME --build-arg JAVA_VERSION=${java_version} .
|
||||
|
||||
if [ $debug = false ] ; then
|
||||
docker run -p $PORT:8080 $NAME
|
||||
else
|
||||
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $NAME
|
||||
fi
|
||||
|
||||
|
||||
docker build -t $NAME .
|
||||
docker run -p $PORT:8080 $NAME
|
|
@ -1,9 +0,0 @@
|
|||
mvn clean package
|
||||
|
||||
NAME=smartgears-helloworld
|
||||
PORT=8081
|
||||
DEBUG_PORT=5001
|
||||
|
||||
docker build -t $NAME .
|
||||
|
||||
docker run -p $PORT:8080 -p $DEBUG_PORT:5005 -e JAVA_TOOL_OPTIONS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=y" $NAME
|
|
@ -1,6 +1,6 @@
|
|||
[node]
|
||||
mode = offline
|
||||
hostname = myhostname.isti.cnr.it
|
||||
hostname = mb-lelii.isti.cnr.it
|
||||
protocol= http
|
||||
port = 8080
|
||||
infrastructure = gcube
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
|
||||
<logger name="org.gcube.service.helloworld" level="DEBUG" />
|
||||
<logger name="org.gcube.smartgears" level="DEBUG" />
|
||||
<logger name="org.gcube.smartgears" level="INFO" />
|
||||
|
||||
<root level="WARN">
|
||||
<appender-ref ref="STDOUT" />
|
||||
|
|
|
@ -14,7 +14,13 @@
|
|||
"type": "noauth"
|
||||
},
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"header": [
|
||||
{
|
||||
"key": "",
|
||||
"value": "{{token}}",
|
||||
"type": "text"
|
||||
}
|
||||
],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/{{application}}/hello?gcube-token={{gcube_token}}",
|
||||
"host": [
|
||||
|
@ -138,41 +144,6 @@
|
|||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "auth TOKEN PARAM",
|
||||
"request": {
|
||||
"auth": {
|
||||
"type": "bearer",
|
||||
"bearer": [
|
||||
{
|
||||
"key": "token",
|
||||
"value": "{{uma_token}}",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/{{application}}/auth/?gcube-token={{gcube_token}}",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"{{application}}",
|
||||
"auth",
|
||||
""
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "gcube-token",
|
||||
"value": "{{gcube_token}}"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "auth org member BEARER",
|
||||
"request": {
|
||||
|
@ -189,9 +160,9 @@
|
|||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "Z{{base_url}}/{{application}}/auth/org_member",
|
||||
"raw": "{{base_url}}/{{application}}/auth/org_member",
|
||||
"host": [
|
||||
"Z{{base_url}}"
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"{{application}}",
|
||||
|
|
|
@ -8,10 +8,15 @@
|
|||
A gcube HelloWorld service - smartgears 4
|
||||
</description>
|
||||
<servlet>
|
||||
<servlet-name>org.gcube.service.helloworld.HelloWorld</servlet-name>
|
||||
<servlet-name>HelloWorld</servlet-name>
|
||||
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
|
||||
<init-param>
|
||||
<param-name>jersey.config.server.provider.packages</param-name>
|
||||
<param-value>org.gcube.service.helloworld.services</param-value>
|
||||
</init-param>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>org.gcube.service.helloworld.HelloWorld</servlet-name>
|
||||
<servlet-name>HelloWorld</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
36
pom.xml
36
pom.xml
|
@ -2,7 +2,7 @@
|
|||
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>
|
||||
|
||||
|
||||
<groupId>org.gcube.service</groupId>
|
||||
<artifactId>helloworld</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
|
@ -31,7 +31,8 @@
|
|||
scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</connection>
|
||||
<developerConnection>
|
||||
scm:git:https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</url>
|
||||
<url>
|
||||
https://code-repo.d4science.org/gCubeSystem/hello-world-sg4-service.git</url>
|
||||
</scm>
|
||||
|
||||
<dependencyManagement>
|
||||
|
@ -47,6 +48,17 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- <dependency>
|
||||
<groupId>org.keycloak</groupId>
|
||||
<artifactId>keycloak-admin-client-jakarta</artifactId>
|
||||
<version>21.1.2</version>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
</dependency>
|
||||
<!-- smartgears -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
|
@ -66,25 +78,19 @@
|
|||
</dependency>
|
||||
|
||||
<!-- jersey -->
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-cdi2-se -->
|
||||
|
||||
<!--
|
||||
https://mvnrepository.com/artifact/org.glassfish.jersey.inject/jersey-cdi2-se -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.inject</groupId>
|
||||
<artifactId>jersey-cdi2-se</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- add jackson as json provider -->
|
||||
<dependency>
|
||||
|
@ -101,7 +107,8 @@
|
|||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
|
||||
<!-- OPTIONAL generate the war in a different folder, that will be mounted on docker
|
||||
<!-- OPTIONAL generate the war in a different folder, that will be
|
||||
mounted on docker
|
||||
container -->
|
||||
<!-- <plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -113,7 +120,8 @@
|
|||
</configuration>
|
||||
</plugin> -->
|
||||
|
||||
<!-- OPTIONAL. authorization-control-library: add this plugin if you want to use gcube
|
||||
<!-- OPTIONAL. authorization-control-library: add this plugin if you
|
||||
want to use gcube
|
||||
authorization control funzionalities -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package org.gcube.service.helloworld;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
import javax.ws.rs.core.Application;
|
||||
|
||||
import org.gcube.service.helloworld.services.AuthenticatedService;
|
||||
import org.gcube.service.helloworld.services.ExcludeAuthorizationService;
|
||||
import org.gcube.service.helloworld.services.HelloService;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Lucio Lelii (ISTI-CNR)
|
||||
*/
|
||||
|
||||
@ApplicationPath("")
|
||||
public class HelloWorld extends Application {
|
||||
|
||||
public Set<Class<?>> getClasses() {
|
||||
final Set<Class<?>> classes = new HashSet<Class<?>>();
|
||||
// register resources classes implementing Servlets
|
||||
classes.add(HelloService.class);
|
||||
classes.add(ExcludeAuthorizationService.class);
|
||||
classes.add(AuthenticatedService.class);
|
||||
return classes;
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package org.gcube.service.helloworld.services;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.common.authorization.control.annotations.AuthorizationControl;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
|
@ -11,7 +11,7 @@ import org.gcube.common.security.secrets.Secret;
|
|||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
|
||||
/**
|
||||
* @author Lucio Le (ISTI - CNR)
|
||||
* @author Lucio Lelii (ISTI - CNR)
|
||||
* @author Alfredo Oliviero (ISTI - CNR)
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.gcube.service.helloworld.services;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
|
@ -3,11 +3,11 @@ package org.gcube.service.helloworld.services;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
|
|
Loading…
Reference in New Issue