fixed constructors for all filters
This commit is contained in:
Scott Battaglia 2007-01-02 20:54:15 +00:00
parent 707d27662d
commit f754e2f38c
9 changed files with 57 additions and 44 deletions

View File

@ -123,6 +123,21 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>xml-security</groupId>
<artifactId>xmlsec</artifactId>
<version>1.3.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>opensaml</groupId>
<artifactId>opensaml</artifactId>
<version>1.1b</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>
<reporting>
<excludeDefaults>false</excludeDefaults>

View File

@ -61,12 +61,12 @@ public abstract class AbstractCasFilter implements Filter {
* The name of the server in the following format: <hostname>:<port> where
* port is optional if its a standard port.
*/
private final String serverName;
private final String service;
/**
* The exact service url to match to.
*/
private final String serviceUrl;
private final boolean isServerName;
/**
* Whether to store the entry in session or not. Defaults to true.
@ -74,20 +74,18 @@ public abstract class AbstractCasFilter implements Filter {
private final boolean useSession;
protected AbstractCasFilter(final String serverName, final String serviceUrl) {
this(serverName, serviceUrl, true);
protected AbstractCasFilter(final String service, final boolean isServerName) {
this(service, isServerName, true);
}
protected AbstractCasFilter(final String serverName, final String serviceUrl, final boolean useSession) {
CommonUtils.assertTrue(CommonUtils.isNotBlank(serverName)
|| CommonUtils.isNotBlank(serviceUrl),
"either serverName or serviceUrl must be set");
protected AbstractCasFilter(final String service, final boolean isServerName, final boolean useSession) {
CommonUtils.assertNotNull(service, "service must be set");
this.serverName = serverName;
this.serviceUrl = serviceUrl;
this.service = service;
this.isServerName = isServerName;
this.useSession = useSession;
log.info("Service Name set to: " + this.serverName + "; Service Url set to: " + this.serviceUrl + "Use Session set to: " + this.useSession);
log.info("Service set to: " + this.service + "; Is Server Name? set to: " + this.isServerName + "Use Session set to: " + this.useSession);
}
public final void destroy() {
@ -120,15 +118,15 @@ public abstract class AbstractCasFilter implements Filter {
*/
protected final String constructServiceUrl(final HttpServletRequest request,
final HttpServletResponse response) {
if (CommonUtils.isNotBlank(this.serviceUrl)) {
return response.encodeURL(this.serviceUrl);
if (!isServerName) {
return response.encodeURL(this.service);
}
final StringBuffer buffer = new StringBuffer();
synchronized (buffer) {
buffer.append(request.isSecure() ? "https://" : "http://");
buffer.append(this.serverName);
buffer.append(this.service);
buffer.append(request.getRequestURI());
if (CommonUtils.isNotBlank(request.getQueryString())) {

View File

@ -41,16 +41,16 @@ public final class AuthenticationFilter extends AbstractCasFilter {
*/
private final boolean gateway;
public AuthenticationFilter(final String serverName, final String serviceUrl, final String casServerLoginUrl) {
this(serverName, serviceUrl, true, casServerLoginUrl, false, false);
public AuthenticationFilter(final String serverName, final boolean isServerName, final String casServerLoginUrl) {
this(serverName, isServerName, true, casServerLoginUrl, false, false);
}
public AuthenticationFilter(final String serverName, final String serviceUrl, final String casServerLoginUrl, boolean renew, boolean gateway) {
this(serverName, serviceUrl, true, casServerLoginUrl, renew, gateway);
public AuthenticationFilter(final String serverName, final boolean isServerName, final String casServerLoginUrl, boolean renew, boolean gateway) {
this(serverName, isServerName, true, casServerLoginUrl, renew, gateway);
}
public AuthenticationFilter(String serverName, String serviceUrl, boolean useSession, String casServerLoginUrl, boolean renew, boolean gateway) {
super(serverName, serviceUrl, useSession);
public AuthenticationFilter(final String serverName, final boolean isServerName, final boolean useSession, String casServerLoginUrl, final boolean renew, final boolean gateway) {
super(serverName, isServerName, useSession);
CommonUtils.assertNotNull(casServerLoginUrl,
"the CAS Server Login URL cannot be null.");
this.casServerLoginUrl = casServerLoginUrl;

View File

@ -51,39 +51,39 @@ public final class TicketValidationFilter extends AbstractCasFilter {
/**
* Constructor that takes the severName (or serviceUrl) and the TicketValidator. Either serveName or serviceUrl is required (but not both).
*
* @param serverName the name of the server in <hostname>:<port> combination, if using a non-standard port.
* @param serviceUrl the url to always redirect to.
* @param service the name of the server in <hostname>:<port> combination, if using a non-standard port or the fully qualified url.
* @param isServerName whether the service is the host name or the fully qualified url.
* @param ticketValidator the validator to validate the tickets.
*/
public TicketValidationFilter(final String serverName, final String serviceUrl, final TicketValidator ticketValidator) {
this(serverName, serviceUrl, true, ticketValidator, false);
public TicketValidationFilter(final String service, final boolean isServerName, final TicketValidator ticketValidator) {
this(service, isServerName, true, ticketValidator, false);
}
/**
* Constructor that takes the severName (or serviceUrl), TicketValidator, useSession and redirectAfterValidation. Either serveName or serviceUrl is required (but not both).
*
* @param serverName the name of the server in <hostname>:<port> combination, if using a non-standard port.
* @param serviceUrl the url to always redirect to.
* @param service the name of the server in <hostname>:<port> combination, if using a non-standard port or the fully qualified url.
* @param isServerName whether the service is the host name or the fully qualified url.
* @param useSession flag to set whether to store stuff in the session.
* @param ticketValidator the validator to validate the tickets.
* @param redirectAfterValidation whether to redirect to remove the ticket.
*/
public TicketValidationFilter(final String serverName, final String serviceUrl, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation) {
this(serverName, serviceUrl, useSession, ticketValidator, redirectAfterValidation, true);
public TicketValidationFilter(final String service, final boolean isServerName, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation) {
this(service, isServerName, useSession, ticketValidator, redirectAfterValidation, true);
}
/**
* Constructor that takes the severName (or serviceUrl), TicketValidator, useSession and redirectAfterValidation. Either serveName or serviceUrl is required (but not both).
*
* @param serverName the name of the server in <hostname>:<port> combination, if using a non-standard port.
* @param serviceUrl the url to always redirect to.
* @param service the name of the server in <hostname>:<port> combination, if using a non-standard port or the fully qualified url.
* @param isServerName whether the service is the host name or the fully qualified url.
* @param useSession flag to set whether to store stuff in the session.
* @param ticketValidator the validator to validate the tickets.
* @param redirectAfterValidation whether to redirect to remove the ticket.
* @param exceptionOnValidationFailure whether to throw an exception if there is a validation failure or not.
*/
public TicketValidationFilter(final String serverName, final String serviceUrl, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation, final boolean exceptionOnValidationFailure) {
super(serverName, serviceUrl, useSession);
public TicketValidationFilter(final String service, final boolean isServerName, final boolean useSession, final TicketValidator ticketValidator, final boolean redirectAfterValidation, final boolean exceptionOnValidationFailure) {
super(service, isServerName, useSession);
CommonUtils.assertNotNull(ticketValidator,
"ticketValidator cannot be null.");
this.ticketValidator = ticketValidator;

View File

@ -36,7 +36,7 @@ public final class AuthenticationFilterTests extends TestCase {
private AuthenticationFilter filter;
protected void setUp() throws Exception {
this.filter = new AuthenticationFilter(null, CAS_SERVICE_URL, CAS_LOGIN_URL, false, false);
this.filter = new AuthenticationFilter(CAS_SERVICE_URL, false, CAS_LOGIN_URL, false, false);
this.filter.init(new MockFilterConfig());
}
@ -80,7 +80,7 @@ public final class AuthenticationFilterTests extends TestCase {
};
request.setSession(session);
this.filter = new AuthenticationFilter("localhost:8443", null, CAS_LOGIN_URL, false, false);
this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL, false, false);
this.filter.doFilter(request, response, filterChain);
assertEquals(CAS_LOGIN_URL
@ -122,7 +122,7 @@ public final class AuthenticationFilterTests extends TestCase {
}
};
this.filter = new AuthenticationFilter("localhost:8443", null, CAS_LOGIN_URL, true, false);
this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL, true, false);
request.setSession(session);
this.filter.doFilter(request, response, filterChain);
@ -143,7 +143,7 @@ public final class AuthenticationFilterTests extends TestCase {
};
request.setSession(session);
this.filter = new AuthenticationFilter("localhost:8443", null, CAS_LOGIN_URL, true, true);
this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL, true, true);
this.filter.doFilter(request, response, filterChain);
assertNotNull(session.getAttribute(AbstractCasFilter.CONST_GATEWAY));
assertNotNull(response.getRedirectedUrl());

View File

@ -34,7 +34,7 @@ public final class ValidationFilterTests extends TestCase {
private TicketValidationFilter filter;
protected void setUp() throws Exception {
this.filter = new TicketValidationFilter("localhost:8443", null, new TicketValidator() {
this.filter = new TicketValidationFilter("localhost:8443", true, new TicketValidator() {
public Assertion validate(final String ticketId,
final Service service) throws ValidationException {

View File

@ -30,12 +30,12 @@ import java.io.IOException;
public final class ThreadLocalAwareCasServiceFilter extends AbstractCasFilter {
public ThreadLocalAwareCasServiceFilter(final String serverName, final String serviceUrl) {
super(serverName, serviceUrl);
public ThreadLocalAwareCasServiceFilter(final String service, final boolean isServerName) {
super(service, isServerName);
}
public ThreadLocalAwareCasServiceFilter(final String serverName, final String serviceUrl, final boolean useSession) {
super(serverName, serviceUrl, useSession);
public ThreadLocalAwareCasServiceFilter(final String service, final boolean isServerName, final boolean useSession) {
super(service, isServerName, useSession);
}
protected void doFilterInternal(final HttpServletRequest request,

View File

@ -22,7 +22,7 @@ public final class ThreadLocalAwareCasServiceFilterTests extends TestCase {
protected void setUp() throws Exception {
this.filter = new ThreadLocalAwareCasServiceFilter(null, "http://localhost");
this.filter = new ThreadLocalAwareCasServiceFilter("http://localhost", false);
}
public void testServiceSetter() throws IOException, ServletException {

View File

@ -64,7 +64,7 @@
</licenses>
<scm>
<connection>scm:cvs:pserver:anonymous:@developer.ja-sig.org:2401/home/cvs/jasig:cas-clients/java-client</connection>
<developerConnection>scm:cvs:pserver:${username}@developer.ja-sig.org:/home/cvs/jasig:cas-clients/java-client
<developerConnection>scm:cvs:pserver:${username}@developer.ja-sig.org:2401/home/cvs/jasig:cas-clients/java-client
</developerConnection>
<url>http://developer.ja-sig.org/source/browse/jasig/cas-clients/java-client</url>
</scm>
@ -115,7 +115,7 @@
<dependency>
<groupId>cas</groupId>
<artifactId>cas-server</artifactId>
<version>3.0.5</version>
<version>3.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>