247 changed files with 611 additions and 506 deletions
@ -0,0 +1,18 @@ |
|||||||
|
package org.springframework.security.event; |
||||||
|
|
||||||
|
import org.springframework.context.ApplicationEvent; |
||||||
|
|
||||||
|
/** |
||||||
|
* Generic session creation event which indicates that a session (potentially |
||||||
|
* represented by a security context) has begun. |
||||||
|
* |
||||||
|
* @author Luke Taylor |
||||||
|
* @version $Id$ |
||||||
|
* @since 2.5 |
||||||
|
*/ |
||||||
|
public abstract class SessionCreationEvent extends ApplicationEvent { |
||||||
|
|
||||||
|
public SessionCreationEvent(Object source) { |
||||||
|
super(source); |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
package org.springframework.security.event; |
||||||
|
|
||||||
|
import org.springframework.context.ApplicationEvent; |
||||||
|
import org.springframework.security.context.SecurityContext; |
||||||
|
|
||||||
|
/** |
||||||
|
* Generic "session termination" event which indicates that a session (potentially |
||||||
|
* represented by a security context) has ended. |
||||||
|
* |
||||||
|
* @author Luke Taylor |
||||||
|
* @version $Id$ |
||||||
|
* @since 2.5 |
||||||
|
*/ |
||||||
|
public abstract class SessionDestroyedEvent extends ApplicationEvent { |
||||||
|
|
||||||
|
public SessionDestroyedEvent(Object source) { |
||||||
|
super(source); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* Provides the <tt>SecurityContext</tt> under which the session was running. |
||||||
|
* |
||||||
|
* @return the <tt>SecurityContext</tt> associated with the session, or null if there is no context. |
||||||
|
*/ |
||||||
|
public abstract SecurityContext getSecurityContext(); |
||||||
|
} |
||||||
@ -1,50 +0,0 @@ |
|||||||
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
|
||||||
* |
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
* you may not use this file except in compliance with the License. |
|
||||||
* You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.springframework.security.ui.session; |
|
||||||
|
|
||||||
import org.springframework.context.ApplicationEvent; |
|
||||||
|
|
||||||
import javax.servlet.http.HttpSession; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* Parent class for published HttpSession events |
|
||||||
* |
|
||||||
* @author Ray Krueger |
|
||||||
*/ |
|
||||||
public abstract class HttpSessionApplicationEvent extends ApplicationEvent { |
|
||||||
//~ Constructors ===================================================================================================
|
|
||||||
|
|
||||||
/** |
|
||||||
* Base constructor for all subclasses must have an HttpSession |
|
||||||
* |
|
||||||
* @param httpSession The session to carry as the event source. |
|
||||||
*/ |
|
||||||
public HttpSessionApplicationEvent(HttpSession httpSession) { |
|
||||||
super(httpSession); |
|
||||||
} |
|
||||||
|
|
||||||
//~ Methods ========================================================================================================
|
|
||||||
|
|
||||||
/** |
|
||||||
* Get the HttpSession that is the cause of the event |
|
||||||
* |
|
||||||
* @return HttpSession instance |
|
||||||
*/ |
|
||||||
public HttpSession getSession() { |
|
||||||
return (HttpSession) getSource(); |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,56 +0,0 @@ |
|||||||
/* Copyright 2004, 2005, 2006 Acegi Technology Pty Limited |
|
||||||
* |
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
||||||
* you may not use this file except in compliance with the License. |
|
||||||
* You may obtain a copy of the License at |
|
||||||
* |
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
* |
|
||||||
* Unless required by applicable law or agreed to in writing, software |
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, |
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
||||||
* See the License for the specific language governing permissions and |
|
||||||
* limitations under the License. |
|
||||||
*/ |
|
||||||
|
|
||||||
package org.springframework.security.util; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
|
|
||||||
import javax.servlet.FilterChain; |
|
||||||
import javax.servlet.ServletException; |
|
||||||
import javax.servlet.ServletRequest; |
|
||||||
import javax.servlet.ServletResponse; |
|
||||||
|
|
||||||
import org.junit.Assert; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* A mock <code>FilterChain</code>. |
|
||||||
* |
|
||||||
* @author Ben Alex |
|
||||||
* @version $Id$ |
|
||||||
*/ |
|
||||||
public class MockFilterChain implements FilterChain { |
|
||||||
//~ Instance fields ================================================================================================
|
|
||||||
|
|
||||||
private boolean expectToProceed; |
|
||||||
|
|
||||||
//~ Constructors ===================================================================================================
|
|
||||||
|
|
||||||
public MockFilterChain() { |
|
||||||
this(true); |
|
||||||
} |
|
||||||
|
|
||||||
public MockFilterChain(boolean expectToProceed) { |
|
||||||
this.expectToProceed = expectToProceed; |
|
||||||
} |
|
||||||
|
|
||||||
//~ Methods ========================================================================================================
|
|
||||||
|
|
||||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException { |
|
||||||
if (!expectToProceed) { |
|
||||||
Assert.fail("Did not expect filter chain to proceed"); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
@ -0,0 +1,57 @@ |
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<parent> |
||||||
|
<groupId>org.springframework.security</groupId> |
||||||
|
<artifactId>spring-security-parent</artifactId> |
||||||
|
<version>2.5.0-SNAPSHOT</version> |
||||||
|
</parent> |
||||||
|
<packaging>jar</packaging> |
||||||
|
<artifactId>spring-security-web</artifactId> |
||||||
|
<name>Spring Security - Web Application Security Module</name> |
||||||
|
|
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.security</groupId> |
||||||
|
<artifactId>spring-security-core</artifactId> |
||||||
|
<version>${project.version}</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.security</groupId> |
||||||
|
<artifactId>spring-security-core</artifactId> |
||||||
|
<version>${project.version}</version> |
||||||
|
<classifier>tests</classifier> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework</groupId> |
||||||
|
<artifactId>org.springframework.web</artifactId> |
||||||
|
<!-- optional>true</optional --> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework</groupId> |
||||||
|
<artifactId>org.springframework.jdbc</artifactId> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework</groupId> |
||||||
|
<artifactId>org.springframework.test</artifactId> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>jaxen</groupId> |
||||||
|
<artifactId>jaxen</artifactId> |
||||||
|
<version>1.1.1</version> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>hsqldb</groupId> |
||||||
|
<artifactId>hsqldb</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>javax.servlet</groupId> |
||||||
|
<artifactId>servlet-api</artifactId> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
|
||||||
|
</project> |
||||||
@ -0,0 +1,6 @@ |
|||||||
|
<html> |
||||||
|
<body> |
||||||
|
Concurrent session control and registration classes. |
||||||
|
</body> |
||||||
|
</html> |
||||||
|
|
||||||
@ -1,4 +1,4 @@ |
|||||||
package org.springframework.security.context; |
package org.springframework.security.context.web; |
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.http.HttpServletRequest; |
||||||
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
||||||
@ -1,10 +1,13 @@ |
|||||||
package org.springframework.security.context; |
package org.springframework.security.context.web; |
||||||
|
|
||||||
import java.io.IOException; |
import java.io.IOException; |
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse; |
import javax.servlet.http.HttpServletResponse; |
||||||
import javax.servlet.http.HttpServletResponseWrapper; |
import javax.servlet.http.HttpServletResponseWrapper; |
||||||
|
|
||||||
|
import org.springframework.security.context.SecurityContext; |
||||||
|
import org.springframework.security.context.SecurityContextHolder; |
||||||
|
|
||||||
/** |
/** |
||||||
* Base class for response wrappers which encapsulate the logic for storing a security context and which |
* Base class for response wrappers which encapsulate the logic for storing a security context and which |
||||||
* store the with the <code>SecurityContext</code> when a <code>sendError()</code> or <code>sendRedirect</code> |
* store the with the <code>SecurityContext</code> when a <code>sendError()</code> or <code>sendRedirect</code> |
||||||
@ -0,0 +1,19 @@ |
|||||||
|
package org.springframework.security.expression.web; |
||||||
|
|
||||||
|
import org.springframework.expression.EvaluationContext; |
||||||
|
import org.springframework.expression.ExpressionParser; |
||||||
|
import org.springframework.security.Authentication; |
||||||
|
import org.springframework.security.intercept.web.FilterInvocation; |
||||||
|
|
||||||
|
public interface WebSecurityExpressionHandler { |
||||||
|
/** |
||||||
|
* @return an expression parser for the expressions used by the implementation. |
||||||
|
*/ |
||||||
|
ExpressionParser getExpressionParser(); |
||||||
|
|
||||||
|
/** |
||||||
|
* Provides an evaluation context in which to evaluate security expressions for a web invocation. |
||||||
|
*/ |
||||||
|
EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi); |
||||||
|
|
||||||
|
} |
||||||
@ -0,0 +1,39 @@ |
|||||||
|
package org.springframework.security.expression.web.support; |
||||||
|
|
||||||
|
import org.springframework.expression.EvaluationContext; |
||||||
|
import org.springframework.expression.ExpressionParser; |
||||||
|
import org.springframework.expression.spel.antlr.SpelAntlrExpressionParser; |
||||||
|
import org.springframework.expression.spel.support.StandardEvaluationContext; |
||||||
|
import org.springframework.security.Authentication; |
||||||
|
import org.springframework.security.AuthenticationTrustResolver; |
||||||
|
import org.springframework.security.AuthenticationTrustResolverImpl; |
||||||
|
import org.springframework.security.expression.support.SecurityExpressionRoot; |
||||||
|
import org.springframework.security.expression.web.WebSecurityExpressionHandler; |
||||||
|
import org.springframework.security.intercept.web.FilterInvocation; |
||||||
|
|
||||||
|
/** |
||||||
|
* Facade which isolates Spring Security's requirements for evaluating web-security expressions |
||||||
|
* from the implementation of the underlying expression objects. |
||||||
|
* |
||||||
|
* @author Luke Taylor |
||||||
|
* @version $Id$ |
||||||
|
* @since 2.5 |
||||||
|
*/ |
||||||
|
public class DefaultWebSecurityExpressionHandler implements WebSecurityExpressionHandler { |
||||||
|
|
||||||
|
private AuthenticationTrustResolver trustResolver = new AuthenticationTrustResolverImpl(); |
||||||
|
private ExpressionParser expressionParser = new SpelAntlrExpressionParser(); |
||||||
|
|
||||||
|
public ExpressionParser getExpressionParser() { |
||||||
|
return expressionParser; |
||||||
|
} |
||||||
|
|
||||||
|
public EvaluationContext createEvaluationContext(Authentication authentication, FilterInvocation fi) { |
||||||
|
StandardEvaluationContext ctx = new StandardEvaluationContext(); |
||||||
|
SecurityExpressionRoot root = new WebSecurityExpressionRoot(authentication, fi); |
||||||
|
root.setTrustResolver(trustResolver); |
||||||
|
ctx.setRootObject(root); |
||||||
|
|
||||||
|
return ctx; |
||||||
|
} |
||||||
|
} |
||||||
@ -1,10 +1,11 @@ |
|||||||
package org.springframework.security.expression.support; |
package org.springframework.security.expression.web.support; |
||||||
|
|
||||||
import java.net.InetAddress; |
import java.net.InetAddress; |
||||||
import java.net.UnknownHostException; |
import java.net.UnknownHostException; |
||||||
import java.util.Arrays; |
import java.util.Arrays; |
||||||
|
|
||||||
import org.springframework.security.Authentication; |
import org.springframework.security.Authentication; |
||||||
|
import org.springframework.security.expression.support.SecurityExpressionRoot; |
||||||
import org.springframework.security.intercept.web.FilterInvocation; |
import org.springframework.security.intercept.web.FilterInvocation; |
||||||
import org.springframework.util.StringUtils; |
import org.springframework.util.StringUtils; |
||||||
|
|
||||||
@ -1,9 +1,9 @@ |
|||||||
package org.springframework.security.securechannel; |
package org.springframework.security.securechannel; |
||||||
|
|
||||||
import org.springframework.security.util.PortMapper; |
import org.springframework.security.web.util.PortMapper; |
||||||
import org.springframework.security.util.PortResolver; |
import org.springframework.security.web.util.PortMapperImpl; |
||||||
import org.springframework.security.util.PortMapperImpl; |
import org.springframework.security.web.util.PortResolver; |
||||||
import org.springframework.security.util.PortResolverImpl; |
import org.springframework.security.web.util.PortResolverImpl; |
||||||
import org.springframework.util.Assert; |
import org.springframework.util.Assert; |
||||||
|
|
||||||
import org.apache.commons.logging.Log; |
import org.apache.commons.logging.Log; |
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue