Skip to content

Commit

Permalink
Rename current spring-security-context to spring-security-v5-context.
Browse files Browse the repository at this point in the history
Signed-off-by: Sjoerd Talsma <[email protected]>
  • Loading branch information
sjoerdtalsma committed Dec 8, 2023
1 parent 4148dc3 commit 6666f51
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .mvn/javadoc/package-list
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ nl.talsmasoftware.context.slf4j.mdc
nl.talsmasoftware.context.log4j2.threadcontext
nl.talsmasoftware.context.opentracing
nl.talsmasoftware.context.servletrequest
nl.talsmasoftware.context.springsecurity
nl.talsmasoftware.context.springsecurity.v5
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<module>log4j2-propagation</module>
<module>servletrequest-propagation</module>
<module>slf4j-propagation</module>
<module>spring-security-context</module>
<module>spring-security-v5-context</module>
<module>opentracing-span-propagation</module>
</modules>

Expand Down Expand Up @@ -89,7 +89,7 @@

<metrics.version>4.2.23</metrics.version>
<opentracing-api.version>0.33.0</opentracing-api.version>
<spring-security.version>5.7.3</spring-security.version>
<spring-security-v5.version>5.7.3</spring-security-v5.version>
<servlet-api.version>4.0.1</servlet-api.version>
<slf4j.version>2.0.9</slf4j.version>
<log4j2.version>2.22.0</log4j2.version>
Expand Down Expand Up @@ -225,8 +225,8 @@
<location>${root.basedir}/.mvn/javadoc/opentracing-util</location>
</offlineLink>
<offlineLink>
<url>https://javadoc.io/page/org.springframework.security/spring-security-core/${spring-security.version}</url>
<location>${root.basedir}/.mvn/javadoc/spring-security-core</location>
<url>https://javadoc.io/page/org.springframework.security/spring-security-core/${spring-security-v5.version}</url>
<location>${root.basedir}/.mvn/javadoc/spring-security-v5-core</location>
</offlineLink>
<offlineLink>
<url>https://javadoc.io/page/javax.servlet/javax.servlet-api/${servlet-api.version}</url>
Expand Down

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2016-2022 Talsma ICT
Copyright 2016-2023 Talsma ICT
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -26,15 +26,16 @@
</parent>

<!-- Artifact identification -->
<artifactId>spring-security-context</artifactId>
<name>Propagation of Spring Security Context</name>
<artifactId>spring-security-v5-context</artifactId>
<name>Propagation of Spring Security (v5) Context</name>
<packaging>jar</packaging>

<properties>
<project.moduleName>${project.groupId}.springsecurity</project.moduleName>
<root.basedir>${project.parent.basedir}</root.basedir>
<maven.compiler.source>1.5</maven.compiler.source>
<maven.compiler.target>1.5</maven.compiler.target>

<!-- Suppress java version deprecation warnings -->
<project.compiler.argument>-Xlint:-options</project.compiler.argument>
</properties>
Expand All @@ -48,7 +49,7 @@
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${spring-security.version}</version>
<version>${spring-security-v5.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.talsmasoftware.context.springsecurity;
package nl.talsmasoftware.context.springsecurity.v5;

import nl.talsmasoftware.context.Context;
import nl.talsmasoftware.context.ContextManagers;
Expand All @@ -33,7 +33,7 @@
*
* @author Sjoerd Talsma
*/
public class SpringSecurityContextManager implements ClearableContextManager<Authentication> {
public class SpringSecurity5ContextManager implements ClearableContextManager<Authentication> {

/**
* Creates a new Spring {@linkplain SecurityContext} and sets the {@linkplain Authentication value} in it.
Expand Down Expand Up @@ -76,7 +76,7 @@ private AuthenticationContext(SecurityContext current, SecurityContext previous,
this.current = current;
this.previous = previous;
this.closed = new AtomicBoolean(alreadyClosed);
ContextManagers.onActivate(SpringSecurityContextManager.class, auth(current), auth(previous));
ContextManagers.onActivate(SpringSecurity5ContextManager.class, auth(current), auth(previous));
}

public Authentication getValue() {
Expand All @@ -86,7 +86,7 @@ public Authentication getValue() {
public void close() {
if (closed.compareAndSet(false, true)) {
SecurityContextHolder.setContext(previous);
ContextManagers.onDeactivate(SpringSecurityContextManager.class, auth(current), auth(previous));
ContextManagers.onDeactivate(SpringSecurity5ContextManager.class, auth(current), auth(previous));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nl.talsmasoftware.context.springsecurity.v5.SpringSecurity5ContextManager
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.talsmasoftware.context.springsecurity;
package nl.talsmasoftware.context.springsecurity.v5;

import nl.talsmasoftware.context.Context;
import nl.talsmasoftware.context.ContextManagers;
Expand All @@ -39,11 +39,11 @@
import static org.hamcrest.Matchers.nullValue;

/**
* Unit test for the {@link SpringSecurityContextManager}.
* Unit test for the {@link SpringSecurity5ContextManager}.
*
* @author Sjoerd Talsma
*/
public class SpringSecurityContextManagerTest {
public class SpringSecurity5ContextManagerTest {

ExecutorService threadpool;

Expand Down Expand Up @@ -79,7 +79,7 @@ private static void setAuthentication(String name) {

@Test
public void testWithoutAnyAuthentication() {
assertThat(new SpringSecurityContextManager().getActiveContext().getValue(), is(nullValue()));
assertThat(new SpringSecurity5ContextManager().getActiveContext().getValue(), is(nullValue()));
}

@Test
Expand Down Expand Up @@ -115,19 +115,19 @@ public void testAuthenticationReactivation() throws Exception {
@Test
public void testClosingCurrentAuthenticationContext() {
setAuthentication("Vincent Vega");
assertThat(new SpringSecurityContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));
assertThat(new SpringSecurity5ContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));

new SpringSecurityContextManager().getActiveContext().close(); // Not ours to manage!
assertThat(new SpringSecurityContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));
new SpringSecurity5ContextManager().getActiveContext().close(); // Not ours to manage!
assertThat(new SpringSecurity5ContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));
}

@Test
public void testClearableImplementation() {
setAuthentication("Vincent Vega");
assertThat(new SpringSecurityContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));
assertThat(new SpringSecurity5ContextManager().getActiveContext().getValue().getName(), is("Vincent Vega"));

ContextManagers.clearActiveContexts();
assertThat(new SpringSecurityContextManager().getActiveContext().getValue(), is(nullValue()));
assertThat(new SpringSecurity5ContextManager().getActiveContext().getValue(), is(nullValue()));
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2016-2022 Talsma ICT
* Copyright 2016-2023 Talsma ICT
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package nl.talsmasoftware.context.springsecurity;
package nl.talsmasoftware.context.springsecurity.v5;

import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
Expand Down

0 comments on commit 6666f51

Please sign in to comment.