SEC-712: HttpSessionContextIntegrationFilter "context" property should be renamed
http://jira.springframework.org/browse/SEC-712
This commit is contained in:
parent
ed08ba10ba
commit
089bffa10f
|
@ -49,7 +49,7 @@ import org.springframework.security.ui.FilterChainOrder;
|
|||
* If a valid <code>SecurityContext</code> cannot be obtained from the
|
||||
* <code>HttpSession</code> for whatever reason, a fresh
|
||||
* <code>SecurityContext</code> will be created and used instead. The created
|
||||
* object will be of the instance defined by the {@link #setContext(Class)}
|
||||
* object will be of the instance defined by the {@link #setContextClass(Class)}
|
||||
* method (which defaults to {@link org.springframework.security.context.SecurityContextImpl}.
|
||||
* </p>
|
||||
* <p/>
|
||||
|
@ -58,7 +58,7 @@ import org.springframework.security.ui.FilterChainOrder;
|
|||
* does not exist, a <code>HttpSession</code> will <b>only</b> be created if
|
||||
* the current contents of the <code>SecurityContextHolder</code> are not
|
||||
* {@link java.lang.Object#equals(java.lang.Object)} to a <code>new</code>
|
||||
* instance of {@link #setContext(Class)}. This avoids needless
|
||||
* instance of {@link #setContextClass(Class)}. This avoids needless
|
||||
* <code>HttpSession</code> creation, but automates the storage of changes
|
||||
* made to the <code>SecurityContextHolder</code>. There is one exception to
|
||||
* this rule, that is if the {@link #forceEagerSessionCreation} property is
|
||||
|
@ -108,7 +108,7 @@ public class HttpSessionContextIntegrationFilter extends SpringSecurityFilter im
|
|||
|
||||
//~ Instance fields ================================================================================================
|
||||
|
||||
private Class context = SecurityContextImpl.class;
|
||||
private Class contextClass = SecurityContextImpl.class;
|
||||
|
||||
private Object contextObject;
|
||||
|
||||
|
@ -149,7 +149,7 @@ public class HttpSessionContextIntegrationFilter extends SpringSecurityFilter im
|
|||
* allowed to affect the security identitiy in other threads associated with
|
||||
* the same <code>HttpSession</code>. For unusual cases where this is not
|
||||
* permitted, change this value to <code>true</code> and ensure the
|
||||
* {@link #context} is set to a <code>SecurityContext</code> that
|
||||
* {@link #contextClass} is set to a <code>SecurityContext</code> that
|
||||
* implements {@link Cloneable} and overrides the <code>clone()</code>
|
||||
* method.
|
||||
*/
|
||||
|
@ -170,10 +170,10 @@ public class HttpSessionContextIntegrationFilter extends SpringSecurityFilter im
|
|||
//~ Methods ========================================================================================================
|
||||
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if ((this.context == null) || (!SecurityContext.class.isAssignableFrom(this.context))) {
|
||||
if ((this.contextClass == null) || (!SecurityContext.class.isAssignableFrom(this.contextClass))) {
|
||||
throw new IllegalArgumentException("context must be defined and implement SecurityContext "
|
||||
+ "(typically use org.springframework.security.context.SecurityContextImpl; existing class is "
|
||||
+ this.context + ")");
|
||||
+ this.contextClass + ")");
|
||||
}
|
||||
|
||||
if (forceEagerSessionCreation && !allowSessionCreation) {
|
||||
|
@ -407,7 +407,7 @@ public class HttpSessionContextIntegrationFilter extends SpringSecurityFilter im
|
|||
|
||||
public SecurityContext generateNewContext() throws ServletException {
|
||||
try {
|
||||
return (SecurityContext) this.context.newInstance();
|
||||
return (SecurityContext) this.contextClass.newInstance();
|
||||
}
|
||||
catch (InstantiationException ie) {
|
||||
throw new ServletException(ie);
|
||||
|
@ -425,12 +425,12 @@ public class HttpSessionContextIntegrationFilter extends SpringSecurityFilter im
|
|||
this.allowSessionCreation = allowSessionCreation;
|
||||
}
|
||||
|
||||
public Class getContext() {
|
||||
return context;
|
||||
protected Class getContextClass() {
|
||||
return contextClass;
|
||||
}
|
||||
|
||||
public void setContext(Class secureContext) {
|
||||
this.context = secureContext;
|
||||
public void setContextClass(Class secureContext) {
|
||||
this.contextClass = secureContext;
|
||||
}
|
||||
|
||||
public boolean isForceEagerSessionCreation() {
|
||||
|
|
|
@ -85,7 +85,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
|
||||
try {
|
||||
filter.setContext(null);
|
||||
filter.setContextClass(null);
|
||||
filter.afterPropertiesSet();
|
||||
fail("Shown have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
@ -93,8 +93,8 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
}
|
||||
|
||||
try {
|
||||
filter.setContext(Integer.class);
|
||||
assertEquals(Integer.class, filter.getContext());
|
||||
filter.setContextClass(Integer.class);
|
||||
assertEquals(Integer.class, filter.getContextClass());
|
||||
filter.afterPropertiesSet();
|
||||
fail("Shown have thrown IllegalArgumentException");
|
||||
} catch (IllegalArgumentException expected) {
|
||||
|
@ -127,7 +127,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
// Execute filter
|
||||
|
@ -179,7 +179,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
// Execute filter
|
||||
|
@ -206,7 +206,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
// don't call afterPropertiesSet to test case when Spring filter.afterPropertiesSet(); isn't called
|
||||
|
||||
// Execute filter
|
||||
|
@ -226,7 +226,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.setForceEagerSessionCreation(true); // non-default
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
// Execute filter
|
||||
|
@ -276,7 +276,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
// Execute filter
|
||||
|
@ -308,7 +308,7 @@ public class HttpSessionContextIntegrationFilterTests extends TestCase {
|
|||
|
||||
// Prepare filter
|
||||
HttpSessionContextIntegrationFilter filter = new HttpSessionContextIntegrationFilter();
|
||||
filter.setContext(SecurityContextImpl.class);
|
||||
filter.setContextClass(SecurityContextImpl.class);
|
||||
filter.afterPropertiesSet();
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
|
Loading…
Reference in New Issue