New version
This commit is contained in:
parent
9b7433f730
commit
94276c97f4
|
@ -2,6 +2,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
# Changelog for Accounting Service
|
# Changelog for Accounting Service
|
||||||
|
|
||||||
|
## [v2.1.0-SNAPSHOT]
|
||||||
|
|
||||||
|
- Added request filter to allow the service to properly run with any Smartgears version
|
||||||
|
|
||||||
## [v2.0.0]
|
## [v2.0.0]
|
||||||
|
|
||||||
|
|
7
pom.xml
7
pom.xml
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.accounting</groupId>
|
<groupId>org.gcube.accounting</groupId>
|
||||||
<artifactId>accounting-service</artifactId>
|
<artifactId>accounting-service</artifactId>
|
||||||
<version>2.0.0</version>
|
<version>2.1.0-SNAPSHOT</version>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<name>Accounting Service</name>
|
<name>Accounting Service</name>
|
||||||
<description>This service allows any client to publish Accounting data</description>
|
<description>This service allows any client to publish Accounting data</description>
|
||||||
|
@ -48,6 +48,11 @@
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.common</groupId>
|
||||||
|
<artifactId>authorization-utils</artifactId>
|
||||||
|
<version>[2.2.0, 3.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.accounting</groupId>
|
<groupId>org.gcube.accounting</groupId>
|
||||||
<artifactId>accounting-lib</artifactId>
|
<artifactId>accounting-lib</artifactId>
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package org.gcube.accounting.service.resources;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import javax.ws.rs.container.ContainerRequestContext;
|
||||||
|
import javax.ws.rs.container.ContainerRequestFilter;
|
||||||
|
import javax.ws.rs.container.ContainerResponseContext;
|
||||||
|
import javax.ws.rs.container.ContainerResponseFilter;
|
||||||
|
import javax.ws.rs.container.PreMatching;
|
||||||
|
import javax.ws.rs.ext.Provider;
|
||||||
|
|
||||||
|
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||||
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||||
|
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||||
|
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||||
|
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||||
|
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||||
|
import org.gcube.common.authorization.utils.secret.Secret;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
@Provider
|
||||||
|
@PreMatching
|
||||||
|
public class RequestFilter implements ContainerRequestFilter, ContainerResponseFilter {
|
||||||
|
|
||||||
|
private final static Logger logger = LoggerFactory.getLogger(RequestFilter.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(ContainerRequestContext requestContext) throws IOException {
|
||||||
|
logger.trace("PreMatching RequestFilter");
|
||||||
|
|
||||||
|
SecretManagerProvider.instance.remove();
|
||||||
|
SecretManager secretManager = new SecretManager();
|
||||||
|
|
||||||
|
String token = AccessTokenProvider.instance.get();
|
||||||
|
if(token!=null) {
|
||||||
|
Secret secret = new JWTSecret(token);
|
||||||
|
secretManager.addSecret(secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
token = SecurityTokenProvider.instance.get();
|
||||||
|
if(token!=null) {
|
||||||
|
Secret secret = new GCubeSecret(token);
|
||||||
|
secretManager.addSecret(secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
SecretManagerProvider.instance.set(secretManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
|
||||||
|
throws IOException {
|
||||||
|
logger.trace("ResponseFilter");
|
||||||
|
SecretManagerProvider.instance.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue