Fix CAS packages for 4.0.1 and Jasig references

Issue gh-11674
This commit is contained in:
hdeadman 2022-12-10 13:16:31 -05:00 committed by Marcus Da Coregio
parent b4d3ac6665
commit e0284a4503
30 changed files with 78 additions and 80 deletions

View File

@ -4,7 +4,7 @@ dependencies {
management platform(project(":spring-security-dependencies")) management platform(project(":spring-security-dependencies"))
api project(':spring-security-core') api project(':spring-security-core')
api project(':spring-security-web') api project(':spring-security-web')
api 'org.jasig.cas.client:cas-client-core' api 'org.apereo.cas.client:cas-client-core'
api 'org.springframework:spring-beans' api 'org.springframework:spring-beans'
api 'org.springframework:spring-context' api 'org.springframework:spring-context'
api 'org.springframework:spring-core' api 'org.springframework:spring-core'

View File

@ -18,7 +18,7 @@ package org.springframework.security.cas.authentication;
import java.util.ArrayList; import java.util.ArrayList;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.SpringSecurityCoreVersion; import org.springframework.security.core.SpringSecurityCoreVersion;

View File

@ -18,9 +18,9 @@ package org.springframework.security.cas.authentication;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.TicketValidationException; import org.apereo.cas.client.validation.TicketValidationException;
import org.jasig.cas.client.validation.TicketValidator; import org.apereo.cas.client.validation.TicketValidator;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;

View File

@ -19,7 +19,7 @@ package org.springframework.security.cas.authentication;
import java.io.Serializable; import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.springframework.security.authentication.AbstractAuthenticationToken; import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2016 the original author or authors. * Copyright 2015-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,11 +24,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.jasig.cas.client.authentication.AttributePrincipal; import org.apereo.cas.client.authentication.AttributePrincipal;
/** /**
* Helps in jackson deserialization of class * Helps in jackson deserialization of class
* {@link org.jasig.cas.client.validation.AssertionImpl}, which is used with * {@link org.apereo.cas.client.validation.AssertionImpl}, which is used with
* {@link org.springframework.security.cas.authentication.CasAuthenticationToken}. To use * {@link org.springframework.security.cas.authentication.CasAuthenticationToken}. To use
* this class we need to register with * this class we need to register with
* {@link com.fasterxml.jackson.databind.ObjectMapper}. Type information will be stored * {@link com.fasterxml.jackson.databind.ObjectMapper}. Type information will be stored
@ -52,7 +52,7 @@ class AssertionImplMixin {
/** /**
* Mixin Constructor helps in deserialize * Mixin Constructor helps in deserialize
* {@link org.jasig.cas.client.validation.AssertionImpl} * {@link org.apereo.cas.client.validation.AssertionImpl}
* @param principal the Principal to associate with the Assertion. * @param principal the Principal to associate with the Assertion.
* @param validFromDate when the assertion is valid from. * @param validFromDate when the assertion is valid from.
* @param validUntilDate when the assertion is valid to. * @param validUntilDate when the assertion is valid to.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2016 the original author or authors. * Copyright 2015-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,11 +23,11 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.jasig.cas.client.proxy.ProxyRetriever; import org.apereo.cas.client.proxy.ProxyRetriever;
/** /**
* Helps in deserialize {@link org.jasig.cas.client.authentication.AttributePrincipalImpl} * Helps in deserialize
* which is used with * {@link org.apereo.cas.client.authentication.AttributePrincipalImpl} which is used with
* {@link org.springframework.security.cas.authentication.CasAuthenticationToken}. Type * {@link org.springframework.security.cas.authentication.CasAuthenticationToken}. Type
* information will be stored in property named @class. * information will be stored in property named @class.
* <p> * <p>
@ -49,7 +49,7 @@ class AttributePrincipalImplMixin {
/** /**
* Mixin Constructor helps in deserialize * Mixin Constructor helps in deserialize
* {@link org.jasig.cas.client.authentication.AttributePrincipalImpl} * {@link org.apereo.cas.client.authentication.AttributePrincipalImpl}
* @param name the unique identifier for the principal. * @param name the unique identifier for the principal.
* @param attributes the key/value pairs for this principal. * @param attributes the key/value pairs for this principal.
* @param proxyGrantingTicket the ticket associated with this principal. * @param proxyGrantingTicket the ticket associated with this principal.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2016 the original author or authors. * Copyright 2015-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.springframework.security.cas.authentication.CasAuthenticationProvider; import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.authentication.CasAuthenticationToken; import org.springframework.security.cas.authentication.CasAuthenticationToken;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2016 the original author or authors. * Copyright 2015-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -18,8 +18,8 @@ package org.springframework.security.cas.jackson2;
import com.fasterxml.jackson.core.Version; import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.module.SimpleModule; import com.fasterxml.jackson.databind.module.SimpleModule;
import org.jasig.cas.client.authentication.AttributePrincipalImpl; import org.apereo.cas.client.authentication.AttributePrincipalImpl;
import org.jasig.cas.client.validation.AssertionImpl; import org.apereo.cas.client.validation.AssertionImpl;
import org.springframework.security.cas.authentication.CasAuthenticationToken; import org.springframework.security.cas.authentication.CasAuthenticationToken;
import org.springframework.security.jackson2.SecurityJackson2Modules; import org.springframework.security.jackson2.SecurityJackson2Modules;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -15,7 +15,7 @@
*/ */
/** /**
* Spring Security support for Jasig's Central Authentication Service * Spring Security support for Apereo's Central Authentication Service
* (<a href="https://www.jasig.org/cas">CAS</a>). * (<a href="https://github.com/apereo/cas">CAS</a>).
*/ */
package org.springframework.security.cas; package org.springframework.security.cas;

View File

@ -16,7 +16,7 @@
package org.springframework.security.cas.userdetails; package org.springframework.security.cas.userdetails;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken; import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService; import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;

View File

@ -19,7 +19,7 @@ package org.springframework.security.cas.userdetails;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority;

View File

@ -20,8 +20,7 @@ import java.io.IOException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apereo.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.CommonUtils;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.security.cas.ServiceProperties; import org.springframework.security.cas.ServiceProperties;

View File

@ -22,10 +22,9 @@ import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException; import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apereo.cas.client.proxy.ProxyGrantingTicketStorage;
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; import org.apereo.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.CommonUtils; import org.apereo.cas.client.validation.TicketValidator;
import org.jasig.cas.client.validation.TicketValidator;
import org.springframework.core.log.LogMessage; import org.springframework.core.log.LogMessage;
import org.springframework.security.authentication.AnonymousAuthenticationToken; import org.springframework.security.authentication.AnonymousAuthenticationToken;
@ -133,7 +132,7 @@ import org.springframework.util.Assert;
* NOTE: In a real application you should not use an in memory implementation. You will also want * NOTE: In a real application you should not use an in memory implementation. You will also want
* to ensure to clean up expired tickets by calling ProxyGrantingTicketStorage.cleanup() * to ensure to clean up expired tickets by calling ProxyGrantingTicketStorage.cleanup()
* --&gt; * --&gt;
* &lt;b:bean id=&quot;pgtStorage&quot; class=&quot;org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl&quot;/&gt; * &lt;b:bean id=&quot;pgtStorage&quot; class=&quot;org.apereo.cas.client.proxy.ProxyGrantingTicketStorageImpl&quot;/&gt;
* &lt;b:bean id=&quot;casAuthProvider&quot; class=&quot;org.springframework.security.cas.authentication.CasAuthenticationProvider&quot; * &lt;b:bean id=&quot;casAuthProvider&quot; class=&quot;org.springframework.security.cas.authentication.CasAuthenticationProvider&quot;
* p:serviceProperties-ref=&quot;serviceProperties&quot; * p:serviceProperties-ref=&quot;serviceProperties&quot;
* p:key=&quot;casAuthProviderKey&quot;&gt; * p:key=&quot;casAuthProviderKey&quot;&gt;
@ -145,7 +144,7 @@ import org.springframework.util.Assert;
* &lt;/b:property&gt; * &lt;/b:property&gt;
* &lt;b:property name=&quot;ticketValidator&quot;&gt; * &lt;b:property name=&quot;ticketValidator&quot;&gt;
* &lt;b:bean * &lt;b:bean
* class=&quot;org.jasig.cas.client.validation.Cas20ProxyTicketValidator&quot; * class=&quot;org.apereo.cas.client.validation.Cas20ProxyTicketValidator&quot;
* p:acceptAnyProxy=&quot;true&quot; * p:acceptAnyProxy=&quot;true&quot;
* p:proxyCallbackUrl=&quot;https://service.example.com/cas-sample/login/cas/proxyreceptor&quot; * p:proxyCallbackUrl=&quot;https://service.example.com/cas-sample/login/cas/proxyreceptor&quot;
* p:proxyGrantingTicketStorage-ref=&quot;pgtStorage&quot;&gt; * p:proxyGrantingTicketStorage-ref=&quot;pgtStorage&quot;&gt;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ package org.springframework.security.cas.authentication;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.AssertionImpl; import org.apereo.cas.client.validation.AssertionImpl;
import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.userdetails.User; import org.springframework.security.core.userdetails.User;

View File

@ -19,9 +19,9 @@ package org.springframework.security.cas.authentication;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.AssertionImpl; import org.apereo.cas.client.validation.AssertionImpl;
import org.jasig.cas.client.validation.TicketValidator; import org.apereo.cas.client.validation.TicketValidator;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;

View File

@ -19,8 +19,8 @@ package org.springframework.security.cas.authentication;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.AssertionImpl; import org.apereo.cas.client.validation.AssertionImpl;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2015-2016 the original author or authors. * Copyright 2015-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,9 +23,9 @@ import java.util.Date;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.jasig.cas.client.authentication.AttributePrincipalImpl; import org.apereo.cas.client.authentication.AttributePrincipalImpl;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.AssertionImpl; import org.apereo.cas.client.validation.AssertionImpl;
import org.json.JSONException; import org.json.JSONException;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -79,14 +79,15 @@ public class CasAuthenticationTokenMixinTests {
+ "\"keyHash\": " + KEY.hashCode() + "," + "\"principal\": " + USER_JSON + ", " + "\"credentials\": " + "\"keyHash\": " + KEY.hashCode() + "," + "\"principal\": " + USER_JSON + ", " + "\"credentials\": "
+ PASSWORD + ", " + "\"authorities\": " + AUTHORITIES_ARRAYLIST_JSON + "," + "\"userDetails\": " + USER_JSON + PASSWORD + ", " + "\"authorities\": " + AUTHORITIES_ARRAYLIST_JSON + "," + "\"userDetails\": " + USER_JSON
+ "," + "\"authenticated\": true, " + "\"details\": null," + "\"assertion\": {" + "," + "\"authenticated\": true, " + "\"details\": null," + "\"assertion\": {"
+ "\"@class\": \"org.jasig.cas.client.validation.AssertionImpl\", " + "\"principal\": {" + "\"@class\": \"org.apereo.cas.client.validation.AssertionImpl\", " + "\"principal\": {"
+ "\"@class\": \"org.jasig.cas.client.authentication.AttributePrincipalImpl\", " + "\"@class\": \"org.apereo.cas.client.authentication.AttributePrincipalImpl\", "
+ "\"name\": \"assertName\", " + "\"attributes\": {\"@class\": \"java.util.Collections$EmptyMap\"}, " + "\"name\": \"assertName\", " + "\"attributes\": {\"@class\": \"java.util.Collections$EmptyMap\"}, "
+ "\"proxyGrantingTicket\": null, " + "\"proxyRetriever\": null" + "}, " + "\"proxyGrantingTicket\": null, " + "\"proxyRetriever\": null" + "}, "
+ "\"validFromDate\": [\"java.util.Date\", " + START_DATE.getTime() + "], " + "\"validFromDate\": [\"java.util.Date\", " + START_DATE.getTime() + "], "
+ "\"validUntilDate\": [\"java.util.Date\", " + END_DATE.getTime() + "]," + "\"validUntilDate\": [\"java.util.Date\", " + END_DATE.getTime() + "],"
+ "\"authenticationDate\": [\"java.util.Date\", " + START_DATE.getTime() + "], " + "\"authenticationDate\": [\"java.util.Date\", " + START_DATE.getTime() + "], "
+ "\"attributes\": {\"@class\": \"java.util.Collections$EmptyMap\"}" + "}" + "}"; + "\"attributes\": {\"@class\": \"java.util.Collections$EmptyMap\"},"
+ "\"context\": {\"@class\":\"java.util.HashMap\"}" + "}" + "}";
private static final String CAS_TOKEN_CLEARED_JSON = CAS_TOKEN_JSON.replaceFirst(PASSWORD, "null"); private static final String CAS_TOKEN_CLEARED_JSON = CAS_TOKEN_JSON.replaceFirst(PASSWORD, "null");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +21,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.jasig.cas.client.authentication.AttributePrincipal; import org.apereo.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion; import org.apereo.cas.client.validation.Assertion;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken; import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;

View File

@ -17,8 +17,7 @@
package org.springframework.security.cas.web; package org.springframework.security.cas.web;
import jakarta.servlet.FilterChain; import jakarta.servlet.FilterChain;
import org.apereo.cas.client.proxy.ProxyGrantingTicketStorage;
import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -41,8 +40,8 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given; import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verifyZeroInteractions;
/** /**
* Tests {@link CasAuthenticationFilter}. * Tests {@link CasAuthenticationFilter}.
@ -173,7 +172,7 @@ public class CasAuthenticationFilterTests {
assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull() assertThat(SecurityContextHolder.getContext().getAuthentication()).isNotNull()
.withFailMessage("Authentication should not be null"); .withFailMessage("Authentication should not be null");
verify(chain).doFilter(request, response); verify(chain).doFilter(request, response);
verifyZeroInteractions(successHandler); verifyNoInteractions(successHandler);
// validate for when the filterProcessUrl matches // validate for when the filterProcessUrl matches
filter.setFilterProcessesUrl(request.getServletPath()); filter.setFilterProcessesUrl(request.getServletPath());
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
@ -193,7 +192,7 @@ public class CasAuthenticationFilterTests {
filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class)); filter.setProxyGrantingTicketStorage(mock(ProxyGrantingTicketStorage.class));
filter.setProxyReceptorUrl(request.getServletPath()); filter.setProxyReceptorUrl(request.getServletPath());
filter.doFilter(request, response, chain); filter.doFilter(request, response, chain);
verifyZeroInteractions(chain); verifyNoInteractions(chain);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2011-2016 the original author or authors. * Copyright 2011-2023 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -32,7 +32,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.security.cas.web.CasAuthenticationFilter; import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.test.SpringTestContext; import org.springframework.security.config.test.SpringTestContext;
import org.springframework.security.config.test.SpringTestContextExtension; import org.springframework.security.config.test.SpringTestContextExtension;
@ -125,18 +124,19 @@ public class HttpConfigurationTests {
} }
@EnableWebSecurity @EnableWebSecurity
static class CasAuthenticationFilterConfig extends WebSecurityConfigurerAdapter { static class CasAuthenticationFilterConfig {
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER; @Bean
SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
@Override
protected void configure(HttpSecurity http) {
// @formatter:off // @formatter:off
http http
.addFilter(CAS_AUTHENTICATION_FILTER); .addFilter(CAS_AUTHENTICATION_FILTER);
// @formatter:on // @formatter:on
return http.build();
} }
static CasAuthenticationFilter CAS_AUTHENTICATION_FILTER;
} }
@Configuration @Configuration

View File

@ -57,7 +57,7 @@ dependencies {
api "org.hamcrest:hamcrest:2.2" api "org.hamcrest:hamcrest:2.2"
api "org.hibernate.orm:hibernate-core:6.1.5.Final" api "org.hibernate.orm:hibernate-core:6.1.5.Final"
api "org.hsqldb:hsqldb:2.7.1" api "org.hsqldb:hsqldb:2.7.1"
api "org.jasig.cas.client:cas-client-core:3.6.4" api "org.apereo.cas.client:cas-client-core:4.0.1"
api "org.opensaml:opensaml-core:$openSamlVersion" api "org.opensaml:opensaml-core:$openSamlVersion"
api "org.opensaml:opensaml-saml-api:$openSamlVersion" api "org.opensaml:opensaml-saml-api:$openSamlVersion"
api "org.opensaml:opensaml-saml-impl:$openSamlVersion" api "org.opensaml:opensaml-saml-impl:$openSamlVersion"

View File

@ -163,7 +163,7 @@ Next you need to add a `CasAuthenticationProvider` and its collaborators:
</property> </property>
<property name="serviceProperties" ref="serviceProperties" /> <property name="serviceProperties" ref="serviceProperties" />
<property name="ticketValidator"> <property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator"> <bean class="org.apereo.cas.client.validation.Cas20ServiceTicketValidator">
<constructor-arg index="0" value="https://localhost:9443/cas" /> <constructor-arg index="0" value="https://localhost:9443/cas" />
</bean> </bean>
</property> </property>
@ -208,7 +208,7 @@ Below are updates to the Spring Security configuration that handle Single Logout
</security:http> </security:http>
<!-- This filter handles a Single Logout Request from the CAS Server --> <!-- This filter handles a Single Logout Request from the CAS Server -->
<bean id="singleLogoutFilter" class="org.jasig.cas.client.session.SingleSignOutFilter"/> <bean id="singleLogoutFilter" class="org.apereo.cas.client.session.SingleSignOutFilter"/>
<!-- This filter redirects to the CAS Server to signal Single Logout should be performed --> <!-- This filter redirects to the CAS Server to signal Single Logout should be performed -->
<bean id="requestSingleLogoutFilter" <bean id="requestSingleLogoutFilter"
@ -235,7 +235,7 @@ With the configuration above, the flow of logout would be:
* The logout success page, `/cas-logout.jsp`, should instruct the user to click a link pointing to `/logout/cas` in order to logout out of all applications. * The logout success page, `/cas-logout.jsp`, should instruct the user to click a link pointing to `/logout/cas` in order to logout out of all applications.
* When the user clicks the link, the user is redirected to the CAS single logout URL (https://localhost:9443/cas/logout). * When the user clicks the link, the user is redirected to the CAS single logout URL (https://localhost:9443/cas/logout).
* On the CAS Server side, the CAS single logout URL then submits single logout requests to all the CAS Services. * On the CAS Server side, the CAS single logout URL then submits single logout requests to all the CAS Services.
On the CAS Service side, JASIG's `SingleSignOutFilter` processes the logout request by invalidating the original session. On the CAS Service side, Apereo's `SingleSignOutFilter` processes the logout request by invalidating the original session.
@ -259,14 +259,14 @@ The next step is to add the following to your web.xml
</filter-mapping> </filter-mapping>
<listener> <listener>
<listener-class> <listener-class>
org.jasig.cas.client.session.SingleSignOutHttpSessionListener org.apereo.cas.client.session.SingleSignOutHttpSessionListener
</listener-class> </listener-class>
</listener> </listener>
---- ----
When using the SingleSignOutFilter you might encounter some encoding issues. When using the SingleSignOutFilter you might encounter some encoding issues.
Therefore it is recommended to add the `CharacterEncodingFilter` to ensure that the character encoding is correct when using the `SingleSignOutFilter`. Therefore it is recommended to add the `CharacterEncodingFilter` to ensure that the character encoding is correct when using the `SingleSignOutFilter`.
Again, refer to JASIG's documentation for details. Again, refer to Apereo CAS's documentation for details.
The `SingleSignOutHttpSessionListener` ensures that when an `HttpSession` expires, the mapping used for single logout is removed. The `SingleSignOutHttpSessionListener` ensures that when an `HttpSession` expires, the mapping used for single logout is removed.
@ -293,7 +293,7 @@ NOTE: In a real application you should not use an in memory implementation.
You will also want to ensure to clean up expired tickets by calling You will also want to ensure to clean up expired tickets by calling
ProxyGrantingTicketStorage.cleanup() ProxyGrantingTicketStorage.cleanup()
--> -->
<bean id="pgtStorage" class="org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl"/> <bean id="pgtStorage" class="org.apereo.cas.client.proxy.ProxyGrantingTicketStorageImpl"/>
---- ----
The next step is to update the `CasAuthenticationProvider` to be able to obtain proxy tickets. The next step is to update the `CasAuthenticationProvider` to be able to obtain proxy tickets.
@ -308,7 +308,7 @@ You can find an example of the configuration changes that should be made below.
class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
... ...
<property name="ticketValidator"> <property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"> <bean class="org.apereo.cas.client.validation.Cas20ProxyTicketValidator">
<constructor-arg value="https://localhost:9443/cas"/> <constructor-arg value="https://localhost:9443/cas"/>
<property name="proxyCallbackUrl" <property name="proxyCallbackUrl"
value="https://localhost:8443/cas-sample/login/cas/proxyreceptor"/> value="https://localhost:8443/cas-sample/login/cas/proxyreceptor"/>
@ -439,7 +439,7 @@ You can find an example of the updates required to accept all proxies below.
class="org.springframework.security.cas.authentication.CasAuthenticationProvider"> class="org.springframework.security.cas.authentication.CasAuthenticationProvider">
... ...
<property name="ticketValidator"> <property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ProxyTicketValidator"> <bean class="org.apereo.cas.client.validation.Cas20ProxyTicketValidator">
<constructor-arg value="https://localhost:9443/cas"/> <constructor-arg value="https://localhost:9443/cas"/>
<property name="acceptAnyProxy" value="true"/> <property name="acceptAnyProxy" value="true"/>
</bean> </bean>