From d3e0062060ac81181b817d06f298f74d5198b733 Mon Sep 17 00:00:00 2001 From: lucio Date: Mon, 30 May 2022 18:55:04 +0200 Subject: [PATCH 1/4] removed all providers --- pom.xml | 2 +- .../library/AuthorizedTasks.java | 96 ------------------- .../library/provider/AccessTokenProvider.java | 31 ------ .../provider/AuthorizationProvider.java | 35 ------- .../provider/CalledMethodProvider.java | 39 -------- .../provider/SecurityTokenProvider.java | 33 ------- 6 files changed, 1 insertion(+), 235 deletions(-) delete mode 100644 src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java delete mode 100644 src/main/java/org/gcube/common/authorization/library/provider/AccessTokenProvider.java delete mode 100644 src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java delete mode 100644 src/main/java/org/gcube/common/authorization/library/provider/CalledMethodProvider.java delete mode 100644 src/main/java/org/gcube/common/authorization/library/provider/SecurityTokenProvider.java diff --git a/pom.xml b/pom.xml index c5e8b6a..2e73c4c 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.gcube.common common-authorization - 2.5.0 + 3.0.0-SNAPSHOT authorization service common library diff --git a/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java b/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java deleted file mode 100644 index ed7e133..0000000 --- a/src/main/java/org/gcube/common/authorization/library/AuthorizedTasks.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.gcube.common.authorization.library; - -import java.util.concurrent.Callable; - -import org.gcube.common.authorization.library.provider.AccessTokenProvider; -import org.gcube.common.authorization.library.provider.AuthorizationProvider; -import org.gcube.common.authorization.library.provider.SecurityTokenProvider; -import org.gcube.common.authorization.library.utils.Caller; -import org.gcube.common.scope.api.ScopeProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class AuthorizedTasks { - - private static Logger logger= LoggerFactory.getLogger(AuthorizedTasks.class); - - /** - * Binds a {@link Callable} task to the current scope and user. - * @param task the task - * @return an equivalent {@link Callable} task bound to the current scope and user - */ - static public Callable bind(final Callable task) { - - - final Caller userCall = AuthorizationProvider.instance.get(); - - final String token = SecurityTokenProvider.instance.get(); - - final String scope = ScopeProvider.instance.get(); - - final String accessToken = AccessTokenProvider.instance.get(); - - return new Callable() { - @Override - public V call() throws Exception { - - - AuthorizationProvider.instance.set(userCall); - SecurityTokenProvider.instance.set(token); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(accessToken); - - try { - logger.info("setting on authorized task scope {} and token {}", scope, token); - return task.call(); - } - finally { - AuthorizationProvider.instance.reset(); - SecurityTokenProvider.instance.reset(); - ScopeProvider.instance.reset(); - } - - } - }; - } - - /** - * Binds a {@link Runnable} task to the current scope and user. - * @param task the task - * @return an equivalent {@link Runnable} task bound to the current scope and user - */ - static public Runnable bind(final Runnable task) { - - - final Caller userCall = AuthorizationProvider.instance.get(); - - final String token = SecurityTokenProvider.instance.get(); - - final String scope = ScopeProvider.instance.get(); - - final String accessToken = AccessTokenProvider.instance.get(); - - return new Runnable() { - @Override - public void run() { - AuthorizationProvider.instance.set(userCall); - SecurityTokenProvider.instance.set(token); - ScopeProvider.instance.set(scope); - AccessTokenProvider.instance.set(accessToken); - - try { - logger.info("setting on authorized task scope {} and token {}", scope, token); - task.run(); - } - finally { - AuthorizationProvider.instance.reset(); - SecurityTokenProvider.instance.reset(); - ScopeProvider.instance.reset(); - } - - } - }; - } - -} diff --git a/src/main/java/org/gcube/common/authorization/library/provider/AccessTokenProvider.java b/src/main/java/org/gcube/common/authorization/library/provider/AccessTokenProvider.java deleted file mode 100644 index e118d33..0000000 --- a/src/main/java/org/gcube/common/authorization/library/provider/AccessTokenProvider.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.gcube.common.authorization.library.provider; - -@Deprecated -public class AccessTokenProvider { - - public static AccessTokenProvider instance = new AccessTokenProvider(); - - private static final InheritableThreadLocal threadToken = new InheritableThreadLocal() { - - @Override - protected String initialValue() { - return null; - } - - }; - - private AccessTokenProvider() { - } - - public String get() { - return threadToken.get(); - } - - public void set(String jwt) { - threadToken.set(jwt); - } - - public void reset() { - threadToken.remove(); - } -} diff --git a/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java b/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java deleted file mode 100644 index eed2fe2..0000000 --- a/src/main/java/org/gcube/common/authorization/library/provider/AuthorizationProvider.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.gcube.common.authorization.library.provider; - -import org.gcube.common.authorization.library.utils.Caller; - -@Deprecated -public class AuthorizationProvider { - - public static AuthorizationProvider instance = new AuthorizationProvider(); - - // Thread local variable containing each thread's ID - private static final InheritableThreadLocal threadAuth = - new InheritableThreadLocal() { - - @Override protected Caller initialValue() { - return null; - } - - }; - - private AuthorizationProvider(){} - - public Caller get(){ - Caller info = threadAuth.get(); - return info; - } - - public void set(Caller info){ - threadAuth.set(info); - } - - public void reset(){ - threadAuth.remove(); - } - -} diff --git a/src/main/java/org/gcube/common/authorization/library/provider/CalledMethodProvider.java b/src/main/java/org/gcube/common/authorization/library/provider/CalledMethodProvider.java deleted file mode 100644 index 991375a..0000000 --- a/src/main/java/org/gcube/common/authorization/library/provider/CalledMethodProvider.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.gcube.common.authorization.library.provider; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class CalledMethodProvider { - -public static CalledMethodProvider instance = new CalledMethodProvider(); - - private static Logger logger = LoggerFactory.getLogger(CalledMethodProvider.class); - - // Thread local variable containing each thread's ID - private static final InheritableThreadLocal threadMethod = - new InheritableThreadLocal() { - - @Override protected String initialValue() { - return "UNKNOWN"; - } - - }; - - private CalledMethodProvider(){} - - public String get(){ - String calledMethod = threadMethod.get(); - logger.trace("getting calledMethod as "+calledMethod+" in thread "+Thread.currentThread().getId() ); - return calledMethod; - } - - public void set(String calledMethod){ - if (calledMethod==null) return; - threadMethod.set(calledMethod); - logger.trace("setting calledMethod as "+calledMethod+" in thread "+Thread.currentThread().getId() ); - } - - public void reset(){ - threadMethod.remove(); - } -} diff --git a/src/main/java/org/gcube/common/authorization/library/provider/SecurityTokenProvider.java b/src/main/java/org/gcube/common/authorization/library/provider/SecurityTokenProvider.java deleted file mode 100644 index c80d323..0000000 --- a/src/main/java/org/gcube/common/authorization/library/provider/SecurityTokenProvider.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.gcube.common.authorization.library.provider; - -@Deprecated -public class SecurityTokenProvider { - - public static SecurityTokenProvider instance = new SecurityTokenProvider(); - - //private static Logger logger = LoggerFactory.getLogger(SecurityTokenProvider.class); - - // Thread local variable containing each thread's ID - private static final InheritableThreadLocal threadToken = - new InheritableThreadLocal() { - - @Override protected String initialValue() { - return null; - } - - }; - - private SecurityTokenProvider(){} - - public String get(){ - return threadToken.get(); - } - - public void set(String authorizationToken){ - threadToken.set(authorizationToken); - } - - public void reset(){ - threadToken.remove(); - } -} From 2a0f1d25825b4df00f8ebab292e82a5b8304fdb2 Mon Sep 17 00:00:00 2001 From: lucio Date: Mon, 6 Jun 2022 15:37:32 +0200 Subject: [PATCH 2/4] removed common-scope dependency --- CHANGELOG.md | 5 ++ pom.xml | 77 ++++++++++--------- .../library/AuthorizationEntry.java | 14 +--- 3 files changed, 45 insertions(+), 51 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a8d785..29dc2c9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [v3.0.0-SNAPSHOT] - [2022-06-06] + +- removed common-scope from the dependencies + ## [v2.5.0] - [2022-04-20] - Deprecated AccessTokenProvider, AuthorizationProvider and SecurityTokenProvider [#22871] diff --git a/pom.xml b/pom.xml index 2e73c4c..0aabd7e 100644 --- a/pom.xml +++ b/pom.xml @@ -1,41 +1,42 @@ - - 4.0.0 - org.gcube.common - common-authorization - 3.0.0-SNAPSHOT - authorization service common library - - maven-parent - org.gcube.tools - 1.1.0 - - - - scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git - scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git - https://code-repo.d4science.org/gCubeSystem/common-authorization - + + 4.0.0 + org.gcube.common + common-authorization + 3.0.0-SNAPSHOT + authorization service common library - - - org.gcube.core - common-scope - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) - - - junit - junit - 4.11 - test - - - - org.slf4j - slf4j-api - 1.7.5 - - + + maven-parent + org.gcube.tools + 1.1.0 + - + + scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git + scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git + https://code-repo.d4science.org/gCubeSystem/common-authorization + + + + + junit + junit + 4.11 + test + + + org.gcube.core + common-configuration-scanner + [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) + + + org.slf4j + slf4j-api + 1.7.5 + + + + diff --git a/src/main/java/org/gcube/common/authorization/library/AuthorizationEntry.java b/src/main/java/org/gcube/common/authorization/library/AuthorizationEntry.java index c69245c..7d4e6ca 100644 --- a/src/main/java/org/gcube/common/authorization/library/AuthorizationEntry.java +++ b/src/main/java/org/gcube/common/authorization/library/AuthorizationEntry.java @@ -18,8 +18,6 @@ import org.gcube.common.authorization.library.provider.ContainerInfo; import org.gcube.common.authorization.library.provider.ExternalServiceInfo; import org.gcube.common.authorization.library.provider.ServiceInfo; import org.gcube.common.authorization.library.provider.UserInfo; -import org.gcube.common.scope.api.ServiceMap; -import org.gcube.common.scope.impl.DefaultServiceMap; @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) @@ -35,9 +33,6 @@ public class AuthorizationEntry { private String context; - @XmlElementRef(type = DefaultServiceMap.class) - private ServiceMap map; - @XmlElementRefs({ @XmlElementRef(type = Service2ServicePolicy.class), @XmlElementRef(type = User2ServicePolicy.class), @@ -68,18 +63,11 @@ public class AuthorizationEntry { return context; } - public ServiceMap getMap() { - return map; - } public String getQualifier() { return qualifier; } - public void setMap(ServiceMap map) { - this.map = map; - } - public List getPolicies() { return policies; } @@ -128,7 +116,7 @@ public class AuthorizationEntry { @Override public String toString() { return "AuthorizationEntry [clientInfo=" + clientInfo + ", context=" - + context + ", map=" + map + ", qualifier=" + qualifier + + context + ", qualifier=" + qualifier + ", policies=" + policies + "]"; } From 54fc75efe52309a61a9b7a869fe5f7f6bc13106d Mon Sep 17 00:00:00 2001 From: lucio lelii Date: Tue, 28 Jun 2022 12:26:51 +0200 Subject: [PATCH 3/4] package updated --- .../{enpoints => endpoints}/AuthorizationEndpoint.java | 2 +- .../{enpoints => endpoints}/AuthorizationEndpointScanner.java | 2 +- .../library/{enpoints => endpoints}/EndpointsContainer.java | 2 +- .../common/authorization/library/binder/EndpointBinder.java | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/main/java/org/gcube/common/authorization/library/{enpoints => endpoints}/AuthorizationEndpoint.java (98%) rename src/main/java/org/gcube/common/authorization/library/{enpoints => endpoints}/AuthorizationEndpointScanner.java (98%) rename src/main/java/org/gcube/common/authorization/library/{enpoints => endpoints}/EndpointsContainer.java (90%) diff --git a/src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpoint.java b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpoint.java similarity index 98% rename from src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpoint.java rename to src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpoint.java index 54c9500..6d06bb4 100644 --- a/src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpoint.java +++ b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpoint.java @@ -1,4 +1,4 @@ -package org.gcube.common.authorization.library.enpoints; +package org.gcube.common.authorization.library.endpoints; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; diff --git a/src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpointScanner.java b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java similarity index 98% rename from src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpointScanner.java rename to src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java index 70be1e1..9449d94 100644 --- a/src/main/java/org/gcube/common/authorization/library/enpoints/AuthorizationEndpointScanner.java +++ b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java @@ -1,4 +1,4 @@ -package org.gcube.common.authorization.library.enpoints; +package org.gcube.common.authorization.library.endpoints; import java.net.URL; import java.util.HashMap; diff --git a/src/main/java/org/gcube/common/authorization/library/enpoints/EndpointsContainer.java b/src/main/java/org/gcube/common/authorization/library/endpoints/EndpointsContainer.java similarity index 90% rename from src/main/java/org/gcube/common/authorization/library/enpoints/EndpointsContainer.java rename to src/main/java/org/gcube/common/authorization/library/endpoints/EndpointsContainer.java index 15fae84..6589d09 100644 --- a/src/main/java/org/gcube/common/authorization/library/enpoints/EndpointsContainer.java +++ b/src/main/java/org/gcube/common/authorization/library/endpoints/EndpointsContainer.java @@ -1,4 +1,4 @@ -package org.gcube.common.authorization.library.enpoints; +package org.gcube.common.authorization.library.endpoints; import java.util.Map; diff --git a/src/test/java/org/gcube/common/authorization/library/binder/EndpointBinder.java b/src/test/java/org/gcube/common/authorization/library/binder/EndpointBinder.java index ae6673e..510a05c 100644 --- a/src/test/java/org/gcube/common/authorization/library/binder/EndpointBinder.java +++ b/src/test/java/org/gcube/common/authorization/library/binder/EndpointBinder.java @@ -8,8 +8,8 @@ import java.util.Map; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; -import org.gcube.common.authorization.library.enpoints.AuthorizationEndpoint; -import org.gcube.common.authorization.library.enpoints.AuthorizationEndpointScanner; +import org.gcube.common.authorization.library.endpoints.AuthorizationEndpoint; +import org.gcube.common.authorization.library.endpoints.AuthorizationEndpointScanner; import org.junit.Assert; import org.junit.Test; From 5d3cc1261045f304fc8803c302763dd6b0eaff51 Mon Sep 17 00:00:00 2001 From: lucio Date: Fri, 31 Mar 2023 14:45:23 +0200 Subject: [PATCH 4/4] update --- .classpath | 1 + .settings/org.eclipse.jdt.core.prefs | 2 +- pom.xml | 26 ++++++++++++++++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.classpath b/.classpath index a5d9509..c67d98a 100644 --- a/.classpath +++ b/.classpath @@ -26,6 +26,7 @@ + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index db24ee7..671cad6 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -10,6 +10,6 @@ org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index 0aabd7e..61d0173 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,3 @@ - @@ -7,19 +6,27 @@ common-authorization 3.0.0-SNAPSHOT authorization service common library - maven-parent org.gcube.tools 1.1.0 - scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git scm:git:https://code-repo.d4science.org/gCubeSystem/common-authorization.git https://code-repo.d4science.org/gCubeSystem/common-authorization - + + + + org.gcube.distribution + gcube-bom + 3.0.0-SNAPSHOT + pom + import + + + junit @@ -35,8 +42,15 @@ org.slf4j slf4j-api - 1.7.5 + + + jakarta.xml.bind + jakarta.xml.bind-api + + + com.sun.xml.bind + jaxb-impl + runtime -