Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to pl 2.7.1.Final, to be able to sign logout assertion request #48

Draft
wants to merge 1 commit into
base: stable/6.5.x-exo
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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());
Expand Down
9 changes: 6 additions & 3 deletions saml/gatein-saml-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<name>GateIn SSO - SAML Identity provider plugin</name>

<properties>
<exo.test.coverage.ratio>0.07</exo.test.coverage.ratio>
<exo.test.coverage.ratio>0.06</exo.test.coverage.ratio>
</properties>

<dependencies>
Expand All @@ -40,10 +40,12 @@
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-common</artifactId>
<version>2.7.1.Final</version>
</dependency>
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-config</artifactId>
<version>2.7.1.Final</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
Expand Down Expand Up @@ -72,8 +74,9 @@
<artifactId>exo.core.component.organization.api</artifactId>
</dependency>
<dependency>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-federation</artifactId>
<groupId>org.picketlink</groupId>
<artifactId>picketlink-federation</artifactId>
<version>2.7.1.Final</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</value-param>
<value-param>
<name>CONFIG_FILE</name>
<value>${exo.conf.dir}/saml2/picketlink-sp.xml</value>
<value>${gatein.sso.saml.config.file}</value>
</value-param>
<value-param>
<name>IGNORE_SIGNATURES</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand All @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Loading