diff --git a/.classpath b/.classpath
index c67d98a..e27c82a 100644
--- a/.classpath
+++ b/.classpath
@@ -1,23 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -29,5 +11,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fc04794..e9e9c4a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,9 @@
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.1-SNAPSHOT] - [2024-02-02]
+
+- authorization endpoints configuration retrieving moved from common scanner to reflection library
## [v3.0.0] - [2022-06-06]
diff --git a/pom.xml b/pom.xml
index bc8261c..1428ab5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.gcube.common
common-authorization
- 3.0.0
+ 3.0.1-SNAPSHOT
authorization service common library
maven-parent
@@ -21,24 +21,23 @@
org.gcube.distribution
gcube-bom
- 3.0.0
+ 3.0.1-SNAPSHOT
pom
import
+
+ org.reflections
+ reflections
+
junit
junit
4.11
test
-
- org.gcube.core
- common-configuration-scanner
- [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)
-
org.slf4j
slf4j-api
@@ -53,4 +52,13 @@
runtime
+
+
+
+
+ src/main/resources
+ true
+
+
+
diff --git a/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java
index 9449d94..93548b3 100644
--- a/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java
+++ b/src/main/java/org/gcube/common/authorization/library/endpoints/AuthorizationEndpointScanner.java
@@ -1,18 +1,18 @@
package org.gcube.common.authorization.library.endpoints;
import java.net.URL;
+import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Pattern;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
-
-import org.gcube.common.scan.ClasspathScanner;
-import org.gcube.common.scan.ClasspathScannerFactory;
-import org.gcube.common.scan.matchers.NameMatcher;
-import org.gcube.common.scan.resources.ClasspathResource;
+import org.reflections.Reflections;
+import org.reflections.scanners.ResourcesScanner;
+import org.reflections.util.ClasspathHelper;
+import org.reflections.util.ConfigurationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,17 +38,22 @@ public class AuthorizationEndpointScanner {
try {
+ ConfigurationBuilder reflectionConf = new ConfigurationBuilder().addUrls(ClasspathHelper.forJavaClassPath()).addClassLoader(AuthorizationEndpointScanner.class.getClassLoader()).setScanners(new ResourcesScanner());
+
+ Reflections reflection = new Reflections(reflectionConf);
+
+ Set resources = reflection.getResources((String input)-> input.endsWith(".authorization"));
+ log.info("loading resources {} ", resources);
+
JAXBContext context = JAXBContext.newInstance(AuthorizationEndpoint.class);
Unmarshaller um = context.createUnmarshaller();
String defaultInfrastructure = null;
int defaultInfraPriority= Integer.MAX_VALUE;
- for (String r :getEnpointResourceNames()){
-
- URL url = Thread.currentThread().getContextClassLoader().getResource(r);
-
-
+ for (String resource: resources) {
+ log.info("loading {} ", resource);
+ URL url = Thread.currentThread().getContextClassLoader().getResource(resource);
AuthorizationEndpoint endpoint = (AuthorizationEndpoint)um.unmarshal(url);
if (defaultInfrastructure==null)
defaultInfrastructure = endpoint.getInfrastructure();
@@ -56,7 +61,7 @@ public class AuthorizationEndpointScanner {
if (!endpointsMap.containsKey(endpoint.getInfrastructure())
|| endpointsMap.get(endpoint.getInfrastructure()).getPriority()> endpoint.getPriority()){
- if (r.startsWith("default") && endpoint.getPriority() getEnpointResourceNames() {
-
- ClasspathScanner scanner = ClasspathScannerFactory.scanner();
- Set names = new HashSet();
- for (ClasspathResource r : scanner.scan(new NameMatcher(configurationPattern)))
- names.add(r.name());
- return names;
- }
-
-}
+}
\ No newline at end of file