You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2020/03/30 08:31:04 UTC
[syncope] 02/02: Initial steps to enable Payara Server 5
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
commit 7ebd2c66687329765507f51b4c19a352790cee18
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Tue Mar 24 10:29:39 2020 +0100
Initial steps to enable Payara Server 5
---
.../core/spring/security/JWTAuthenticationFilter.java | 15 +++++----------
.../syncope/core/spring/security/WebSecurityContext.java | 4 +---
fit/build-tools/pom.xml | 3 ++-
.../webapp/WEB-INF/{glassfish-web.xml => payara-web.xml} | 8 ++++----
fit/core-reference/pom.xml | 6 ++++++
.../webapp/WEB-INF/{glassfish-web.xml => payara-web.xml} | 10 +++++-----
pom.xml | 2 +-
7 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/core/spring/src/main/java/org/apache/syncope/core/spring/security/JWTAuthenticationFilter.java b/core/spring/src/main/java/org/apache/syncope/core/spring/security/JWTAuthenticationFilter.java
index ebe09fa..e82f294 100644
--- a/core/spring/src/main/java/org/apache/syncope/core/spring/security/JWTAuthenticationFilter.java
+++ b/core/spring/src/main/java/org/apache/syncope/core/spring/security/JWTAuthenticationFilter.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.spring.security;
import java.io.IOException;
import java.util.Optional;
-
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -33,25 +32,22 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.core.Authentication;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.AuthenticationEntryPoint;
-import org.springframework.web.filter.OncePerRequestFilter;
+import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
/**
* Processes the JSON Web Token provided as {@link HttpHeaders#AUTHORIZATION} HTTP header, putting the result into the
* {@link SecurityContextHolder}.
*/
-public class JWTAuthenticationFilter extends OncePerRequestFilter {
+public class JWTAuthenticationFilter extends BasicAuthenticationFilter {
private static final Logger LOG = LoggerFactory.getLogger(JWTAuthenticationFilter.class);
@Autowired
private AuthenticationEntryPoint authenticationEntryPoint;
- private AuthenticationManager authenticationManager;
-
@Autowired
private SyncopeAuthenticationDetailsSource authenticationDetailsSource;
@@ -61,8 +57,8 @@ public class JWTAuthenticationFilter extends OncePerRequestFilter {
@Autowired
private DefaultCredentialChecker credentialChecker;
- public void setAuthenticationManager(final AuthenticationManager authenticationManager) {
- this.authenticationManager = authenticationManager;
+ public JWTAuthenticationFilter(final AuthenticationManager authenticationManager) {
+ super(authenticationManager);
}
@Override
@@ -91,9 +87,8 @@ public class JWTAuthenticationFilter extends OncePerRequestFilter {
throw new BadCredentialsException("Invalid signature found in JWT");
}
- Authentication authentication = authenticationManager.authenticate(
+ SecurityContextHolder.getContext().setAuthentication(
new JWTAuthentication(consumer.getJwtClaims(), authenticationDetailsSource.buildDetails(request)));
- SecurityContextHolder.getContext().setAuthentication(authentication);
chain.doFilter(request, response);
} catch (JwsException e) {
diff --git a/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java b/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
index 0778d0e..05dfc94 100644
--- a/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
+++ b/core/spring/src/main/java/org/apache/syncope/core/spring/security/WebSecurityContext.java
@@ -110,9 +110,7 @@ public class WebSecurityContext extends WebSecurityConfigurerAdapter {
@Bean
public JWTAuthenticationFilter jwtAuthenticationFilter() throws Exception {
- JWTAuthenticationFilter jwtAuthenticationFilter = new JWTAuthenticationFilter();
- jwtAuthenticationFilter.setAuthenticationManager(authenticationManager());
- return jwtAuthenticationFilter;
+ return new JWTAuthenticationFilter(authenticationManager());
}
@Bean
diff --git a/fit/build-tools/pom.xml b/fit/build-tools/pom.xml
index 86a9726..fe10e45 100644
--- a/fit/build-tools/pom.xml
+++ b/fit/build-tools/pom.xml
@@ -363,7 +363,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.glassfish</groupId>
- <artifactId>javax.faces</artifactId>
+ <artifactId>jakarta.faces</artifactId>
<version>${javax.faces.version}</version>
</dependency>
@@ -401,6 +401,7 @@ under the License.
</container>
<configuration>
<properties>
+ <cargo.glassfish.removeDefaultDatasource>false</cargo.glassfish.removeDefaultDatasource>
<cargo.jvmargs>-Xdebug -Djaxb.debug=true -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
-XX:+CMSClassUnloadingEnabled</cargo.jvmargs>
</properties>
diff --git a/fit/build-tools/src/main/webapp/WEB-INF/glassfish-web.xml b/fit/build-tools/src/main/webapp/WEB-INF/payara-web.xml
similarity index 79%
rename from fit/build-tools/src/main/webapp/WEB-INF/glassfish-web.xml
rename to fit/build-tools/src/main/webapp/WEB-INF/payara-web.xml
index 31212ca..01ee064 100644
--- a/fit/build-tools/src/main/webapp/WEB-INF/glassfish-web.xml
+++ b/fit/build-tools/src/main/webapp/WEB-INF/payara-web.xml
@@ -17,12 +17,12 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD
-GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
-<glassfish-web-app>
+<!DOCTYPE payara-web-app PUBLIC "-//Payara.fish//DTD Payara Server 4 Servlet 3.0//EN" "https://docs.payara.fish/schemas/payara-web-app_4.dtd">
+<payara-web-app error-url="">
<context-root>/syncope-fit-build-tools</context-root>
<class-loader delegate="false"/>
+ <jaxrs-roles-allowed-enabled>false</jaxrs-roles-allowed-enabled>
<jsp-config>
<property name="httpMethods" value="GET,POST,HEAD,PUT,DELETE"/>
</jsp-config>
-</glassfish-web-app>
+</payara-web-app>
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index a0d338f..4b477c9 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -1489,6 +1489,12 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>jakarta.faces</artifactId>
+ <version>${javax.faces.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
diff --git a/fit/core-reference/src/main/webapp/WEB-INF/glassfish-web.xml b/fit/core-reference/src/main/webapp/WEB-INF/payara-web.xml
similarity index 79%
rename from fit/core-reference/src/main/webapp/WEB-INF/glassfish-web.xml
rename to fit/core-reference/src/main/webapp/WEB-INF/payara-web.xml
index 2eea12b..a32bda0 100644
--- a/fit/core-reference/src/main/webapp/WEB-INF/glassfish-web.xml
+++ b/fit/core-reference/src/main/webapp/WEB-INF/payara-web.xml
@@ -17,10 +17,8 @@ KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
-<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD
-GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
-<glassfish-web-app>
- <context-root>/syncope</context-root>
+<!DOCTYPE payara-web-app PUBLIC "-//Payara.fish//DTD Payara Server 4 Servlet 3.0//EN" "https://docs.payara.fish/schemas/payara-web-app_4.dtd">
+<payara-web-app error-url="">
<!-- Uncomment this when using JNDI DataSource -->
<!--<resource-ref>
<res-ref-name>jdbc/syncopeMasterDataSource</res-ref-name>
@@ -28,7 +26,9 @@ GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/gla
</resource-ref>-->
<class-loader delegate="false"/>
<scanning-exclude>*</scanning-exclude>
+ <scanning-exclude>*</scanning-exclude>
+ <jaxrs-roles-allowed-enabled>false</jaxrs-roles-allowed-enabled>
<jsp-config>
<property name="httpMethods" value="GET,POST,HEAD,PUT,DELETE"/>
</jsp-config>
-</glassfish-web-app>
+</payara-web-app>
diff --git a/pom.xml b/pom.xml
index 071cc99..1e2b71a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -516,7 +516,7 @@ under the License.
<tomcat.version>9.0.33</tomcat.version>
<wildfly.version>19.0.0.Final</wildfly.version>
<payara.version>5.201</payara.version>
- <javax.faces.version>2.4.0</javax.faces.version>
+ <javax.faces.version>2.3.14</javax.faces.version>
<docker.postgresql.version>12</docker.postgresql.version>
<docker.mysql.version>8.0.19</docker.mysql.version>