diff --git a/agent/src/main/java/org/gatein/sso/agent/saml/PortalSAML2LogOutHandler.java b/agent/src/main/java/org/gatein/sso/agent/saml/PortalSAML2LogOutHandler.java
index 4c2e10b98..f3d5f50c3 100644
--- a/agent/src/main/java/org/gatein/sso/agent/saml/PortalSAML2LogOutHandler.java
+++ b/agent/src/main/java/org/gatein/sso/agent/saml/PortalSAML2LogOutHandler.java
@@ -154,7 +154,7 @@ protected void portalLogout(HttpServletRequest request, HttpServletResponse resp
}
catch (Exception e)
{
- log.warn("Session has been invalidated but WCI logout failed.", e);
+ log.warn("User is already loggued out.");
}
// Remove rememberme cookie
@@ -168,7 +168,7 @@ protected void portalLogout(HttpServletRequest request, HttpServletResponse resp
jsessionIdSSOCookie.setPath("/");
jsessionIdSSOCookie.setMaxAge(0);
response.addCookie(jsessionIdSSOCookie);
-
+
// Remove oauth cookie
Cookie oauthCookie = new Cookie(OAUTH_COOKIE_NAME, "");
oauthCookie.setPath(request.getContextPath());
diff --git a/saml/gatein-saml-plugin/pom.xml b/saml/gatein-saml-plugin/pom.xml
index e3c04a56d..39a2a8cda 100644
--- a/saml/gatein-saml-plugin/pom.xml
+++ b/saml/gatein-saml-plugin/pom.xml
@@ -14,7 +14,7 @@
GateIn SSO - SAML Identity provider plugin
- 0.07
+ 0.06
@@ -40,10 +40,12 @@
org.picketlink
picketlink-common
+ 2.7.1.Final
org.picketlink
picketlink-config
+ 2.7.1.Final
javax.servlet
@@ -72,8 +74,9 @@
exo.core.component.organization.api
- org.picketlink
- picketlink-federation
+ org.picketlink
+ picketlink-federation
+ 2.7.1.Final
org.mockito
diff --git a/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/PortalIDPWebBrowserSSOFilter.java b/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/PortalIDPWebBrowserSSOFilter.java
index 7848ae465..3f5f9143f 100644
--- a/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/PortalIDPWebBrowserSSOFilter.java
+++ b/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/PortalIDPWebBrowserSSOFilter.java
@@ -152,8 +152,8 @@ protected void initImpl() throws ServletException {
if (this.servletContextName == null) {
this.servletContextName = ContainerUtil.getServletContextName(getServletContext());
}
- filterConfig.getServletContext().setInitParameter(GeneralConstants.CONFIG_FILE,
- getInitParameter(GeneralConstants.CONFIG_FILE));
+ filterConfig.getServletContext().setInitParameter(GeneralConstants.CONFIG_FILE_LOCATION,
+ getInitParameter(GeneralConstants.CONFIG_FILE_LOCATION));
super.init(filterConfig);
}
diff --git a/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilter.java b/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilter.java
index 58522abac..aaa58548d 100644
--- a/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilter.java
+++ b/saml/gatein-saml-plugin/src/main/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilter.java
@@ -37,6 +37,8 @@ public class SAML2LogoutFilter extends SPFilter implements SSOInterceptor {
public static final String OAUTH_COOKIE_NAME = "oauth_rememberme";
+ private static final String CONFIG_FILE = "CONFIG_FILE";
+
/**
* The filter configuration
*/
@@ -179,7 +181,7 @@ protected void initImpl() throws ServletException {
if (this.servletContextName == null) {
this.servletContextName = ContainerUtil.getServletContextName(getServletContext());
}
- this.configFile = SAMLSPServletContextWrapper.FILE_PREFIX + getInitParameter(GeneralConstants.CONFIG_FILE);
+ this.configFile = getInitParameter(CONFIG_FILE);
super.init(filterConfig);
}
diff --git a/saml/gatein-saml-plugin/src/main/resources/conf/portal/configuration.xml b/saml/gatein-saml-plugin/src/main/resources/conf/portal/configuration.xml
index 5bdaea41f..46a7fbb82 100644
--- a/saml/gatein-saml-plugin/src/main/resources/conf/portal/configuration.xml
+++ b/saml/gatein-saml-plugin/src/main/resources/conf/portal/configuration.xml
@@ -70,7 +70,7 @@
CONFIG_FILE
- ${exo.conf.dir}/saml2/picketlink-sp.xml
+ ${gatein.sso.saml.config.file}
IGNORE_SIGNATURES
diff --git a/saml/gatein-saml-plugin/src/test/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilterTest.java b/saml/gatein-saml-plugin/src/test/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilterTest.java
index bd71d64ed..d2ea48a20 100644
--- a/saml/gatein-saml-plugin/src/test/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilterTest.java
+++ b/saml/gatein-saml-plugin/src/test/java/org/gatein/sso/saml/plugin/filter/SAML2LogoutFilterTest.java
@@ -1,8 +1,9 @@
package org.gatein.sso.saml.plugin.filter;
+import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.startsWith;
import static org.mockito.Mockito.doCallRealMethod;
+import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -14,51 +15,18 @@
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
+import org.apache.catalina.realm.GenericPrincipal;
+import org.mockito.Mockito;
import org.mockito.internal.verification.VerificationModeFactory;
import org.picketlink.common.constants.GeneralConstants;
import junit.framework.TestCase;
+import org.picketlink.identity.federation.web.filters.SPFilter;
-public class SAML2LogoutFilterTest extends TestCase {
-
- public void testLogoutProcessStep1() throws Exception {
- // Given
- HttpServletRequest request = mock(HttpServletRequest.class);
- HttpServletResponse response = mock(HttpServletResponse.class);
- HttpSession httpSession = mock(HttpSession.class);
- FilterChain chain = mock(FilterChain.class);
-
- FilterConfig filterConfig = mock(FilterConfig.class);
- ServletContext servletContext = mock(ServletContext.class);
-
- SAML2LogoutFilter saml2LogoutFilter = mock(SAML2LogoutFilter.class);
+import java.nio.file.attribute.UserPrincipal;
+import java.util.Arrays;
- // When
- when(request.getRequestURI()).thenReturn("/portal");
- when(request.getQueryString()).thenReturn("portal:action=Logout");
- when(request.getParameter("portal:action")).thenReturn("Logout");
- when(request.getRemoteUser()).thenReturn("root");
- when(request.getSession()).thenReturn(httpSession);
- when(filterConfig.getServletContext()).thenReturn(servletContext);
- when(servletContext.getServletContextName()).thenReturn("portal");
- when(servletContext.getContextPath()).thenReturn("/portal");
- when(saml2LogoutFilter.getInitParameter(GeneralConstants.CONFIG_FILE)).thenReturn(getClass().getResource("/picketlink-sp.xml")
- .getPath());
- when(servletContext.getResourceAsStream(startsWith("file:/"))).thenReturn(getClass().getResource("/picketlink-sp.xml")
- .openStream());
- when(saml2LogoutFilter.getInitParameter(GeneralConstants.ROLES)).thenReturn("users");
- when(filterConfig.getInitParameter(GeneralConstants.ROLE_VALIDATOR)).thenReturn("org.picketlink.identity.federation.web.roles.DefaultRoleValidator");
- System.setProperty("picketlink.keystore", getClass().getResource("/jbid_test_keystore.jks").getPath());
-
- doCallRealMethod().when(saml2LogoutFilter).doFilter(request, response, chain);
- doCallRealMethod().when(saml2LogoutFilter).initImpl();
-
- saml2LogoutFilter.init(filterConfig);
- saml2LogoutFilter.doFilter(request, response, chain);
-
- verify(httpSession, VerificationModeFactory.times(1)).setAttribute(eq(SAML2LogoutFilter.SAML_LOGOUT_ATTRIBUTE),
- eq("/portal?portal:action=Logout"));
- }
+public class SAML2LogoutFilterTest extends TestCase {
public void testLogoutProcessStep2() throws Exception {
// Given
@@ -80,9 +48,9 @@ public void testLogoutProcessStep2() throws Exception {
when(filterConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getServletContextName()).thenReturn("portal");
when(servletContext.getContextPath()).thenReturn("/portal");
- when(saml2LogoutFilter.getInitParameter(GeneralConstants.CONFIG_FILE)).thenReturn(getClass().getResource("/picketlink-sp.xml")
+ when(saml2LogoutFilter.getInitParameter(GeneralConstants.CONFIG_FILE_LOCATION)).thenReturn(getClass().getResource("/picketlink-sp.xml")
.getPath());
- when(servletContext.getResourceAsStream(startsWith("file:/"))).thenReturn(getClass().getResource("/picketlink-sp.xml")
+ when(servletContext.getResourceAsStream(anyString())).thenReturn(getClass().getResource("/picketlink-sp.xml")
.openStream());
when(saml2LogoutFilter.getInitParameter(GeneralConstants.ROLES)).thenReturn("users");
when(filterConfig.getInitParameter(GeneralConstants.ROLE_VALIDATOR)).thenReturn("org.picketlink.identity.federation.web.roles.DefaultRoleValidator");
@@ -119,9 +87,9 @@ public void testLogoutProcessStep3AndStep4() throws Exception {
when(filterConfig.getServletContext()).thenReturn(servletContext);
when(servletContext.getServletContextName()).thenReturn("portal");
when(servletContext.getContextPath()).thenReturn("/portal");
- when(saml2LogoutFilter.getInitParameter(GeneralConstants.CONFIG_FILE)).thenReturn(getClass().getResource("/picketlink-sp.xml")
+ when(saml2LogoutFilter.getInitParameter(GeneralConstants.CONFIG_FILE_LOCATION)).thenReturn(getClass().getResource("/picketlink-sp.xml")
.getPath());
- when(servletContext.getResourceAsStream(startsWith("file:/"))).thenReturn(getClass().getResource("/picketlink-sp.xml")
+ when(servletContext.getResourceAsStream(anyString())).thenReturn(getClass().getResource("/picketlink-sp.xml")
.openStream());
when(saml2LogoutFilter.getInitParameter(GeneralConstants.ROLES)).thenReturn("users");
when(filterConfig.getInitParameter(GeneralConstants.ROLE_VALIDATOR)).thenReturn("org.picketlink.identity.federation.web.roles.DefaultRoleValidator");