mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-03-01 02:49:11 +00:00
SEC-1521: Add check for null SecurityContextRepository and clarify related docs on use of null implementation (NullSecurityContextRepository).
This commit is contained in:
parent
e659e15f90
commit
d7d8448120
@ -241,17 +241,18 @@ public interface SecurityContextRepository {
|
|||||||
changed). If you don't want a session to be created, then you can set this property
|
changed). If you don't want a session to be created, then you can set this property
|
||||||
to <literal>false</literal>: <programlisting language="xml"><![CDATA[
|
to <literal>false</literal>: <programlisting language="xml"><![CDATA[
|
||||||
<bean id="securityContextPersistenceFilter"
|
<bean id="securityContextPersistenceFilter"
|
||||||
class="org.springframework.security.web.context.SecurityContextPersistenceFilter">
|
class="org.springframework.security.web.context.SecurityContextPersistenceFilter">
|
||||||
<property name='securityContextRepository'>
|
<property name='securityContextRepository'>
|
||||||
<bean class='org.springframework.security.web.context.HttpSessionSecurityContextRepository'>
|
<bean class='org.springframework.security.web.context.HttpSessionSecurityContextRepository'>
|
||||||
<property name='allowSessionCreation' value='false' />
|
<property name='allowSessionCreation' value='false' />
|
||||||
|
</bean>
|
||||||
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
</property>
|
]]></programlisting> Alternatively you could provide an instance of
|
||||||
</bean>
|
<classname>NullSecurityContextRepository</classname>, a <quote><link
|
||||||
]]></programlisting> Alternatively you could provide a null implementation of the
|
xlink:href="http://en.wikipedia.org/wiki/Null_Object_pattern">null object</link></quote>
|
||||||
<interfacename>SecurityContextRepository</interfacename> interface, which will
|
implementation, which will prevent the security context from being stored, even if a
|
||||||
prevent the security context from being stored, even if a session has already been
|
session has already been created during the request. </para>
|
||||||
created during the request. </para>
|
|
||||||
</section>
|
</section>
|
||||||
</section>
|
</section>
|
||||||
<section xml:id="form-login-filter">
|
<section xml:id="form-login-filter">
|
||||||
|
@ -12,6 +12,7 @@ import javax.servlet.http.HttpSession;
|
|||||||
|
|
||||||
import org.springframework.security.core.context.SecurityContext;
|
import org.springframework.security.core.context.SecurityContext;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.web.filter.GenericFilterBean;
|
import org.springframework.web.filter.GenericFilterBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,6 +93,7 @@ public class SecurityContextPersistenceFilter extends GenericFilterBean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setSecurityContextRepository(SecurityContextRepository repo) {
|
public void setSecurityContextRepository(SecurityContextRepository repo) {
|
||||||
|
Assert.notNull(repo, "SecurityContextRepository cannot be null");
|
||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user