diff --git a/.classpath b/.classpath
index 85f0971..1f5e859 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -18,7 +18,7 @@
-
+
@@ -30,5 +30,5 @@
-
+
diff --git a/pom.xml b/pom.xml
index 71368f6..5d7ca25 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,9 +158,20 @@
org.junit.jupiter
junit-jupiter-engine
5.10.1
- test
+ test
+
+
+ net.revelc.code.formatter
+ formatter-maven-plugin
+ 2.23.0
-
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.3.1
+
+
+
src
test/src
@@ -241,7 +252,7 @@
org.apache.maven.plugins
maven-checkstyle-plugin
- 3.1.0
+ 3.3.1
CheckStyle.xml
true
@@ -253,7 +264,7 @@
net.revelc.code.formatter
formatter-maven-plugin
- 2.12.2
+ 2.23.0
UTF-8
LF
diff --git a/src/org/kar/archidata/catcher/JacksonCatcher.java b/src/org/kar/archidata/catcher/JacksonCatcher.java
index 7111ceb..c447cf9 100644
--- a/src/org/kar/archidata/catcher/JacksonCatcher.java
+++ b/src/org/kar/archidata/catcher/JacksonCatcher.java
@@ -11,7 +11,7 @@ import jakarta.ws.rs.ext.ExceptionMapper;
public class JacksonCatcher implements ExceptionMapper {
private static final Logger LOGGER = LoggerFactory.getLogger(JacksonCatcher.class);
-
+
@Override
public Response toResponse(final JsonProcessingException exception) {
LOGGER.warn("Catch exception Input data parsing:");
@@ -20,9 +20,9 @@ public class JacksonCatcher implements ExceptionMapper
exception.printStackTrace();
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ret).type(MediaType.APPLICATION_JSON).build();
}
-
+
private RestErrorResponse build(final Exception exception) {
return new RestErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Catch JSON Exception", exception.getMessage());
}
-
+
}
diff --git a/src/org/kar/archidata/db/DBEntry.java b/src/org/kar/archidata/db/DBEntry.java
index af7fe00..3085da9 100644
--- a/src/org/kar/archidata/db/DBEntry.java
+++ b/src/org/kar/archidata/db/DBEntry.java
@@ -52,7 +52,7 @@ public class DBEntry implements Closeable {
try {
this.connection = DriverManager.getConnection(this.config.getUrl(true), this.config.getLogin(), this.config.getPassword());
} catch (final SQLException ex) {
- throw new IOException("Connection db fail: " + ex.getMessage());
+ throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
}
}
@@ -61,7 +61,7 @@ public class DBEntry implements Closeable {
try {
this.connection = DriverManager.getConnection(this.config.getUrl(), this.config.getLogin(), this.config.getPassword());
} catch (final SQLException ex) {
- throw new IOException("Connection db fail: " + ex.getMessage());
+ throw new IOException("Connection db fail: " + ex.getMessage() + " On URL: " + this.config.getUrl(true));
}
}
diff --git a/src/org/kar/archidata/filter/AuthenticationFilter.java b/src/org/kar/archidata/filter/AuthenticationFilter.java
index 4601532..f0aee38 100644
--- a/src/org/kar/archidata/filter/AuthenticationFilter.java
+++ b/src/org/kar/archidata/filter/AuthenticationFilter.java
@@ -61,7 +61,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
abortWithForbidden(requestContext, "Access blocked !!!");
return;
}
-
+
// Access allowed for all
if (method.isAnnotationPresent(PermitAll.class)) {
// logger.debug(" ==> permit all " + requestContext.getUriInfo().getPath());
@@ -74,7 +74,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
abortWithForbidden(requestContext, "Access ILLEGAL !!!");
return;
}
-
+
// Get the Authorization header from the request
String authorizationHeader = requestContext.getHeaderString(HttpHeaders.AUTHORIZATION);
String apikeyHeader = requestContext.getHeaderString(APIKEY);
@@ -129,7 +129,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
abortWithUnauthorized(requestContext, "get a NULL application ...");
return;
}
-
+
}
// create the security context model:
final String scheme = requestContext.getUriInfo().getRequestUri().getScheme();
@@ -161,7 +161,7 @@ public class AuthenticationFilter implements ContainerRequestFilter {
// The authentication scheme comparison must be case-insensitive
return authorizationHeader != null && authorizationHeader.toLowerCase().startsWith(AUTHENTICATION_SCHEME.toLowerCase() + " ");
}
-
+
private void abortWithUnauthorized(final ContainerRequestContext requestContext, final String message) {
// Abort the filter chain with a 401 status code response
diff --git a/src/org/kar/archidata/filter/MySecurityContext.java b/src/org/kar/archidata/filter/MySecurityContext.java
index de5ec31..af2b386 100644
--- a/src/org/kar/archidata/filter/MySecurityContext.java
+++ b/src/org/kar/archidata/filter/MySecurityContext.java
@@ -8,20 +8,20 @@ import jakarta.ws.rs.core.SecurityContext;
// https://simplapi.wordpress.com/2015/09/19/jersey-jax-rs-securitycontext-in-action/
class MySecurityContext implements SecurityContext {
-
+
private final GenericContext contextPrincipale;
private final String sheme;
-
+
public MySecurityContext(final UserByToken userByToken, final String sheme) {
this.contextPrincipale = new GenericContext(userByToken);
this.sheme = sheme;
}
-
+
@Override
public Principal getUserPrincipal() {
return this.contextPrincipale;
}
-
+
@Override
public boolean isUserInRole(final String role) {
if (this.contextPrincipale.userByToken != null) {
@@ -32,12 +32,12 @@ class MySecurityContext implements SecurityContext {
}
return false;
}
-
+
@Override
public boolean isSecure() {
return "https".equalsIgnoreCase(this.sheme);
}
-
+
@Override
public String getAuthenticationScheme() {
if (this.contextPrincipale.userByToken != null) {
@@ -45,5 +45,5 @@ class MySecurityContext implements SecurityContext {
}
return null;
}
-
+
}
\ No newline at end of file
diff --git a/src/org/kar/archidata/tools/ConfigBaseVariable.java b/src/org/kar/archidata/tools/ConfigBaseVariable.java
index d5bc208..8069962 100644
--- a/src/org/kar/archidata/tools/ConfigBaseVariable.java
+++ b/src/org/kar/archidata/tools/ConfigBaseVariable.java
@@ -14,6 +14,9 @@ public class ConfigBaseVariable {
static public String ssoAdress;
static public String ssoToken;
static public String testMode;
+ static public String eMailFrom;
+ static public String eMailLogin;
+ static public String eMailPassword;
// For test only
public static void clearAllValue() {
@@ -30,6 +33,9 @@ public class ConfigBaseVariable {
ssoAdress = System.getenv("SSO_ADDRESS");
ssoToken = System.getenv("SSO_TOKEN");
testMode = System.getenv("TEST_MODE");
+ eMailFrom = System.getenv("EMAIL_FROM");
+ eMailLogin = System.getenv("EMAIL_LOGIN");
+ eMailPassword = System.getenv("EMAIL_PASSWORD");
}
static {
@@ -120,4 +126,15 @@ public class ConfigBaseVariable {
}
return Boolean.parseBoolean(testMode);
}
+
+ public record EMailConfig(String from, String login, String password) {
+ };
+
+ public static EMailConfig getEMailConfig() {
+ if (eMailFrom == null || eMailLogin == null || eMailPassword == null) {
+ return null;
+ }
+ return new EMailConfig(eMailFrom, eMailLogin, eMailPassword);
+ }
+
}
diff --git a/tools/pre-commit b/tools/pre-commit
index 673506a..874e460 100755
--- a/tools/pre-commit
+++ b/tools/pre-commit
@@ -23,5 +23,5 @@ function __run() #(step, name, cmd)
fi
}
-__run "1/1" "Check JAVA code format" "mvn formatter:verify"
+__run "1/1" "Check JAVA code format" "mvn formatter:validate"