From 3747b3f1058e84f1abdee4a7646021bdb0b69b47 Mon Sep 17 00:00:00 2001 From: lucio Date: Wed, 21 Feb 2024 20:27:02 +0100 Subject: [PATCH] porting to latest version of aspectJ --- .classpath | 28 +++---- .gitignore | 1 + .settings/org.eclipse.jdt.core.prefs | 8 +- .settings/org.eclipse.wst.common.component | 5 ++ ....eclipse.wst.common.project.facet.core.xml | 5 ++ .settings/org.eclipse.wst.validation.prefs | 2 + distro/LICENSE | 1 - distro/README | 64 ---------------- distro/changelog.xml | 5 -- distro/descriptor.xml | 36 --------- distro/profile.xml | 26 ------- pom.xml | 75 +++++-------------- .../control/AuthorizationAspect.java | 4 +- .../annotations/AuthorizationControl.java | 5 +- .../DefaultAuthorizationException.java | 16 ++++ 15 files changed, 72 insertions(+), 209 deletions(-) create mode 100644 .gitignore create mode 100644 .settings/org.eclipse.wst.common.component create mode 100644 .settings/org.eclipse.wst.common.project.facet.core.xml create mode 100644 .settings/org.eclipse.wst.validation.prefs delete mode 100644 distro/LICENSE delete mode 100644 distro/README delete mode 100644 distro/changelog.xml delete mode 100644 distro/descriptor.xml delete mode 100644 distro/profile.xml create mode 100644 src/main/java/org/gcube/common/authorization/control/exception/DefaultAuthorizationException.java diff --git a/.classpath b/.classpath index 1d05ba3..11f5b86 100644 --- a/.classpath +++ b/.classpath @@ -1,19 +1,6 @@ - - - - - - - - - - - - - - + @@ -24,5 +11,18 @@ + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index cac0df4..29fe717 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 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 +org.eclipse.jdt.core.compiler.source=11 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component new file mode 100644 index 0000000..c7925ef --- /dev/null +++ b/.settings/org.eclipse.wst.common.component @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml new file mode 100644 index 0000000..54a5299 --- /dev/null +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/.settings/org.eclipse.wst.validation.prefs b/.settings/org.eclipse.wst.validation.prefs new file mode 100644 index 0000000..04cad8c --- /dev/null +++ b/.settings/org.eclipse.wst.validation.prefs @@ -0,0 +1,2 @@ +disabled=06target +eclipse.preferences.version=1 diff --git a/distro/LICENSE b/distro/LICENSE deleted file mode 100644 index 3695e26..0000000 --- a/distro/LICENSE +++ /dev/null @@ -1 +0,0 @@ -${gcube.license} diff --git a/distro/README b/distro/README deleted file mode 100644 index 8055c89..0000000 --- a/distro/README +++ /dev/null @@ -1,64 +0,0 @@ -The gCube System - ${name} --------------------------------------------------- - -${description} - - -${gcube.description} - -${gcube.funding} - - -Version --------------------------------------------------- - -${version} (${buildDate}) - -Please see the file named "changelog.xml" in this directory for the release notes. - -Authors --------------------------------------------------- - -* Lucio Lelii (lucio.lelii-AT-isti.cnr.it), CNR, Italy - -Maintainers --------------------------------------------------- - -* Lucio Lelii (lucio.lelii-AT-isti.cnr.it), CNR, Italy - -Download information --------------------------------------------------- - -Source code is available from SVN: - ${scm.url} - -Binaries can be downloaded from the gCube website: - ${gcube.website} - - -Installation --------------------------------------------------- - -Installation documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot} - -Documentation --------------------------------------------------- - -Documentation is available on-line in the gCube Wiki: - ${gcube.wikiRoot} - -Support --------------------------------------------------- - -Bugs and support requests can be reported in the gCube issue tracking tool: - ${gcube.issueTracking} - - -Licensing --------------------------------------------------- - -This software is licensed under the terms you may find in the file named "LICENSE" in this directory. - - - diff --git a/distro/changelog.xml b/distro/changelog.xml deleted file mode 100644 index db267d7..0000000 --- a/distro/changelog.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - First Release - - \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml deleted file mode 100644 index 50e73a4..0000000 --- a/distro/descriptor.xml +++ /dev/null @@ -1,36 +0,0 @@ - - servicearchive - - tar.gz - - / - - - ${distroDirectory} - / - true - - README - LICENSE - changelog.xml - profile.xml - - 755 - true - - - - - - target/${build.finalName}.jar - /${artifactId} - - - diff --git a/distro/profile.xml b/distro/profile.xml deleted file mode 100644 index 91c49e4..0000000 --- a/distro/profile.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - Service - - ${description} - Common - ${artifactId} - 1.0.0 - - - ${artifactId} - ${version} - - ${groupId} - ${artifactId} - ${version} - - - ${build.finalName}.jar - - - - - - diff --git a/pom.xml b/pom.xml index 5bfa979..49de1e4 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ maven-parent org.gcube.tools - 1.1.0 + 1.2.0 scm:git:https://code-repo.d4science.org/gCubeSystem/authorization-control-library.git @@ -20,16 +20,16 @@ - 1.8 - 1.8 + 11 + 11 org.gcube.distribution - gcube-bom - 3.0.0-SNAPSHOT + gcube-smartgears-bom + 3.0.1-SNAPSHOT pom import @@ -41,12 +41,21 @@ org.gcube.common common-security + + org.gcube.core + common-smartgears + org.aspectj aspectjrt - 1.8.2 + 1.9.7 - + + + javax.ws.rs + javax.ws.rs-api + + org.slf4j slf4j-api @@ -85,9 +94,9 @@ org.codehaus.mojo aspectj-maven-plugin - 1.8 - 1.8 - 1.8 + 11 + 11 + 11 @@ -104,56 +113,12 @@ org.codehaus.mojo aspectj-maven-plugin + 1.14.0 org.apache.maven.plugins maven-compiler-plugin - - org.apache.maven.plugins - maven-resources-plugin - 2.5 - - - copy-profile - install - - copy-resources - - - target - - - . - true - - profile.xml - - - - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - descriptor.xml - - - - - servicearchive - install - - single - - - - \ No newline at end of file diff --git a/src/main/java/org/gcube/common/authorization/control/AuthorizationAspect.java b/src/main/java/org/gcube/common/authorization/control/AuthorizationAspect.java index 6500f53..6be64c2 100644 --- a/src/main/java/org/gcube/common/authorization/control/AuthorizationAspect.java +++ b/src/main/java/org/gcube/common/authorization/control/AuthorizationAspect.java @@ -38,9 +38,9 @@ public class AuthorizationAspect { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); AuthorizationControl authAnn = (AuthorizationControl) method.getAnnotation(AuthorizationControl.class); - log.info("aspect before with annotation {} with action {}, allowed {} in method {}", authAnn.annotationType(), authAnn.actions(), authAnn.allowedRoles(), authAnn.allowedUsers(), method.getName()); + log.info("aspect before with annotation {} allowed role {} and allowed users {} in method {}", authAnn.annotationType(), authAnn.allowedRoles(), authAnn.allowedUsers(), method.getName()); - Owner user = SecretManagerProvider.instance.get().getOwner(); + Owner user = SecretManagerProvider.get().getOwner(); String userId = user.getId(); Collection userRoles = user.getRoles(); diff --git a/src/main/java/org/gcube/common/authorization/control/annotations/AuthorizationControl.java b/src/main/java/org/gcube/common/authorization/control/annotations/AuthorizationControl.java index 9e18878..8621ec4 100644 --- a/src/main/java/org/gcube/common/authorization/control/annotations/AuthorizationControl.java +++ b/src/main/java/org/gcube/common/authorization/control/annotations/AuthorizationControl.java @@ -6,14 +6,15 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.gcube.common.authorization.control.exception.DefaultAuthorizationException; + @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface AuthorizationControl { - String[] actions() default {}; String[] allowedUsers() default {}; String[] allowedRoles() default {}; - Class exception(); + Class exception() default DefaultAuthorizationException.class; } diff --git a/src/main/java/org/gcube/common/authorization/control/exception/DefaultAuthorizationException.java b/src/main/java/org/gcube/common/authorization/control/exception/DefaultAuthorizationException.java new file mode 100644 index 0000000..c1f2c40 --- /dev/null +++ b/src/main/java/org/gcube/common/authorization/control/exception/DefaultAuthorizationException.java @@ -0,0 +1,16 @@ +package org.gcube.common.authorization.control.exception; + +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Response.Status; + +public class DefaultAuthorizationException extends WebApplicationException { + /** + * + */ + private static final long serialVersionUID = 1L; + + public DefaultAuthorizationException(Throwable cause) { + super(cause, Status.FORBIDDEN); + } + +} \ No newline at end of file