diff --git a/cas-client-core/LICENSE.txt b/cas-client-core/LICENSE.txt deleted file mode 100644 index 30c8573..0000000 --- a/cas-client-core/LICENSE.txt +++ /dev/null @@ -1,29 +0,0 @@ -License for Use - -Copyright (c) 2000 The JA-SIG Collaborative. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes software developed by the JA-SIG Collaborative - (http://www.ja-sig.org/)." - -This software is provided by the JA-SIG collaborative "as is" and any expressed -or implied warranties, including, but not limited to, the implied warranties of -merchantability and fitness for a particular purpose are disclaimed. In no -event shall the JA-SIG collaborative or its contributors be liable for any -direct, indirect, incidental, special, exemplary, or consequential damages -(including, but not limited to, procurement of substitute goods or services; -loss of use, data, or profits; or business interruption) however caused and on -any theory of liability, whether in contract, strict liability, or tort -(including negligence or otherwise) arising in any way out of the use of this -software, even if advised of the possibility of such damage. \ No newline at end of file diff --git a/cas-client-core/README.txt b/cas-client-core/README.txt deleted file mode 100644 index f5cd476..0000000 --- a/cas-client-core/README.txt +++ /dev/null @@ -1,28 +0,0 @@ -CENTRAL AUTHENTICATION SERVICE (CAS) --------------------------------------------------------------------- -http://www.ja-sig.org/products/cas/ - -1. INTRODUCTION - -The Central Authentication Service (CAS) is the standard mechanism by which web -applications should authenticate users. Any custom applications written benefit -from using CAS. - -Note that CAS provides authentication; that is, it determines that your users -are who they say they are. CAS should not be viewed as an access-control system; -in particular, providers of applications that grant access to anyone who -possesses a NetID should understand that loose affiliates of an organization may -be granted NetIDs. - -The JA-SIG CAS Client for Java is a support library for Java applications to communicate -with the CAS server. - -2. RELEASE INFO - -CAS requires J2SE 1.4 and J2EE1.3. - -Release conents: -* "src/main/java" contains the Java source files for the framework -* "src/test/java" contains the Java source files for CAS's test suite - - diff --git a/cas-client-core/cas-client-core.iml b/cas-client-core/cas-client-core.iml deleted file mode 100644 index d595813..0000000 --- a/cas-client-core/cas-client-core.iml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cas-client-core/pom.xml b/cas-client-core/pom.xml deleted file mode 100644 index acf8cc9..0000000 --- a/cas-client-core/pom.xml +++ /dev/null @@ -1,173 +0,0 @@ - - - org.jasig.cas - 3.1-m1 - cas-client - - 4.0.0 - org.jasig.cas - cas-client-core - jar - JA-SIG CAS Client for Java - Core - 3.1-m1 - - - src/main/java - src/test/java - - - src/test/resources - false - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.4 - 1.4 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Tests* - - - - - org.apache.maven.plugins - maven-clover-plugin - - ${basedir}/src/test/clover/clover.license - - - - pre-site - - instrument - - - - - - - - - - commons-httpclient - commons-httpclient - 3.0.1 - compile - - - - commons-httpclient - commons-httpclient-contrib - 3.0 - compile - - - - org.springframework - spring-web - 2.0.2 - compile - - - - org.springframework - spring-context - 2.0.2 - compile - - - - org.springframework - spring-mock - 2.0.2 - compile - - - org.springframework - spring-beans - - - - org.springframework - spring-core - - - - org.springframework - spring-dao - - - - org.springframework - spring-jdbc - - - - org.springframework - spring-jpa - - - - - - xml-security - xmlsec - 1.3.0 - runtime - - - - org.opensaml - opensaml - 1.1b - jar - compile - - - - false - - - org.apache.maven.plugins - maven-clover-plugin - - ${basedir}/src/test/clover/clover.license - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - org.apache.maven.plugins - maven-javadoc-plugin - - 128m - 512m - - - - org.apache.maven.plugins - maven-jxr-plugin - - - org.apache.maven.plugins - maven-surefire-report-plugin - - - org.codehaus.mojo - jdepend-maven-plugin - - - - diff --git a/cas-client-core/settings.xml b/cas-client-core/settings.xml deleted file mode 100644 index 977af0a..0000000 --- a/cas-client-core/settings.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - central - JA-SIG Maven Repository - http://developer.ja-sig.org/maven/ - jasig - - \ No newline at end of file diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizationException.java b/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizationException.java deleted file mode 100644 index 729b30e..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizationException.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -/** - * Exception to be thrown if the user is not authorized to use the system. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AuthorizationException extends RuntimeException { - - /** - * Unique ID for serialization. - */ - private static final long serialVersionUID = 5912038088650643442L; - - /** - * Constructs a new exception with the specified detail message and cause. - * - * @param message the detail message. The detail message is saved for later retrieval by the Throwable.getMessage() method. - * @param cause the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) - */ - public AuthorizationException(final String message, final Throwable cause) { - super(message, cause); - } - - /** - * Constructs a new exception with the specified detail message. - * - * @param message the detail message. The detail message is saved for later retrieval by the Throwable.getMessage() method. - */ - public AuthorizationException(final String message) { - super(message); - } - - /** - * Constructs a new exception with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). - * - * @param cause the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) - */ - public AuthorizationException(final Throwable cause) { - super(cause); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizedDecider.java b/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizedDecider.java deleted file mode 100644 index 4590021..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/AuthorizedDecider.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -import org.jasig.cas.authentication.principal.Principal; - -/** - * Simple interface for determining whether a Principal is authorized to use the - * application or not. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface AuthorizedDecider { - - /** - * Determines whether someone can use the system or not. - * - * @param principal the person we are checking - * @return true if authorized, false otherwise. - */ - boolean isAuthorizedToUseApplication(final Principal principal); -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImpl.java b/cas-client-core/src/main/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImpl.java deleted file mode 100644 index ea00b07..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.client.util.CommonUtils; - -import java.util.List; - -/** - * Default implementation of the AuthorizedDecider that delegates to a list - * to check if someone is authorized. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class DefaultAuthorizedDeciderImpl implements - AuthorizedDecider { - - /** - * The list of users authorized to use the system. - */ - private final List users; - - /** - * Constructor that takes the list of acceptable users as its parameters. - * - * @param users the list of acceptable users. - */ - public DefaultAuthorizedDeciderImpl(final List users) { - CommonUtils.assertNotEmpty(users, "users cannot be empty."); - this.users = users; - } - - public boolean isAuthorizedToUseApplication(final Principal principal) { - return this.users.contains(principal.getId()); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/package.html b/cas-client-core/src/main/java/org/jasig/cas/client/authorization/package.html deleted file mode 100644 index 772f980..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/authorization/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - -

The authorization package contains the interface for a simple - abstraction for authorizing users to use an application. It is not a - complete role-based or access control authorization system.

- -

For true authorization we recommend you look at the Security for Spring - project.

- - diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/AbstractProxyReceptorServlet.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/AbstractProxyReceptorServlet.java deleted file mode 100644 index 9ddf21e..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/AbstractProxyReceptorServlet.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jasig.cas.client.util.CommonUtils; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Implementation of an HttpServlet that accepts ProxyGrantingTicketIous and - * ProxyGrantingTickets and stores them in an implementation of - * {@link ProxyGrantingTicketStorage}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractProxyReceptorServlet extends HttpServlet { - - /** - * The name we expect the instance of ProxyGrantingTicketStorage to be - * instanciated under in the applicationContext. - */ - public static final String CONST_PROXY_GRANTING_TICKET_STORAGE_BEAN_NAME = "proxyGrantingTicketStorage"; - - /** - * Constant representing the ProxyGrantingTicket IOU Request Parameter. - */ - private static final String PARAM_PROXY_GRANTING_TICKET_IOU = "pgtIou"; - - /** - * Constant representing the ProxyGrantingTicket Request Parameter. - */ - private static final String PARAM_PROXY_GRANTING_TICKET = "pgtId"; - - /** - * Instance of ProxyGrantingTicketStorage to store ProxyGrantingTickets. - */ - private ProxyGrantingTicketStorage proxyGrantingTicketStorage; - - /** - * Instance of Commons Logging - */ - protected final Log logger = LogFactory.getLog(this.getClass()); - - /** - * Unique Id for Serialization. - */ - private static final long serialVersionUID = 8766956323018042995L; - - protected final void doGet(final HttpServletRequest request, - final HttpServletResponse response) throws ServletException, - IOException { - final String proxyGrantingTicketIou = request - .getParameter(PARAM_PROXY_GRANTING_TICKET_IOU); - - final String proxyGrantingTicket = request - .getParameter(PARAM_PROXY_GRANTING_TICKET); - - if (CommonUtils.isBlank(proxyGrantingTicket) - || CommonUtils.isBlank(proxyGrantingTicketIou)) { - response.getWriter().write(""); - return; - } - - if (logger.isDebugEnabled()) { - logger.debug("Received proxyGrantingTicketId [" - + proxyGrantingTicket + "] for proxyGrantingTicketIou [" - + proxyGrantingTicketIou + "]"); - } - - this.proxyGrantingTicketStorage.save(proxyGrantingTicketIou, - proxyGrantingTicket); - - response.getWriter().write(""); - response - .getWriter() - .write( - ""); - } - - /** - * Delegates to the protected method retrieveProxyGrantingTicketStorageFromConfiguration(). - */ - public final void init(final ServletConfig servletConfig) throws ServletException { - this.proxyGrantingTicketStorage = retrieveProxyGrantingTicketStorageFromConfiguration(servletConfig); - } - - /** - * Abstract class to retrieve the ProxyGrantingTicketStorage from the ServletConfig. Its up to - * implementing classes to figure out where they are initializing/retrieving the object from. - * - * @param servletConfig the Servlet Config that has access to the ProxyGrantingTicketStorage. - * @return the initialized ProxyGrantingTicketStorage. - * @throws ServletException if there is an exception retrieving the ProxyGrantingTicketStorage. - */ - protected abstract ProxyGrantingTicketStorage retrieveProxyGrantingTicketStorageFromConfiguration(final ServletConfig servletConfig) throws ServletException; -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/Cas20ProxyRetriever.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/Cas20ProxyRetriever.java deleted file mode 100644 index d49190c..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/Cas20ProxyRetriever.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.util.XmlUtils; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; - -/** - * Implementation of a ProxyRetriever that follows the CAS 2.0 specification. - * For more information on the CAS 2.0 specification, please see the specification - * document. - *

- * In general, this class will make a call to the CAS server with some specified - * parameters and receive an XML response to parse. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class Cas20ProxyRetriever implements ProxyRetriever { - - /** - * Instance of Commons Logging. - */ - protected final Log log = LogFactory.getLog(this.getClass()); - - /** - * Url to CAS server. - */ - private final String casServerUrl; - - /** - * Instance of HttpClient for connecting to server. - */ - private final HttpClient httpClient; - - /** - * Main Constructor. - * - * @param casServerUrl the URL to the CAS server (i.e. http://localhost/cas/) - * @param httpClient an Instance of a thread-safe HttpClient. - */ - public Cas20ProxyRetriever(final String casServerUrl, final HttpClient httpClient) { - CommonUtils.assertNotNull(casServerUrl, - "casServerUrl cannot be null."); - CommonUtils - .assertNotNull(httpClient, "httpClient cannot be null."); - this.casServerUrl = casServerUrl; - this.httpClient = httpClient; - } - - public String getProxyTicketIdFor(final String proxyGrantingTicketId, - final Service targetService) { - - final String url = constructUrl(proxyGrantingTicketId, targetService - .getId()); - - final GetMethod method = new GetMethod(url); - try { - this.httpClient.executeMethod(method); - final String response = method.getResponseBodyAsString(); - - final String error = XmlUtils.getTextForElement(response, - "proxyFailure"); - - if (CommonUtils.isNotEmpty(error)) { - log.debug(error); - return null; - } - - return XmlUtils.getTextForElement(response, "proxyTicket"); - - } catch (IOException e) { - log.error(e, e); - return null; - } finally { - method.releaseConnection(); - } - } - - private String constructUrl(final String proxyGrantingTicketId, - final String targetService) { - try { - return this.casServerUrl + "proxy" + "?pgt=" - + proxyGrantingTicketId + "&targetService=" - + URLEncoder.encode(targetService, "UTF-8"); - } catch (final UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorage.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorage.java deleted file mode 100644 index c541160..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorage.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -/** - * Interface for the storage and retrieval of ProxyGrantingTicketIds by mapping - * them to a specific ProxyGrantingTicketIou. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface ProxyGrantingTicketStorage { - - /** - * Method to save the ProxyGrantingTicket to the backing storage facility. - * - * @param proxyGrantingTicketIou used as the key - * @param proxyGrantingTicket used as the value - */ - public void save(String proxyGrantingTicketIou, String proxyGrantingTicket); - - /** - * Method to retrieve a ProxyGrantingTicket based on the - * ProxyGrantingTicketIou. Note that implementations are not guaranteed to - * return the same result if retrieve is called twice with the same - * proxyGrantingTicketIou. - * - * @param proxyGrantingTicketIou used as the key - * @return the ProxyGrantingTicket Id or null if it can't be found - */ - public String retrieve(String proxyGrantingTicketIou); -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImpl.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImpl.java deleted file mode 100644 index 0e4283f..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImpl.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * Implementation of {@link ProxyGrantingTicketStorage} that is backed by a - * HashMap that keeps a ProxyGrantingTicket for a specified amount of time. - *

- * A cleanup thread is run periodically to clean out the HashMap. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ProxyGrantingTicketStorageImpl implements - ProxyGrantingTicketStorage { - - /** - * Default timeout in milliseconds. - */ - private static final long DEFAULT_TIMEOUT = 60000; - - private final Map cache = new HashMap(); - - /** - * Constructor set the timeout to the default value. - */ - public ProxyGrantingTicketStorageImpl() { - this(DEFAULT_TIMEOUT); - } - - /** - * Sets the amount of time to hold on to a ProxyGrantingTicket if its never - * been retrieved. - * - * @param timeout the time to hold on to the ProxyGrantingTicket - */ - public ProxyGrantingTicketStorageImpl(final long timeout) { - final Thread thread = new ProxyGrantingTicketCleanupThread( - timeout, this.cache); - thread.setDaemon(true); - thread.start(); - } - - /** - * NOTE: you can only retrieve a ProxyGrantingTicket once with this method. - * Its removed after retrieval. - */ - public String retrieve(final String proxyGrantingTicketIou) { - final ProxyGrantingTicketHolder holder = (ProxyGrantingTicketHolder) this.cache - .get(proxyGrantingTicketIou); - - if (holder == null) { - return null; - } - - this.cache.remove(holder); - - return holder.getProxyGrantingTicket(); - } - - public void save(final String proxyGrantingTicketIou, - final String proxyGrantingTicket) { - final ProxyGrantingTicketHolder holder = new ProxyGrantingTicketHolder( - proxyGrantingTicket); - - this.cache.put(proxyGrantingTicketIou, holder); - } - - private final class ProxyGrantingTicketHolder { - - private final String proxyGrantingTicket; - - private final long timeInserted; - - protected ProxyGrantingTicketHolder(final String proxyGrantingTicket) { - this.proxyGrantingTicket = proxyGrantingTicket; - this.timeInserted = System.currentTimeMillis(); - } - - public String getProxyGrantingTicket() { - return this.proxyGrantingTicket; - } - - final boolean isExpired(final long timeout) { - return System.currentTimeMillis() - this.timeInserted > timeout; - } - } - - private final class ProxyGrantingTicketCleanupThread extends Thread { - - private final long timeout; - - private final Map cache; - - public ProxyGrantingTicketCleanupThread(final long timeout, - final Map cache) { - this.timeout = timeout; - this.cache = cache; - } - - public void run() { - - while (true) { - try { - Thread.sleep(this.timeout); - } catch (final InterruptedException e) { - // nothing to do - } - - final List itemsToRemove = new ArrayList(); - - synchronized (this.cache) { - for (final Iterator iter = this.cache.keySet().iterator(); iter - .hasNext();) { - final Object key = iter.next(); - final ProxyGrantingTicketHolder holder = (ProxyGrantingTicketHolder) this.cache - .get(key); - - if (holder.isExpired(this.timeout)) { - itemsToRemove.add(key); - } - } - - for (final Iterator iter = itemsToRemove.iterator(); iter - .hasNext();) { - this.cache.remove(iter.next()); - } - } - } - } - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyRetriever.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyRetriever.java deleted file mode 100644 index bb69063..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/ProxyRetriever.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import org.jasig.cas.authentication.principal.Service; - -/** - * Interface to abstract the retrieval of a proxy ticket to make the - * implementation a black box to the client. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface ProxyRetriever { - - /** - * Retrieves a proxy ticket for a specific targetService. - * - * @param proxyGrantingTicketId the ProxyGrantingTicketId - * @param targetService the service we want to proxy. - * @return the ProxyTicket Id if Granted, null otherwise. - */ - String getProxyTicketIdFor(String proxyGrantingTicketId, - Service targetService); -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServlet.java b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServlet.java deleted file mode 100644 index 9074fd2..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServlet.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.WebApplicationContextUtils; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; -import java.util.Map; - -/** - * Implementation of an HttpServlet that accepts ProxyGrantingTicketIous and - * ProxyGrantingTickets and stores them in an implementation of - * {@link ProxyGrantingTicketStorage}. - *

- * Note that ProxyReceptorServlet attempts to load a - * {@link ProxyGrantingTicketStorage} from the ApplicationContext either via the - * name "proxyGrantingTicketStorage" or by type. One of these two must exist - * within the applicationContext or the initialization of the - * ProxyReceptorServlet will fail. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class SpringConfiguredProxyReceptorServlet extends - AbstractProxyReceptorServlet { - - /** - * Unique Id for serialization - */ - private static final long serialVersionUID = -5642050740265266568L; - - protected ProxyGrantingTicketStorage retrieveProxyGrantingTicketStorageFromConfiguration(final ServletConfig servletConfig) throws ServletException { - final WebApplicationContext context = WebApplicationContextUtils - .getRequiredWebApplicationContext(servletConfig.getServletContext()); - - if (context.containsBean(CONST_PROXY_GRANTING_TICKET_STORAGE_BEAN_NAME)) { - return (ProxyGrantingTicketStorage) context - .getBean(CONST_PROXY_GRANTING_TICKET_STORAGE_BEAN_NAME, - ProxyGrantingTicketStorage.class); - } - - final Map map = context - .getBeansOfType(ProxyGrantingTicketStorage.class); - - if (map.isEmpty()) { - throw new ServletException("No ProxyGrantingTicketStorage found!"); - } - - if (map.size() > 1) { - throw new ServletException( - "Expecting one ProxyGrantingTicketStorage and found multiple instances."); - } - - return (ProxyGrantingTicketStorage) map.get(map - .keySet().iterator().next()); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/package.html b/cas-client-core/src/main/java/org/jasig/cas/client/proxy/package.html deleted file mode 100644 index c3cbfc5..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/proxy/package.html +++ /dev/null @@ -1,7 +0,0 @@ - - -

The proxy package includes a servlet to act as a proxy receptor, - an interface for ProxyGrantingTicketStorage and an abstraction for - retrieving proxy tickets.

- - \ No newline at end of file diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java b/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java deleted file mode 100644 index 73e511b..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/CommonUtils.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.util; - -import java.util.Collection; - -/** - * Common utilities so that we don't need to include Commons Lang. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CommonUtils { - - private CommonUtils() { - // nothing to do - } - - /** - * Check whether the object is null or not. If it is, throw an exception and - * display the message. - * - * @param object the object to check. - * @param message the message to display if the object is null. - */ - public static void assertNotNull(final Object object, final String message) { - if (object == null) { - throw new IllegalArgumentException(message); - } - } - - /** - * Check whether the collection is null or empty. If it is, throw an - * exception and display the message. - * - * @param c the collecion to check. - * @param message the message to display if the object is null. - */ - public static void assertNotEmpty(final Collection c, final String message) { - assertNotNull(c, message); - if (c.isEmpty()) { - throw new IllegalArgumentException(message); - } - } - - /** - * Assert that the statement is true, otherwise throw an exception with the - * provided message. - * - * @param cond the codition to assert is true. - * @param message the message to display if the condition is not true. - */ - public static void assertTrue(final boolean cond, final String message) { - if (!cond) { - throw new IllegalArgumentException(message); - } - } - - /** - * Determines whether the String is null or of length 0. - * - * @param string the string to check - * @return true if its null or length of 0, false otherwise. - */ - public static boolean isEmpty(final String string) { - return string == null || string.length() == 0; - } - - /** - * Determines if the String is not empty. A string is not empty if it is not - * null and has a length > 0. - * - * @param string the string to check - * @return true if it is not empty, false otherwise. - */ - public static boolean isNotEmpty(final String string) { - return !isEmpty(string); - } - - /** - * Determines if a String is blank or not. A String is blank if its empty or - * if it only contains spaces. - * - * @param string the string to check - * @return true if its blank, false otherwise. - */ - public static boolean isBlank(final String string) { - return isEmpty(string) || string.trim().length() == 0; - } - - /** - * Determines if a string is not blank. A string is not blank if it contains - * at least one non-whitespace character. - * - * @param string the string to check. - * @return true if its not blank, false otherwise. - */ - public static boolean isNotBlank(final String string) { - return !isBlank(string); - } - -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/DelegatingFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/util/DelegatingFilter.java deleted file mode 100644 index 6a26bbf..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/DelegatingFilter.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; -import java.util.Iterator; -import java.util.Map; - -/** - * A Delegating Filter looks up a parameter in the request object and matches - * (either exact or using Regular Expressions) the value. If there is a match, - * the associated filter is executed. Otherwise, the normal chain is executed. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class DelegatingFilter implements Filter { - - /** - * Instance of Commons Logging. - */ - private final Log log = LogFactory.getLog(this.getClass()); - - /** - * The request parameter to look for in the Request object. - */ - private final String requestParameterName; - - /** - * The map of filters to delegate to and the criteria (as key). - */ - private final Map delegators; - - /** - * The default filter to use if there is no match. - */ - private final Filter defaultFilter; - - /** - * Whether the key in the delegators map is an exact match or a regular - * expression. - */ - private final boolean exactMatch; - - public DelegatingFilter(final String requestParameterName, final Map delegators, final boolean exactMatch) { - this(requestParameterName, delegators, exactMatch, null); - } - - public DelegatingFilter(final String requestParameterName, final Map delegators, final boolean exactMatch, final Filter defaultFilter) { - CommonUtils.assertNotNull(requestParameterName, - "requestParameterName cannot be null."); - CommonUtils.assertTrue(!delegators.isEmpty(), - "delegators cannot be empty."); - - for (final Iterator iter = delegators.keySet().iterator(); iter - .hasNext();) { - final Object object = delegators.get(iter.next()); - - if (!Filter.class.isAssignableFrom(object.getClass())) { - throw new IllegalArgumentException( - "All value objects in the delegators map must be filters."); - } - } - - this.requestParameterName = requestParameterName; - this.delegators = delegators; - this.defaultFilter = defaultFilter; - this.exactMatch = exactMatch; - } - - public void destroy() { - // nothing to do here - } - - public void doFilter(final ServletRequest request, - final ServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - - final String parameter = request - .getParameter(this.requestParameterName); - - if (CommonUtils.isNotEmpty(parameter)) { - for (final Iterator iter = this.delegators.keySet().iterator(); iter - .hasNext();) { - final String key = (String) iter.next(); - - if ((parameter.equals(key) && this.exactMatch) - || (parameter.matches(key) && !this.exactMatch)) { - final Filter filter = (Filter) this.delegators.get(key); - if (log.isDebugEnabled()) { - log.debug("Match found for parameter [" - + this.requestParameterName + "] with value [" - + parameter + "]. Delegating to filter [" - + filter.getClass().getName() + "]"); - } - filter.doFilter(request, response, filterChain); - return; - } - } - } - - log.debug("No match found for parameter [" + this.requestParameterName - + "] with value [" + parameter + "]"); - - if (this.defaultFilter != null) { - this.defaultFilter.doFilter(request, response, filterChain); - } else { - filterChain.doFilter(request, response); - } - } - - public void init(final FilterConfig filterConfig) throws ServletException { - // nothing to do here. - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/XmlUtils.java b/cas-client-core/src/main/java/org/jasig/cas/client/util/XmlUtils.java deleted file mode 100644 index 05892d6..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/XmlUtils.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.xml.sax.Attributes; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.DefaultHandler; -import org.xml.sax.helpers.XMLReaderFactory; - -import java.io.StringReader; -import java.util.ArrayList; -import java.util.List; - -/** - * Common utilities for easily parsing XML without duplicating logic. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class XmlUtils { - - /** - * Static instance of Commons Logging. - */ - private final static Log LOG = LogFactory.getLog(XmlUtils.class); - - /** - * Get an instance of an XML reader from the XMLReaderFactory. - * - * @return the XMLReader. - */ - public static XMLReader getXmlReader() { - try { - return XMLReaderFactory.createXMLReader(); - } catch (final SAXException e) { - throw new RuntimeException("Unable to create XMLReader", e); - } - } - - /** - * Retrieve the text for a group of elements. Each text element is an entry - * in a list. - * - * @param xmlAsString the xml response - * @param element the element to look for - * @return the list of text from the elements. - */ - public static List getTextForElements(final String xmlAsString, - final String element) { - // XXX: optimized to 2, as most proxy chains have a length of no more than two - final List elements = new ArrayList(2); - final XMLReader reader = getXmlReader(); - - final DefaultHandler handler = new DefaultHandler() { - - private boolean foundElement = false; - - private StringBuffer buffer = new StringBuffer(); - - public void startElement(final String uri, final String localName, - final String qName, final Attributes attributes) - throws SAXException { - if (localName.equals(element)) { - this.foundElement = true; - } - } - - public void endElement(final String uri, final String localName, - final String qName) throws SAXException { - if (localName.equals(element)) { - this.foundElement = false; - elements.add(this.buffer.toString()); - this.buffer = new StringBuffer(); - } - } - - public void characters(char[] ch, int start, int length) - throws SAXException { - if (this.foundElement) { - this.buffer.append(ch, start, length); - } - } - }; - - reader.setContentHandler(handler); - reader.setErrorHandler(handler); - - try { - reader.parse(new InputSource(new StringReader(xmlAsString))); - } catch (final Exception e) { - LOG.error(e, e); - return null; - } - - return elements; - } - - /** - * Retrieve the text for a specific element (when we know there is only - * one). - * - * @param xmlAsString the xml response - * @param element the element to look for - * @return the text value of the element. - */ - public static String getTextForElement(final String xmlAsString, - final String element) { - final XMLReader reader = getXmlReader(); - final StringBuffer buffer = new StringBuffer(); - - final DefaultHandler handler = new DefaultHandler() { - - private boolean foundElement = false; - - public void startElement(final String uri, final String localName, - final String qName, final Attributes attributes) - throws SAXException { - if (localName.equals(element)) { - this.foundElement = true; - } - } - - public void endElement(final String uri, final String localName, - final String qName) throws SAXException { - if (localName.equals(element)) { - this.foundElement = false; - } - } - - public void characters(char[] ch, int start, int length) - throws SAXException { - if (this.foundElement) { - buffer.append(ch, start, length); - } - } - }; - - reader.setContentHandler(handler); - reader.setErrorHandler(handler); - - try { - reader.parse(new InputSource(new StringReader(xmlAsString))); - } catch (final Exception e) { - LOG.error(e, e); - return null; - } - - return buffer.toString(); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/util/package.html b/cas-client-core/src/main/java/org/jasig/cas/client/util/package.html deleted file mode 100644 index d6d6b49..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/util/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

The validation package includes interfaces for validating Tickets, as well as the common implementations.

- - diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AbstractUrlBasedTicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/AbstractUrlBasedTicketValidator.java deleted file mode 100644 index f047f70..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AbstractUrlBasedTicketValidator.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.jasig.cas.client.validation; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.methods.GetMethod; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.util.CommonUtils; - -import java.net.URLEncoder; - -/** - * Abstract class for validating tickets that defines a workflow that all ticket - * validation should follow. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractUrlBasedTicketValidator implements - TicketValidator { - - /** - * Instance of Commons Logging. - */ - protected final Log log = LogFactory.getLog(this.getClass()); - - /** - * Url to CAS server. Generally of the form https://server:port/cas/ - */ - private final String casServerUrl; - - /** - * Whether this client is looking for an authentication from renew. - */ - private final boolean renew; - - /** - * Instance of HttpClient for connecting to server. Care should be taken only inject a multi-threaded HttpClient. - */ - private final HttpClient httpClient; - - public final Assertion validate(final String ticketId, final Service service) - throws ValidationException { - final String url = constructURL(ticketId, service); - final String response = getResponseFromURL(url); - - return parseResponse(response); - } - - /** - * Constructs the URL endpoint for contacting CAS for ticket validation. - * - * @param ticketId the opaque ticket id. - * @param service the service we are validating for. - * @return the fully constructed url. - */ - protected abstract String constructURL(final String ticketId, - final Service service); - - /** - * Parses the response retrieved from the url endpoint. - * - * @param response the String response. - * @return an Assertion based on the response. - * @throws ValidationException if there was an error validating the ticket. - */ - protected abstract Assertion parseResponse(final String response) - throws ValidationException; - - private String getResponseFromURL(final String url) - throws ValidationException { - final GetMethod method = new GetMethod(url); - - try { - this.httpClient.executeMethod(method); - return method.getResponseBodyAsString(); - } catch (Exception e) { - log.error(e, e); - throw new ValidationException( - "Unable to retrieve response from CAS Server.", e); - } finally { - method.releaseConnection(); - } - } - - protected AbstractUrlBasedTicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient) { - CommonUtils.assertNotNull(casServerUrl, - "the validationUrl cannot be null"); - CommonUtils - .assertNotNull(httpClient, "httpClient cannot be null."); - this.casServerUrl = casServerUrl; - this.renew = renew; - this.httpClient = httpClient; - } - - /** - * Helper method to encode the service url. - * - * @param value the String to encode. - * @return the encoded String. - */ - protected final String urlEncode(final String value) { - try { - return URLEncoder.encode(value, "UTF-8"); - } catch (final Exception e) { - throw new RuntimeException(e); - } - } - - protected final String getCasServerUrl() { - return this.casServerUrl; - } - - protected final boolean isRenew() { - return this.renew; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Assertion.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Assertion.java deleted file mode 100644 index a751be5..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Assertion.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.authentication.principal.Service; - -import java.io.Serializable; -import java.util.Map; - -/** - * Interface to represent a successful response from the CAS Server. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface Assertion extends Serializable { - - /** - * Method to retrieve the principal. - * - * @return the principal. - */ - Principal getPrincipal(); - - /** - * Map of attributes returned by the CAS server. A client must know what - * attributes he is looking for as CAS makes no claims about what attributes - * are returned. - * - * @return the map of attributes. - */ - Map getAttributes(); - - /** - * Retrieves a proxy ticket for the specific service. - * - * @param service The service to proxy to. - * @return the Proxy Ticket Id or null. - */ - String getProxyTicketFor(Service service); -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionHolder.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionHolder.java deleted file mode 100644 index 26f877e..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionHolder.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -/** - * Static holder that places Assertion in a threadlocal. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class AssertionHolder { - - /** - * ThreadLocal to hold the Assertion for Threads to access. - */ - private static final ThreadLocal threadLocal = new ThreadLocal(); - - - /** - * Retrieve the assertion from the ThreadLocal. - */ - public static Assertion getAssertion() { - return (Assertion) threadLocal.get(); - } - - /** - * Add the Assertion to the ThreadLocal. - */ - public static void setAssertion(final Assertion assertion) { - threadLocal.set(assertion); - } - - /** - * Clear the ThreadLocal. - */ - public static void clear() { - threadLocal.set(null); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionImpl.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionImpl.java deleted file mode 100644 index a305a7c..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/AssertionImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.proxy.ProxyRetriever; -import org.jasig.cas.client.util.CommonUtils; - -import java.util.HashMap; -import java.util.Map; - -/** - * Concrete implementation of an Assertion. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class AssertionImpl implements Assertion { - - /** - * Unique id for serialization. - */ - private static final long serialVersionUID = 1L; - - /** - * Map of the attributes returned by the CAS server. This is optional as the - * CAS server spec makes no mention of attributes. - */ - private final Map attributes; - - /** - * The principal who was authenticated. - */ - private final Principal principal; - - /** - * The Proxy Granting Ticket Id returned by the server. - */ - private final String proxyGrantingTicketId; - - /** - * Reference to ProxyRetriever so that clients can retrieve proxy tickets for a service. - */ - private final ProxyRetriever proxyRetriever; - - - /** - * Simple constructor that accepts a Principal. - * - * @param principal the Principal this assertion is for. - */ - public AssertionImpl(final Principal principal) { - this(principal, null, null, null); - } - - /** - * Constructor that accepts a Principal and a map of attributes. - * - * @param principal the Principal this assertion is for. - * @param attributes a map of attributes about the principal. - */ - public AssertionImpl(final Principal principal, final Map attributes) { - this(principal, attributes, null, null); - } - - /** - * @param principal the Principal this assertion is for. - * @param attributes a map of attributes about the principal. - * @param proxyRetriever used to retrieve proxy tickets from CAS Server. - * @param proxyGrantingTicketId the Id to use to request proxy tickets. - */ - public AssertionImpl(final Principal principal, final Map attributes, - final ProxyRetriever proxyRetriever, final String proxyGrantingTicketId) { - CommonUtils.assertNotNull(principal, "principal cannot be null"); - - this.principal = principal; - this.attributes = attributes == null ? new HashMap() : attributes; - this.proxyGrantingTicketId = CommonUtils - .isNotEmpty(proxyGrantingTicketId) ? proxyGrantingTicketId : null; - this.proxyRetriever = proxyRetriever; - } - - public final Map getAttributes() { - return this.attributes; - } - - public String getProxyTicketFor(final Service service) { - if (proxyRetriever == null || proxyGrantingTicketId == null) { - return null; - } - - return this.proxyRetriever.getProxyTicketIdFor(this.proxyGrantingTicketId, service); - } - - public final Principal getPrincipal() { - return this.principal; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas10TicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas10TicketValidator.java deleted file mode 100644 index b82a1a9..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas10TicketValidator.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimplePrincipal; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.StringReader; - -/** - * Implementation of TicketValidator that follows the CAS 1.0 protocol. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class Cas10TicketValidator extends AbstractUrlBasedTicketValidator { - - public Cas10TicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient) { - super(casServerUrl, renew, httpClient); - } - - protected String constructURL(final String ticketId, final Service service) { - return getCasServerUrl() + "validate?ticket=" + ticketId - + (isRenew() ? "&renew=true" : "") + "&service=" - + urlEncode(service.getId()); - } - - protected final Assertion parseResponse(final String response) - throws ValidationException { - if (response == null || "no\n\n".equals(response) - || !response.startsWith("yes")) { - throw new ValidationException( - "'No' response returned from server for validation request."); - } - - try { - final BufferedReader reader = new BufferedReader(new StringReader( - response)); - reader.readLine(); - - final Principal principal = new SimplePrincipal(reader.readLine()); - return new AssertionImpl(principal, null); - } catch (final IOException e) { - throw new ValidationException("Unable to parse response.", e); - } - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidator.java deleted file mode 100644 index 2c86e82..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidator.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; -import org.jasig.cas.client.proxy.ProxyRetriever; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.util.XmlUtils; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -/** - * Implementation of the TicketValidator interface that knows how to handle - * proxy tickets. - *

- * In your XML configuration file, proxy chains should be defined as - * follows: <list> <value> proxy1 proxy2 proxy3</value> - * <value> proxy2 proxy4 proxy5</value> <value> proxy4 - * proxy5 proxy6</value> </list> - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class Cas20ProxyTicketValidator extends Cas20ServiceTicketValidator { - - /* List of proxy chains that we accept. */ - private final List proxyChains; - - /** - * Boolean whether we accept any proxy request or not. - */ - private final boolean acceptAnyProxy; - - /** - * @param casServerUrl the url to the CAS server, minus the endpoint. - * @param renew flag for whether we require authentication to be via an initial authentication. - * @param httpClient an instance of HttpClient to do the calls. - * @param proxyChains the chains of proxy lists that we accept tickets from. - * @param acceptAnyProxy flag on whether we accept any proxy or not. - */ - public Cas20ProxyTicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient, List proxyChains, boolean acceptAnyProxy) { - this(casServerUrl, renew, httpClient, null, proxyChains, acceptAnyProxy, null, null); - } - - public Cas20ProxyTicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient, final Service proxyCallbackUrl, List proxyChains, boolean acceptAnyProxy, final ProxyGrantingTicketStorage proxyGrantingTicketStorage, final ProxyRetriever proxyRetriever) { - super(casServerUrl, renew, httpClient, proxyCallbackUrl, proxyGrantingTicketStorage, proxyRetriever); - - CommonUtils.assertTrue(proxyChains != null || acceptAnyProxy, - "proxyChains cannot be null or acceptAnyProxy must be true."); - CommonUtils.assertTrue((proxyChains != null && !proxyChains - .isEmpty()) - || acceptAnyProxy, - "proxyChains cannot be empty or acceptAnyProxy must be true."); - - // assume each proxy chain has a length of 2 - final List tempProxyChains = new ArrayList(proxyChains.size() * 2); - for (final Iterator iter = proxyChains.iterator(); iter.hasNext();) { - final String[] values = ((String) iter.next()).split(" "); - final Service[] principals = new Service[values.length]; - - for (int i = 0; i < principals.length; i++) { - principals[i] = new SimpleService(values[i]); - } - - tempProxyChains.add(principals); - } - - this.proxyChains = tempProxyChains; - this.acceptAnyProxy = acceptAnyProxy; - } - - protected String getValidationUrlName() { - return "proxyValidate"; - } - - - protected Assertion getValidAssertionInternal(final String response, final String principal, final String proxyGrantingTicketIou) throws ValidationException { - final List proxies = XmlUtils.getTextForElements(response, "proxy"); - - // this means there was nothing in the proxy chain, which is okay - if (proxies.isEmpty() || this.acceptAnyProxy) { - return getAssertionBasedOnProxyGrantingTicketIou(proxyGrantingTicketIou, principal); - } - - final Service[] principals = new Service[proxies.size()]; - int i = 0; - for (final Iterator iter = proxies.iterator(); iter.hasNext();) { - principals[i++] = new SimpleService((String) iter.next()); - } - - for (Iterator iter = this.proxyChains.iterator(); iter.hasNext();) { - if (Arrays.equals(principals, (Object[]) iter.next())) { - return getAssertionBasedOnProxyGrantingTicketIou(proxyGrantingTicketIou, principal); - } - } - - throw new InvalidProxyChainValidationException(); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java deleted file mode 100644 index 54d5138..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidator.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; -import org.jasig.cas.client.proxy.ProxyRetriever; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.util.XmlUtils; - -/** - * Implementation of TicketValidator that follows the CAS 2.0 protocol (without - * proxying). - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class Cas20ServiceTicketValidator extends - AbstractUrlBasedTicketValidator { - - /** - * Proxy callback url to send to the CAS server. - */ - private final Service proxyCallbackUrl; - - /** - * The storage mechanism for the ProxyGrantingTickets. - */ - private final ProxyGrantingTicketStorage proxyGrantingTicketStorage; - - /** - * Injected into Assertions to allow them to retrieve proxy tickets. - */ - private final ProxyRetriever proxyRetriever; - - public Cas20ServiceTicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient) { - this(casServerUrl, renew, httpClient, null, null, null); - } - - public Cas20ServiceTicketValidator(final String casServerUrl, final boolean renew, final HttpClient httpClient, final Service proxyCallbackUrl, final ProxyGrantingTicketStorage proxyGrantingTicketStorage, final ProxyRetriever proxyRetriever) { - super(casServerUrl, renew, httpClient); - - if (proxyCallbackUrl != null) { - CommonUtils.assertNotNull(proxyGrantingTicketStorage, - "proxyGrantingTicketStorage cannot be null"); - CommonUtils.assertNotNull(proxyRetriever, "proxyRetriever cannot be null."); - } - this.proxyCallbackUrl = proxyCallbackUrl; - this.proxyGrantingTicketStorage = proxyGrantingTicketStorage; - this.proxyRetriever = proxyRetriever; - } - - protected String constructURL(final String ticketId, - final Service service) { - return getCasServerUrl() - + getValidationUrlName() - + "?ticket=" - + ticketId - + (isRenew() ? "&renew=true" : "") - + "&service=" - + urlEncode(service.getId()) - + (this.proxyCallbackUrl != null ? "&pgtUrl=" - + urlEncode(this.proxyCallbackUrl.getId()) : ""); - } - - protected final Assertion parseResponse(final String response) - throws ValidationException { - - final String error = XmlUtils.getTextForElement(response, - "authenticationFailure"); - - if (CommonUtils.isNotBlank(error)) { - log.debug("Validation of ticket failed: " + error); - throw new ValidationException(error); - } - - final String principal = XmlUtils.getTextForElement(response, "user"); - final String proxyGrantingTicketIou = XmlUtils.getTextForElement( - response, "proxyGrantingTicket"); - - if (CommonUtils.isEmpty(principal)) { - throw new ValidationException("No principal found."); - } - - return getValidAssertionInternal(response, principal, proxyGrantingTicketIou); - } - - protected String getValidationUrlName() { - return "serviceValidate"; - } - - protected final Assertion getAssertionBasedOnProxyGrantingTicketIou(final String proxyGrantingTicketIou, final String principal) { - if (CommonUtils.isNotBlank(proxyGrantingTicketIou)) { - return new AssertionImpl( - new SimplePrincipal(principal), null, this.proxyRetriever, this.proxyGrantingTicketStorage == null ? null : this.proxyGrantingTicketStorage - .retrieve(proxyGrantingTicketIou)); - } else { - return new AssertionImpl(new SimplePrincipal(principal)); - } - } - - protected Assertion getValidAssertionInternal(final String response, final String principal, final String proxyGrantingTicketIou) throws ValidationException { - return getAssertionBasedOnProxyGrantingTicketIou(proxyGrantingTicketIou, principal); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/InvalidProxyChainValidationException.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/InvalidProxyChainValidationException.java deleted file mode 100644 index 00a9440..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/InvalidProxyChainValidationException.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -/** - * Specific instance of a ValidationException that is thrown when the proxy - * chain does not match what is returned. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class InvalidProxyChainValidationException extends ValidationException { - - /** - * Unique id for serialization. - */ - private static final long serialVersionUID = 1L; - - public InvalidProxyChainValidationException() { - super(); - } - - public InvalidProxyChainValidationException(String message) { - super(message); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Saml10TicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/Saml10TicketValidator.java deleted file mode 100644 index 556f0a7..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/Saml10TicketValidator.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.jasig.cas.client.validation; - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.AttributePrincipal; -import org.jasig.cas.authentication.principal.SimpleAttributePrincipal; -import org.opensaml.SAMLAssertion; -import org.opensaml.SAMLAttribute; -import org.opensaml.SAMLAttributeStatement; -import org.opensaml.SAMLAuthenticationStatement; -import org.opensaml.SAMLException; -import org.opensaml.SAMLResponse; -import org.opensaml.SAMLStatement; -import org.opensaml.SAMLSubject; - -import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.net.URLEncoder; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.1 - */ -public class Saml10TicketValidator extends AbstractUrlBasedTicketValidator { - - /** - * Number of milliseconds the client/server clocks can be off by. - */ - private final long tolerance; - - public Saml10TicketValidator(final String casServerUrl, final HttpClient httpClient) { - super(casServerUrl, false, httpClient); - this.tolerance = 1000L; - } - - public Saml10TicketValidator(final String casServerUrl, final HttpClient httpClient, final long tolerance) { - super(casServerUrl, false, httpClient); - this.tolerance = tolerance; - } - - - protected String constructURL(final String ticketId, final Service service) { - return getCasServerUrl() + "/samlValidate?SAMLart=" + urlEncode(ticketId) + "&TARGET=" + urlEncode(service.getId()); - } - - protected Assertion parseResponse(final String response) throws ValidationException { - try { - log.debug(response); - final SAMLResponse samlResponse = new SAMLResponse(new ByteArrayInputStream(response.getBytes())); - - // check to see if we have any assertions - if (!samlResponse.getAssertions().hasNext()) { - throw new ValidationException("No assertions found."); - } - - for (final Iterator iter = samlResponse.getAssertions(); iter.hasNext();) { - final SAMLAssertion assertion = (SAMLAssertion) iter.next(); - - if (!isValidAssertion(assertion)) { - continue; - } - - final SAMLAuthenticationStatement authenticationStatement = getSAMLAuthenticationStatement(assertion); - - if (authenticationStatement == null) { - throw new ValidationException("No AuthentiationStatement found in SAML Assertion."); - } - final SAMLSubject subject = authenticationStatement.getSubject(); - - if (subject == null) { - throw new ValidationException("No Subject found in SAML Assertion."); - } - - final SAMLAttribute[] attributes = getAttributesFor(assertion, subject); - - final Map personAttributes = new HashMap(); - - for (int i = 0; i < attributes.length; i++) { - final SAMLAttribute samlAttribute = attributes[i]; - final List values = getValuesFrom(samlAttribute); - - personAttributes.put(samlAttribute.getName(), values.size() == 1 ? values.get(0) : values); - } - - final AttributePrincipal principal = new SimpleAttributePrincipal(subject.getNameIdentifier().getName(), personAttributes); - - - final Map authenticationAttributes = new HashMap(); - authenticationAttributes.put("samlAuthenticationStatement::authMethod", authenticationStatement.getAuthMethod()); - - final Assertion casAssertion = new AssertionImpl(principal, authenticationAttributes); - return casAssertion; - } - } catch (final SAMLException e) { - log.error(e,e); - throw new ValidationException(e); - } - - throw new ValidationException("No valid assertions from the SAML response found."); - } - - private boolean isValidAssertion(final SAMLAssertion assertion) { - final Date notBefore = assertion.getNotBefore(); - final Date notOnOrAfter = assertion.getNotOnOrAfter(); - - if (assertion.getNotBefore() == null || assertion.getNotOnOrAfter() == null) { - log.debug("Assertion has no bounding dates. Will not process."); - return false; - } - - final long currentTime = new Date().getTime(); - - if (currentTime + tolerance < notBefore.getTime()) { - log.debug("skipping assertion that's not yet valid..."); - return false; - } - - if (notOnOrAfter.getTime() <= currentTime - tolerance) { - log.debug("skipping expired assertion..."); - return false; - } - - return true; - } - - private SAMLAuthenticationStatement getSAMLAuthenticationStatement(final SAMLAssertion assertion) { - for (final Iterator iter = assertion.getStatements(); iter.hasNext();) { - final SAMLStatement statement = (SAMLStatement) iter.next(); - - if (statement instanceof SAMLAuthenticationStatement) { - return (SAMLAuthenticationStatement) statement; - } - } - - return null; - } - - private SAMLAttribute[] getAttributesFor(final SAMLAssertion assertion, final SAMLSubject subject) { - final List attributes = new ArrayList(); - for (final Iterator iter = assertion.getStatements(); iter.hasNext();) { - final SAMLStatement statement = (SAMLStatement) iter.next(); - - if (statement instanceof SAMLAttributeStatement) { - final SAMLAttributeStatement attributeStatement = (SAMLAttributeStatement) statement; - // used because SAMLSubject does not implement equals - if (subject.getNameIdentifier().getName().equals(attributeStatement.getSubject().getNameIdentifier().getName())) { - for (final Iterator iter2 = attributeStatement.getAttributes(); iter2.hasNext();) - attributes.add(iter2.next()); - } - } - } - - return (SAMLAttribute[]) attributes.toArray(new SAMLAttribute[attributes.size()]); - } - - private List getValuesFrom(final SAMLAttribute attribute) { - final List list = new ArrayList(); - for (final Iterator iter = attribute.getValues(); iter.hasNext();) { - list.add(iter.next()); - } - - return list; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/TicketValidator.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/TicketValidator.java deleted file mode 100644 index 5686aea..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/TicketValidator.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import org.jasig.cas.authentication.principal.Service; - -/** - * Interface to encapsulate the validation of a ticket. The inteface is - * specification neutral. Any implementation can be provided, including - * something that parses CAS1 or CAS2 responses. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface TicketValidator { - - /** - * Method to validate a ticket for a give Service. - * - * @param ticketId the ticket to validate - * @param service the service to validate the ticket for - * @return the Assertion about the ticket (never null) - * @throws ValidationException if there is a problem validating the ticket. - */ - Assertion validate(String ticketId, Service service) - throws ValidationException; -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/ValidationException.java b/cas-client-core/src/main/java/org/jasig/cas/client/validation/ValidationException.java deleted file mode 100644 index 0311a7c..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/ValidationException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -/** - * Implementation of Exception to be thrown when there is an error validating - * the Ticket returned from the CAS server. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class ValidationException extends Exception { - - /** - * Unique Id for serialization. - */ - private static final long serialVersionUID = 1L; - - /** - * Default constructor. - */ - public ValidationException() { - super(); - } - - /** - * Constructor that accepts a message and a chained exception. - * - * @param message the error message. - * @param cause the exception we are chaining with. - */ - public ValidationException(final String message, final Throwable cause) { - super(message, cause); - } - - /** - * Constructor that accepts a message. - * - * @param message the error message. - */ - public ValidationException(final String message) { - super(message); - } - - /** - * Constructor that accepts a chained exception. - * - * @param cause the exception we are chaining with. - */ - public ValidationException(final Throwable cause) { - super(cause); - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/validation/package.html b/cas-client-core/src/main/java/org/jasig/cas/client/validation/package.html deleted file mode 100644 index e272813..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/validation/package.html +++ /dev/null @@ -1,5 +0,0 @@ - - -

This package contains common utilities used within the CAS client classes.

- - diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AbstractCasFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AbstractCasFilter.java deleted file mode 100644 index 03056b9..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AbstractCasFilter.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.web.support.ArgumentExtractor; -import org.jasig.cas.web.support.CasArgumentExtractor; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Abstract class that contains common functionality amongst CAS filters. - *

- * You must specify the serverName (format: hostname:port) or the serviceUrl. If you specify both, the - * serviceUrl is used over the serverName. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractCasFilter implements Filter { - - /** - * Constant representing where we store the Assertion in the - * session. - */ - public static final String CONST_ASSERTION = "_cas_assertion_"; - - /** - * Constant representing where we flag a gatewayed request in the session. - */ - public static final String CONST_GATEWAY = "_cas_gateway_"; - - /** - * Constant representing where we flag a principal. - */ - public static final String CONST_PRINCIPAL = "_cas_principal_"; - - /** - * Instance of Commons Logging. - */ - protected final Log log = LogFactory.getLog(this.getClass()); - - /** - * The name of the server in the following format: : where - * port is optional if its a standard port. - */ - private final String service; - - /** - * The exact service url to match to. - */ - private final boolean isServerName; - - /** - * Whether to store the entry in session or not. Defaults to true. - */ - private boolean useSession = true; - - /** Instance of an ArgumentExtractor to retrieve arguments based on supported protocol. Default is the CAS 2 protocol. */ - private ArgumentExtractor argumentExtractor = new CasArgumentExtractor(); - - - protected AbstractCasFilter(final String service, final boolean isServerName) { - CommonUtils.assertNotNull(service, "service must be set"); - - this.service = service; - this.isServerName = isServerName; - - log.info("Service set to: " + this.service + "; Is Server Name? set to: " + this.isServerName + "Use Session set to: " + this.useSession); - } - - public final void destroy() { - // nothing to do - } - - public final void doFilter(final ServletRequest servletRequest, - final ServletResponse servletResponse, final FilterChain filterChain) - throws IOException, ServletException { - doFilterInternal((HttpServletRequest) servletRequest, - (HttpServletResponse) servletResponse, filterChain); - } - - protected abstract void doFilterInternal(HttpServletRequest request, - HttpServletResponse response, FilterChain filterChain) - throws IOException, ServletException; - - public void init(final FilterConfig filterConfig) throws ServletException { - // nothing to do here - } - - /** - * Constructs a service url from the HttpServletRequest or from the given - * serviceUrl. Prefers the serviceUrl provided if both a serviceUrl and a - * serviceName. - * - * @param request the HttpServletRequest - * @param response the HttpServletResponse - * @return the service url to use. - */ - protected final String constructServiceUrl(final HttpServletRequest request, - final HttpServletResponse response) { - if (!isServerName) { - return response.encodeURL(this.service); - } - - final StringBuffer buffer = new StringBuffer(); - - synchronized (buffer) { - buffer.append(request.isSecure() ? "https://" : "http://"); - buffer.append(this.service); - buffer.append(request.getRequestURI()); - - if (CommonUtils.isNotBlank(request.getQueryString())) { - final int location = request.getQueryString().indexOf( - this.argumentExtractor.getArtifactParameterName() + "="); - - if (location == 0) { - final String returnValue = response.encodeURL(buffer - .toString()); - if (log.isDebugEnabled()) { - log.debug("serviceUrl generated: " + returnValue); - } - return returnValue; - } - - buffer.append("?"); - - if (location == -1) { - buffer.append(request.getQueryString()); - } else if (location > 0) { - final int actualLocation = request.getQueryString() - .indexOf("&" + this.argumentExtractor.getArtifactParameterName() + "="); - - if (actualLocation == -1) { - buffer.append(request.getQueryString()); - } else if (actualLocation > 0) { - buffer.append(request.getQueryString().substring(0, - actualLocation)); - } - } - } - } - - final String returnValue = response.encodeURL(buffer.toString()); - if (log.isDebugEnabled()) { - log.debug("serviceUrl generated: " + returnValue); - } - return returnValue; - } - - protected final boolean isUseSession() { - return this.useSession; - } - - public final void setUseSession(final boolean useSession) { - this.useSession = useSession; - } - - - protected ArgumentExtractor getArgumentExtractor() { - return this.argumentExtractor; - } - - public void setArgumentExtractor(final ArgumentExtractor argumentExtractor) { - CommonUtils.assertNotNull(argumentExtractor, "argumentExtractor cannot be null."); - this.argumentExtractor = argumentExtractor; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AssertionThreadLocalFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AssertionThreadLocalFilter.java deleted file mode 100644 index 0530ec1..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AssertionThreadLocalFilter.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.AssertionHolder; -import org.springframework.web.util.WebUtils; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; - -/** - * Places the assertion in a ThreadLocal such that other resources can access it that do not have access to the web tier session. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AssertionThreadLocalFilter implements Filter { - - public void init(final FilterConfig filterConfig) throws ServletException { - // nothing to do here - } - - public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException { - final HttpServletRequest request = (HttpServletRequest) servletRequest; - final Assertion assertion = (Assertion) WebUtils - .getSessionAttribute(request, - AbstractCasFilter.CONST_ASSERTION); - - try { - AssertionHolder.setAssertion(assertion); - filterChain.doFilter(servletRequest, servletResponse); - } finally { - AssertionHolder.clear(); - } - } - - public void destroy() { - // nothing to do - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthenticationFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthenticationFilter.java deleted file mode 100644 index c90dd34..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthenticationFilter.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.validation.Assertion; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import java.io.IOException; -import java.net.URLEncoder; - -/** - * Filter implementation to intercept all requests and attempt to authenticate - * the user by redirecting them to CAS (unless the user has a ticket). - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AuthenticationFilter extends AbstractCasFilter { - - /** - * The URL to the CAS Server login. - */ - private final String casServerLoginUrl; - - /** - * Whether to send the renew request or not. - */ - private boolean renew = false; - - /** - * Whether to send the gateway request or not. - */ - private boolean gateway = false; - - public AuthenticationFilter(final String serverName, final boolean isServerName, String casServerLoginUrl) { - super(serverName, isServerName); - CommonUtils.assertNotNull(casServerLoginUrl, - "the CAS Server Login URL cannot be null."); - this.casServerLoginUrl = casServerLoginUrl; - } - - protected void doFilterInternal(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - final HttpSession session = request.getSession(isUseSession()); - final String ticket = request.getParameter(getArgumentExtractor().getArtifactParameterName()); - final Assertion assertion = session != null ? (Assertion) session - .getAttribute(CONST_ASSERTION) : null; - final boolean wasGatewayed = session != null - && session.getAttribute(CONST_GATEWAY) != null; - - if (CommonUtils.isBlank(ticket) && assertion == null && !wasGatewayed) { - log.debug("no ticket and no assertion found"); - if (this.gateway && session != null) { - log.debug("setting gateway attribute in session"); - session.setAttribute(CONST_GATEWAY, "yes"); - } - - final String serviceUrl = constructServiceUrl(request, response); - final String urlToRedirectTo = this.casServerLoginUrl + "?" + getArgumentExtractor().getServiceParameterName() + "=" - + URLEncoder.encode(serviceUrl, "UTF-8") - + (this.renew ? "&renew=true" : "") - + (this.gateway ? "&gateway=true" : ""); - - if (log.isDebugEnabled()) { - log.debug("redirecting to \"" + urlToRedirectTo + "\""); - } - - response.sendRedirect(urlToRedirectTo); - return; - } - - if (session != null) { - log.debug("removing gateway attribute from session"); - session.setAttribute(CONST_GATEWAY, null); - } - - filterChain.doFilter(request, response); - } - - public void setRenew(final boolean renew) { - this.renew = renew; - } - - public void setGateway(final boolean gateway) { - this.gateway = gateway; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthorizationFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthorizationFilter.java deleted file mode 100644 index 0436b87..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/AuthorizationFilter.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.client.authorization.AuthorizationException; -import org.jasig.cas.client.authorization.AuthorizedDecider; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.validation.Assertion; -import org.springframework.web.util.WebUtils; -import org.apache.commons.logging.LogFactory; -import org.apache.commons.logging.Log; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Simple filter that attempts to determine if someone is authorized to use the - * system. Assumes that you are protecting the application with the - * AuthenticationFilter such that the Assertion is set in the session. - *

- * If a user is not authorized to use the application, the response code of 403 - * will be sent to the browser. - *

- * This filter needs to be configured after both the authentication filter and - * the validation filter. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @see AuthorizedDecider - * @since 3.0 - */ -public final class AuthorizationFilter implements Filter { - - - /** - * Instance of Commons Logging. - */ - private final Log log = LogFactory.getLog(this.getClass()); - - /** - * Decider that determines whether a specified principal has access to the - * resource or not. - */ - private final AuthorizedDecider decider; - - /** - * @param casAuthorizedDecider the thing actually deciding to grant access or not. - */ - public AuthorizationFilter(final AuthorizedDecider casAuthorizedDecider) { - CommonUtils.assertNotNull(casAuthorizedDecider, - "the casAuthorizedDecider cannot be null."); - this.decider = casAuthorizedDecider; - } - - public void destroy() { - // nothing to do here - } - - public void doFilter(final ServletRequest servletRequest, - final ServletResponse servletResponse, final FilterChain filterChain) - throws IOException, ServletException { - final HttpServletRequest request = (HttpServletRequest) servletRequest; - final HttpServletResponse response = (HttpServletResponse) servletResponse; - final Assertion assertion = (Assertion) WebUtils.getRequiredSessionAttribute(request, AbstractCasFilter.CONST_ASSERTION); - final Principal principal = assertion.getPrincipal(); - - final boolean authorized = this.decider - .isAuthorizedToUseApplication(principal); - - if (!authorized) { - log.debug("User not authorized to access application."); - response.setStatus(HttpServletResponse.SC_FORBIDDEN); - throw new AuthorizationException(principal.getId() - + " is not authorized to use this application."); - } - - log.debug("User successfully authorized."); - filterChain.doFilter(servletRequest, servletResponse); - } - - public void init(final FilterConfig filterConfig) throws ServletException { - // nothing to do here - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilter.java deleted file mode 100644 index 9aac42c..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilter.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.jasig.cas.client.validation.Assertion; -import org.springframework.web.util.WebUtils; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import java.io.IOException; - -/** - * Implementation of a filter that wraps the normal HttpServletRequest with a - * wrapper that overrides the getRemoteUser method to retrieve the user from the - * CAS Assertion. - *

- * This filter needs to be configured in the chain so that it executes after - * both the authentication and the validation filters. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class HttpServletRequestWrapperFilter implements Filter { - - public void destroy() { - // nothing to do - } - - /** - * Wraps the HttpServletRequest in a wrapper class that delegates - * request.getRemoteUser to the underlying Assertion object - * stored in the user session. - */ - public void doFilter(final ServletRequest servletRequest, - final ServletResponse servletResponse, final FilterChain filterChain) - throws IOException, ServletException { - filterChain.doFilter(new CasHttpServletRequestWrapper( - (HttpServletRequest) servletRequest), servletResponse); - } - - public void init(final FilterConfig filterConfig) throws ServletException { - // nothing to do - } - - final class CasHttpServletRequestWrapper extends HttpServletRequestWrapper { - - CasHttpServletRequestWrapper(final HttpServletRequest request) { - super(request); - } - - public String getRemoteUser() { - final org.jasig.cas.authentication.principal.Principal p = (org.jasig.cas.authentication.principal.Principal) this - .getAttribute(AbstractCasFilter.CONST_PRINCIPAL); - - if (p != null) { - return p.getId(); - } - - final Assertion assertion = (Assertion) WebUtils - .getSessionAttribute(this, - AbstractCasFilter.CONST_ASSERTION); - - if (assertion != null) { - return assertion.getPrincipal().getId(); - } - - return null; - } - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/TicketValidationFilter.java b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/TicketValidationFilter.java deleted file mode 100644 index d3aef0d..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/TicketValidationFilter.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.TicketValidator; -import org.jasig.cas.client.validation.ValidationException; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Implementation of a Filter that checks for a "ticket" and if one is found, - * will attempt to validate the ticket. On a successful validation, it sets the - * Assertion object into the session. On an unsuccessful validation attempt, it - * sets the response code to 403. - *

- * This filter needs to be configured after the authentication filter (if that - * filter exists in the chain). - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @see TicketValidator - * @since 3.0 - */ -public final class TicketValidationFilter extends AbstractCasFilter { - - /** - * Instance of the ticket validator. - */ - private final TicketValidator ticketValidator; - - /** - * Specify whether the filter should redirect the user agent after a - * successful validation to remove the ticket parameter from the query - * string. - */ - private boolean redirectAfterValidation = false; - - /** Determines whether an exception is thrown when there is a ticket validation failure. */ - private boolean exceptionOnValidationFailure = true; - - /** - * Constructor that takes the severName (or serviceUrl), TicketValidator, useSession and redirectAfterValidation. Either serveName or serviceUrl is required (but not both). - * - * @param service the name of the server in : 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 service, final boolean isServerName, final TicketValidator ticketValidator) { - super(service, isServerName); - CommonUtils.assertNotNull(ticketValidator, - "ticketValidator cannot be null."); - this.ticketValidator = ticketValidator; - - log.info("Initialized with the following properties: " + - "ticketValidator=" + this.ticketValidator.getClass().getName() + "; " + - "redirectAfterValidation=" + this.redirectAfterValidation + "; exceptionOnValidationFailure=" + exceptionOnValidationFailure); - - } - - protected void doFilterInternal(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - final String ticket = request.getParameter(getArgumentExtractor().getArtifactParameterName()); - - if (CommonUtils.isNotBlank(ticket)) { - if (log.isDebugEnabled()) { - log.debug("Attempting to validate ticket: " + ticket); - } - - try { - final Assertion assertion = this.ticketValidator.validate( - ticket, new SimpleService(constructServiceUrl(request, - response))); - - if (log.isDebugEnabled()) { - log.debug("Successfully authenticated user: " - + assertion.getPrincipal().getId()); - } - - request.setAttribute(CONST_PRINCIPAL, assertion.getPrincipal()); - - if (isUseSession()) { - request.getSession().setAttribute(CONST_ASSERTION, - assertion); - } - } catch (final ValidationException e) { - response.setStatus(HttpServletResponse.SC_FORBIDDEN); - log.warn(e, e); - - if (this.exceptionOnValidationFailure) { - throw new ServletException(e); - } - } - - if (this.redirectAfterValidation) { - response.sendRedirect(response - .encodeRedirectURL(constructServiceUrl(request, response))); - return; - } - } - - filterChain.doFilter(request, response); - } - - public void setRedirectAfterValidation(final boolean redirectAfterValidation) { - this.redirectAfterValidation = redirectAfterValidation; - } - - public void setExceptionOnValidationFailure(final boolean exceptionOnValidationFailure) { - this.exceptionOnValidationFailure = exceptionOnValidationFailure; - } -} diff --git a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/package.html b/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/package.html deleted file mode 100644 index e567df0..0000000 --- a/cas-client-core/src/main/java/org/jasig/cas/client/web/filter/package.html +++ /dev/null @@ -1,6 +0,0 @@ - - -

This package contains all of the useful filters related to normal CAS processing, including Authentication, - Validation and Authorization.

- - diff --git a/cas-client-core/src/main/resources/cas-client.properties b/cas-client-core/src/main/resources/cas-client.properties deleted file mode 100644 index 03492ee..0000000 --- a/cas-client-core/src/main/resources/cas-client.properties +++ /dev/null @@ -1,6 +0,0 @@ -cas.server.gateway=false -cas.server.renew=false -cas.server.url=https://localhost:8443/cas/ -cas.server.proxyCallbackUrl=https://localhost:8443/manager/proxy/Receptor -cas.client.serverName=localhost:8443 -cas.client.proxyCallbackUrl=https://localhost:8443/myClientApp/casProxyReceptor \ No newline at end of file diff --git a/cas-client-core/src/main/resources/simpleFilter.xml b/cas-client-core/src/main/resources/simpleFilter.xml deleted file mode 100644 index 33f4d29..0000000 --- a/cas-client-core/src/main/resources/simpleFilter.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - scott - velpi - apetro - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cas-client-core/src/main/resources/web-simple-example.xml b/cas-client-core/src/main/resources/web-simple-example.xml deleted file mode 100644 index df1c562..0000000 --- a/cas-client-core/src/main/resources/web-simple-example.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - Java CAS Client - - - - contextConfigLocation - - /WEB-INF/simpleFilter.xml - - - - - CAS Authentication Filter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casAuthenticationFilter - - - - - CAS Validation Filter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casValidationFilter - - - - - CAS Authorization Filter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casAuthorizationFilter - - - - - CAS Authentication Filter - /* - - - - CAS Validation Filter - /* - - - - CAS Authorization Filter - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - - casclient - org.jasig.cas.client.proxy.SpringConfiguredProxyReceptorServlet - 1 - - - - casclient - /proxy/Receptor - - \ No newline at end of file diff --git a/cas-client-core/src/main/resources/web-simple-proxy-example.xml b/cas-client-core/src/main/resources/web-simple-proxy-example.xml deleted file mode 100644 index 7c94796..0000000 --- a/cas-client-core/src/main/resources/web-simple-proxy-example.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - Java CAS Client - - - - contextConfigLocation - - /WEB-INF/simpleFilter.xml - - - - - CAS Authentication Filter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casAuthenticationFilter - - - - - CAS Validation Filter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casValidationFilter - - - - - - CAS HttpServletRequestWrapperFilter - org.springframework.web.filter.DelegatingFilterProxy - - targetBeanName - casHttpServletRequestWrapperFilter - - - - - - CAS Authentication Filter - /* - - - - CAS Validation Filter - /* - - - - CAS HttpServletRequestWrapperFilter - /* - - - - - org.springframework.web.context.ContextLoaderListener - - - - - casclient - org.jasig.cas.client.proxy.SpringConfiguredProxyReceptorServlet - 1 - - - - casclient - casProxyReceptor - - \ No newline at end of file diff --git a/cas-client-core/src/test/clover/clover.license b/cas-client-core/src/test/clover/clover.license deleted file mode 100644 index 8506a9d..0000000 --- a/cas-client-core/src/test/clover/clover.license +++ /dev/null @@ -1,166 +0,0 @@ -Product: Clover -License: Open Source License, 0.x, 1.x -Issued: Sun Feb 13 2005 22:45:43 CST -Expiry: Never -Key: aae4c7035b1208e316fa6d684 -Name: Scott Battaglia -Org: JA-SIG Central Authentication Service -Certificate: AAACCG+Ow8B7/zEbxOMqqKwwrdpP+a1COmJGHco7sCNLjHkHnajPF+dQW -Ct12PMy0uml0s9xuus5wKngJ9OFk5PFeh01dzQF66bhXH1bvegLfvja3Kle6BYtDv4LZgE -gk3E0aJN4IbgTn+TgUckSevXDR4KzK77NWJfrVzkxV3/JepYRA9UAbsXHiki9WjMIJfzoZ -unjvtTFd/vTOcyirgfT/dTPrG9PAGAjH+e37E9Xf7HnRSrmxtrGX+wdaBOlZFUIIcVHKT2 -IaGToLZnx7FvfE3rzyQCYtS+r0E+H61c+dANzySy5PEH2JEyL8M9JrwgYJSju1FWhxbXO2 -Gb7y3Diufo80+HWz6xrGzl9IlXRseoXHki8rllk5taXqVv5G3UIsTFzbjjWUDlykn557C2 -D4o9T0xQ/6dVFxak75o0MxP4aXGFMZNg/pCBH9DAU7/CKVKRBPAVx1PJ8vIy41MF4p9Mi1 -qmELNvjn9K9fwpaeiUG9qT8B0pfq/tTAObG2sZf7B1mFbA3YwEqjhNqLdkoca5swrS0DI1 -9OejIVIqjK+bvUZaqUDMxVX7fM6hwRvI9Wd+rwFG+X3wHYNPsZ+Cos8/BNPzIIoOh4SbTr -8vIqWUdPXM4HO26uAAVRKz6FknmwM/GQ7FyJBWgIXgXK51SLn+NcifxO8uywGewHzP00ki -frTPmy0+GrikleWry6BdWkg76hjrjQBalNlSmasi9yp9J8qdzVYvQlOBjS5EKWsvsSpXGY -MIdupkiv4a25aXsgdpGBy4GzcSUDioChq287HBBmYRIMVvp5OYbV3/+ERNhTlCQqb6Ck4g -891l1OJOEoMiDqcbDL8DNftlH4gybEE7zJXQRmmJKyw== -License Agreement: CLOVER VERSION 1 (ONE) SOFTWARE LICENSE AGREEMENT - -1. Licenses and Software - -Cortex eBusiness Pty Ltd, an Australian Proprietary Limited Company -("CENQUA") hereby grants to the purchaser (the "LICENSEE") a limited, -revocable, worldwide, non-exclusive, non-transferable, -non-sublicensable license to use the Clover version 1 (one) software -(the "Software"), including any minor upgrades thereof during the Term -(hereinafter defined) up to, but not including the next major version -of the Software. The licensee shall not, or knowingly allow others to, -reverse engineer, decompile, disassemble, modify, adapt, create -derivative works from or otherwise attempt to derive source code from -the Software provided. And, in accordance with the terms and -conditions of this Software License Agreement (the "Agreement"), the -Software shall be used solely by the licensed users in accordance with -the following edition specific conditions: - -a) Server Edition - -A Server Edition license entitles the Licensee to execute one instance -of Clover Server Edition on one (1) machine for the purposes of -instrumenting source code and generating reports. There are no -limitations on the use of the instrumented source code or generated -reports produced by Server Edition. - -b) Workstation Edition - -A Workstation Edition license entitles the licensee to use Clover -Workstation Edition on one (1) machine by one (1) individual end -user. Workstation Edition does not permit the generation of reports -for distribution. - -c) Team Edition - -A Team Edition license entitles the licensee to use Clover Team -edition on any number of machines solely by the licensed number of -users. Reports generated by Clover Team Edition are strictly for use -only by the licensed number of individual end users. - -2. License Fee - -In exchange for the License(s), the Licensee shall pay to Cenqua a -one-time, up front, non-refundable license fee. At the sole discretion -of Cenqua this fee will be waived for non-commercial -projects. Notwithstanding the Licensee's payment of the License Fee, -Cenqua reserves the right to terminate the License if Cenqua discovers -that the Licensee and/or the Licensee's use of the Software is in -breach of this Agreement. - -3. Proprietary Rights - -Cenqua will retain all right, title and interest in and to the -Software, all copies thereof, and Cenqua website(s), software, and -other intellectual property, including, but not limited to, ownership -of all copyrights, look and feel, trademark rights, design rights, -trade secret rights and any and all other intellectual property and -other proprietary rights therein. The Licensee will not directly or -indirectly obtain or attempt to obtain at any time, any right, title -or interest by registration or otherwise in or to the trademarks, -service marks, copyrights, trade names, symbols, logos or designations -or other intellectual property rights owned or used by Cenqua. All -technical manuals or other information provided by Cenqua to the -Licensee shall be the sole property of Cenqua. - -4. Term and Termination - -Subject to the other provisions hereof, this Agreement shall commence -upon the Licensee's opting into this Agreement and continue until the -Licensee discontinues use of the Software or the Agreement terminates -automatically upon the Licensee's breach of any term or condition of -this Agreement (the "Term"). Upon any such termination, the Licensee -will delete the Software immediately. - -5. Copying & Transfer - -The Licensee may copy the Software for back-up purposes only. The -Licensee may not assign or otherwise transfer the Software to any -third party. - -6. Specific Disclaimer of Warranty and Limitation of Liability - -THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND. CENQUA -DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE. CENQUA WILL NOT BE LIABLE FOR ANY DAMAGES -ASSOCIATED WITH THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ORDINARY, -INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING -BUT NOT LIMITED TO DAMAGES RELATING TO LOST DATA OR LOST PROFITS, EVEN -IF CENQUA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Warranties and Representations - -Licensee Indemnification. CENQUA agrees to indemnify, defend and hold -the Licensee harmless from and against any and all liabilities, -damages, losses, claims, costs, and expenses (including reasonable -legal fees) arising out of or resulting from the Software or the use -thereof infringing upon, misappropriating or violating any patents, -copyrights, trademarks, or trade secret rights or other proprietary -rights of persons, firms or entities who are not parties to this -Agreement. - -CENQUA Indemnification. The Licensee warrants and represents that the -Licensee's actions with regard to the Software will be in compliance -with all applicable laws; and the Licensee agrees to indemnify, -defend, and hold CENQUA harmless from and against any and all -liabilities, damages, losses, claims, costs, and expenses (including -reasonable legal fees) arising out of or resulting from the -Licensee's failure to observe the use restrictions set forth herein. - -8. Publicity - -The Licensee grants permission for CENQUA to use Licensee's name -solely in customer lists. CENQUA shall not, without prior consent in -writing, use the Licensee's name, or that of its affiliates, in any -form with the specific exception of customer lists. CENQUA agrees to -remove Licensee's name from any and all materials within 7 days if -notified by the Licensee in writing. - -9. Governing Law - -This Agreement shall be governed by the laws of New South Wales, -Australia. - -10. Independent Contractors - -The parties are independent contractors with respect to each other, -and nothing in this Agreement shall be construed as creating an -employer-employee relationship, a partnership, agency relationship or -a joint venture between the parties. - -11. Assignment - -This Agreement is not assignable or transferable by the Licensee. -CENQUA in its sole discretion may transfer a license to a third party -at the written request of the Licensee. - -12. Entire Agreement - -This Agreement constitutes the entire agreement between the parties -concerning the Licensee's use of the Software. This Agreement -supersedes any prior verbal understanding between the parties and any -Licensee purchase order or other ordering document, regardless of -whether such document is received by CENQUA before or after execution -of this Agreement. This Agreement may be amended only in writing by -CENQUA. diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/PublicTestHttpServer.java b/cas-client-core/src/test/java/org/jasig/cas/client/PublicTestHttpServer.java deleted file mode 100644 index 3b2744e..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/PublicTestHttpServer.java +++ /dev/null @@ -1,106 +0,0 @@ -package org.jasig.cas.client; - - -import java.io.*; -import java.net.ServerSocket; -import java.net.Socket; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class PublicTestHttpServer extends Thread { - - private static PublicTestHttpServer httpServer; - - public byte[] content; - - private byte[] header; - - private int port = 80; - - public String encoding; - - private PublicTestHttpServer(String data, String encoding, String MIMEType, - int port) throws UnsupportedEncodingException { - this(data.getBytes(encoding), encoding, MIMEType, port); - } - - private PublicTestHttpServer(byte[] data, String encoding, String MIMEType, - int port) throws UnsupportedEncodingException { - - this.content = data; - this.port = port; - this.encoding = encoding; - String header = "HTTP/1.0 200 OK\r\n" + "Server: OneFile 1.0\r\n" - // + "Content-length: " + this.content.length + "\r\n" - + "Content-type: " + MIMEType + "\r\n\r\n"; - this.header = header.getBytes("ASCII"); - - } - - public static synchronized PublicTestHttpServer instance() { - if (httpServer == null) { - try { - httpServer = new PublicTestHttpServer("test", "ASCII", - "text/plain", 8085); - } catch (Exception e) { - throw new RuntimeException(e); - } - httpServer.start(); - Thread.yield(); - } - - return httpServer; - } - - public void run() { - - try { - ServerSocket server = new ServerSocket(this.port); - System.out.println("Accepting connections on port " - + server.getLocalPort()); - while (true) { - - Socket connection = null; - try { - connection = server.accept(); - OutputStream out = new BufferedOutputStream(connection - .getOutputStream()); - InputStream in = new BufferedInputStream(connection - .getInputStream()); - // read the first line only; that's all we need - StringBuffer request = new StringBuffer(80); - while (true) { - int c = in.read(); - if (c == '\r' || c == '\n' || c == -1) - break; - request.append((char) c); - } - - if (request.toString().startsWith("STOP")) { - connection.close(); - break; - } - if (request.toString().indexOf("HTTP/") != -1) { - out.write(this.header); - } - out.write(this.content); - out.flush(); - } // end try - catch (IOException e) { - // nothing to do with this IOException - } finally { - if (connection != null) - connection.close(); - } - - } // end while - } // end try - catch (IOException e) { - System.err.println("Could not start server. Port Occupied"); - } - - } // end run -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AbstractAuthorizedDeciderTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AbstractAuthorizedDeciderTests.java deleted file mode 100644 index 90ecd21..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AbstractAuthorizedDeciderTests.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.SimplePrincipal; - -/** - * Abstract test for all AuthorizedDecider implementations. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractAuthorizedDeciderTests extends TestCase { - - private AuthorizedDecider casAuthorizedDecider; - - protected abstract AuthorizedDecider getCasAuthorizedDeciderImpl(); - - protected final void setUp() throws Exception { - this.casAuthorizedDecider = getCasAuthorizedDeciderImpl(); - } - - public final void testIsAuthorized() { - assertTrue(this.casAuthorizedDecider - .isAuthorizedToUseApplication(new SimplePrincipal("scott"))); - } - - public final void testIsNotAuthorized() { - assertFalse(this.casAuthorizedDecider - .isAuthorizedToUseApplication(new SimplePrincipal("not"))); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AuthorizationExceptionTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AuthorizationExceptionTests.java deleted file mode 100644 index d46d866..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/AuthorizationExceptionTests.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -import junit.framework.TestCase; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AuthorizationExceptionTests extends TestCase { - - private static final String CONST_MESSAGE = "t"; - - private static final Exception CONST_THROWABLE = new RuntimeException(); - - public void testMessageThrowable() { - final AuthorizationException e = new AuthorizationException( - CONST_MESSAGE, CONST_THROWABLE); - - assertEquals(CONST_MESSAGE, e.getMessage()); - assertEquals(CONST_THROWABLE, e.getCause()); - } - - public void testMessage() { - final AuthorizationException e = new AuthorizationException( - CONST_MESSAGE); - - assertEquals(CONST_MESSAGE, e.getMessage()); - } - - public void testThrowable() { - final AuthorizationException e = new AuthorizationException( - CONST_THROWABLE); - - assertEquals(CONST_THROWABLE, e.getCause()); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImplTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImplTests.java deleted file mode 100644 index 162bfe9..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/authorization/DefaultAuthorizedDeciderImplTests.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.authorization; - -import java.util.ArrayList; -import java.util.List; - -public final class DefaultAuthorizedDeciderImplTests extends - AbstractAuthorizedDeciderTests { - - public AuthorizedDecider getCasAuthorizedDeciderImpl() { - final List list = new ArrayList(); - list.add("scott"); - - final DefaultAuthorizedDeciderImpl impl = new DefaultAuthorizedDeciderImpl(list); - return impl; - } - -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/AbstractProxyGrantingTicketStorageTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/proxy/AbstractProxyGrantingTicketStorageTests.java deleted file mode 100644 index 367e5c5..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/AbstractProxyGrantingTicketStorageTests.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import junit.framework.TestCase; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractProxyGrantingTicketStorageTests extends TestCase { - - protected ProxyGrantingTicketStorageImpl proxyGrantingTicketStorageImpl; - - public final void testNullValue() { - assertNull(this.proxyGrantingTicketStorageImpl - .retrieve("this should not exist")); - } - - public final void testValueExists() { - final String CONST_KEY = "testKey"; - final String CONST_VALUE = "testValue"; - - this.proxyGrantingTicketStorageImpl.save(CONST_KEY, CONST_VALUE); - - assertEquals(CONST_VALUE, this.proxyGrantingTicketStorageImpl - .retrieve(CONST_KEY)); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImplTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImplTests.java deleted file mode 100644 index 16eac1f..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/ProxyGrantingTicketStorageImplTests.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -/** - * Test cases for the ProxyGrantingTicketStorageImplTests. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ProxyGrantingTicketStorageImplTests extends - AbstractProxyGrantingTicketStorageTests { - - protected void setUp() throws Exception { - this.proxyGrantingTicketStorageImpl = new ProxyGrantingTicketStorageImpl(1000); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServletTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServletTests.java deleted file mode 100644 index 090e97a..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/proxy/SpringConfiguredProxyReceptorServletTests.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.proxy; - -import junit.framework.TestCase; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockServletConfig; -import org.springframework.mock.web.MockServletContext; -import org.springframework.web.context.WebApplicationContext; -import org.springframework.web.context.support.XmlWebApplicationContext; - -import javax.servlet.ServletConfig; - -public final class SpringConfiguredProxyReceptorServletTests extends TestCase { - - private XmlWebApplicationContext webApplicationContext; - - public void testNoProxyGrantingTicketStorage() { - AbstractProxyReceptorServlet servlet = new SpringConfiguredProxyReceptorServlet(); - try { - servlet - .init(getServletConfig("classpath:badProxyGrantingTicketStorageConfig.xml")); - fail("Exception expected."); - } catch (final Exception e) { - // expected - } - } - - public void testTwoProxyGrantingTicketStorage() { - AbstractProxyReceptorServlet servlet = new SpringConfiguredProxyReceptorServlet(); - try { - servlet - .init(getServletConfig("classpath:twoProxyGrantingTicketStorageConfig.xml")); - fail("Exception expected."); - } catch (final Exception e) { - // expected - } - } - - public void testOneProxyGrantingTicketStorage() { - AbstractProxyReceptorServlet servlet = new SpringConfiguredProxyReceptorServlet(); - try { - servlet - .init(getServletConfig("classpath:oneProxyGrantingTicketStorageConfig.xml")); - } catch (final Exception e) { - fail("Unexpected excception."); - } - } - - public void testNoPgtOrPgtIouPassed() throws Exception { - final AbstractProxyReceptorServlet servlet = new SpringConfiguredProxyReceptorServlet(); - servlet - .init(getServletConfig("classpath:proxyGrantingTicketStorageConfig.xml")); - - final MockHttpServletResponse response = new MockHttpServletResponse(); - servlet.doGet(new MockHttpServletRequest(), response); - - assertEquals("", response.getContentAsString()); - } - - public void testPgtPassed() throws Exception { - final AbstractProxyReceptorServlet servlet = new SpringConfiguredProxyReceptorServlet(); - servlet - .init(getServletConfig("classpath:proxyGrantingTicketStorageConfig.xml")); - - final ProxyGrantingTicketStorage storage = (ProxyGrantingTicketStorage) this.webApplicationContext - .getBean("proxyGrantingTicketStorage"); - - final MockHttpServletRequest request = new MockHttpServletRequest(); - request.setParameter("pgtIou", "test"); - request.setParameter("pgtId", "testpgtId"); - final MockHttpServletResponse response = new MockHttpServletResponse(); - servlet.doGet(request, response); - - assertTrue(!"".equals(response.getContentAsString())); - assertEquals("testpgtId", storage.retrieve("test")); - } - - private ServletConfig getServletConfig(final String contextLocation) { - this.webApplicationContext = new XmlWebApplicationContext(); - this.webApplicationContext - .setConfigLocations(new String[]{contextLocation}); - this.webApplicationContext.refresh(); - - MockServletContext context = new MockServletContext(); - context.setAttribute( - WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, - this.webApplicationContext); - - return new MockServletConfig(context); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java deleted file mode 100644 index 543696c..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/util/CommonUtilsTests.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.util; - -import junit.framework.TestCase; - -import java.util.ArrayList; -import java.util.Collection; - -/** - * Tests for the CommonUtils. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CommonUtilsTests extends TestCase { - - public void testAssertNotNull() { - final String CONST_MESSAGE = "test"; - CommonUtils.assertNotNull(new Object(), CONST_MESSAGE); - try { - CommonUtils.assertNotNull(null, CONST_MESSAGE); - } catch (IllegalArgumentException e) { - assertEquals(CONST_MESSAGE, e.getMessage()); - } - } - - public void testAssertNotEmpty() { - final String CONST_MESSAGE = "test"; - final Collection c = new ArrayList(); - c.add(new Object()); - CommonUtils.assertNotEmpty(c, CONST_MESSAGE); - try { - CommonUtils.assertNotEmpty(new ArrayList(), CONST_MESSAGE); - } catch (IllegalArgumentException e) { - assertEquals(CONST_MESSAGE, e.getMessage()); - } - - try { - CommonUtils.assertNotEmpty(null, CONST_MESSAGE); - } catch (IllegalArgumentException e) { - assertEquals(CONST_MESSAGE, e.getMessage()); - } - } - - public void testAssertTrue() { - final String CONST_MESSAGE = "test"; - CommonUtils.assertTrue(true, CONST_MESSAGE); - try { - CommonUtils.assertTrue(false, CONST_MESSAGE); - } catch (IllegalArgumentException e) { - assertEquals(CONST_MESSAGE, e.getMessage()); - } - } - - public void testIsEmpty() { - assertFalse(CommonUtils.isEmpty("test")); - assertFalse(CommonUtils.isEmpty(" test")); - assertTrue(CommonUtils.isEmpty("")); - assertTrue(CommonUtils.isEmpty(null)); - assertFalse(CommonUtils.isEmpty(" ")); - } - - public void testIsNotEmpty() { - assertTrue(CommonUtils.isNotEmpty("test")); - assertTrue(CommonUtils.isNotEmpty(" test")); - assertFalse(CommonUtils.isNotEmpty("")); - assertFalse(CommonUtils.isNotEmpty(null)); - assertTrue(CommonUtils.isNotEmpty(" ")); - } - - public void testIsBlank() { - assertFalse(CommonUtils.isBlank("test")); - assertFalse(CommonUtils.isBlank(" test")); - assertTrue(CommonUtils.isBlank("")); - assertTrue(CommonUtils.isBlank(null)); - assertTrue(CommonUtils.isBlank(" ")); - } - - public void testIsNotBlank() { - assertTrue(CommonUtils.isNotBlank("test")); - assertTrue(CommonUtils.isNotBlank(" test")); - assertFalse(CommonUtils.isNotBlank("")); - assertFalse(CommonUtils.isNotBlank(null)); - assertFalse(CommonUtils.isNotBlank(" ")); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/util/DelegatingFilterTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/util/DelegatingFilterTests.java deleted file mode 100644 index 8fa329e..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/util/DelegatingFilterTests.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.util; - -import junit.framework.TestCase; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; - -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -/** - * Test Cases for DelegatingFilter - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class DelegatingFilterTests extends TestCase { - - private DelegatingFilter delegatingFilter; - - protected int filterExecuted = -1; - - protected void setUp() throws Exception { - final Map delegators = new HashMap(); - - delegators.put("1", new TestFilter(1)); - - this.filterExecuted = -1; - this.delegatingFilter = new DelegatingFilter("test", delegators, true, new TestFilter(0)); - this.delegatingFilter.init(null); - } - - protected void tearDown() throws Exception { - this.delegatingFilter.destroy(); - } - - public void testExactMatchFound() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - request.addParameter("test", "1"); - - this.delegatingFilter.doFilter(request, new MockHttpServletResponse(), - null); - - assertEquals(1, this.filterExecuted); - } - - public void testNoMatchFound() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - request.addParameter("test", "0"); - - this.delegatingFilter.doFilter(request, new MockHttpServletResponse(), - null); - - assertEquals(0, this.filterExecuted); - } - - public void testNoParam() throws Exception { - this.delegatingFilter.doFilter(new MockHttpServletRequest(), - new MockHttpServletResponse(), null); - - assertEquals(0, this.filterExecuted); - } - - public void testRegularExpressionMatch() throws Exception { - - final Map delegators = new HashMap(); - - delegators.put("1.*", new TestFilter(1)); - - this.delegatingFilter = new DelegatingFilter("test", delegators, false, new TestFilter(0)); - - MockHttpServletRequest request = new MockHttpServletRequest(); - request.addParameter("test", "1"); - - this.delegatingFilter.doFilter(request, new MockHttpServletResponse(), - null); - - assertEquals(1, this.filterExecuted); - request = new MockHttpServletRequest(); - request.addParameter("test", "15"); - - this.delegatingFilter.doFilter(request, new MockHttpServletResponse(), - null); - - assertEquals(1, this.filterExecuted); - request = new MockHttpServletRequest(); - request.addParameter("test", "0"); - - this.delegatingFilter.doFilter(request, new MockHttpServletResponse(), - null); - - assertEquals(0, this.filterExecuted); - } - - public void testForIllegalArgument() { - Map map = new HashMap(); - map.put("test", new Object()); - - try { - this.delegatingFilter = new DelegatingFilter("test", map, false, new TestFilter(0)); - fail("Exception expected."); - } catch (IllegalArgumentException e) { - // expected - } - } - - private final class TestFilter implements Filter { - - private final int i; - - public TestFilter(final int i) { - this.i = i; - } - - public void destroy() { - // nothing to do here - } - - public void doFilter(ServletRequest arg0, ServletResponse arg1, - FilterChain arg2) throws IOException, ServletException { - DelegatingFilterTests.this.filterExecuted = this.i; - - } - - public void init(FilterConfig arg0) throws ServletException { - // nothing to do - } - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/AbstractTicketValidatorTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/AbstractTicketValidatorTests.java deleted file mode 100644 index fdfaed5..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/AbstractTicketValidatorTests.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import junit.framework.TestCase; - -/** - * Base class for all TicketValidator tests to inherit from. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractTicketValidatorTests extends TestCase { - - protected static final String CONST_CAS_SERVER_URL = "http://localhost:8085/"; - - protected static final String CONST_USERNAME = "username"; -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/AssertionImplTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/AssertionImplTests.java deleted file mode 100644 index 91cd5c8..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/AssertionImplTests.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.authentication.principal.SimpleService; - -import java.util.HashMap; -import java.util.Map; - -/** - * Test cases for the {@link AssertionImpl}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AssertionImplTests extends TestCase { - - private static final Principal CONST_PRINCIPAL = new SimplePrincipal("test"); - - private static final String CONST_PROXY_GRANTING_TICKET_IOU = "proxyGrantingTicketIou"; - - private static final Map CONST_ATTRIBUTES = new HashMap(); - - static { - CONST_ATTRIBUTES.put("test", "test"); - } - - public void testPrincipalConstructor() { - final Assertion assertion = new AssertionImpl(CONST_PRINCIPAL); - - assertEquals(CONST_PRINCIPAL, assertion.getPrincipal()); - assertTrue(assertion.getAttributes().isEmpty()); - assertNull(assertion.getProxyTicketFor(new SimpleService("test"))); - } - - public void testCompleteConstructor() { - final Assertion assertion = new AssertionImpl(CONST_PRINCIPAL, - CONST_ATTRIBUTES); - - assertEquals(CONST_PRINCIPAL, assertion.getPrincipal()); - assertEquals(CONST_ATTRIBUTES, assertion.getAttributes()); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas10TicketValidatorTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas10TicketValidatorTests.java deleted file mode 100644 index c51b433..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas10TicketValidatorTests.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.PublicTestHttpServer; - -import java.io.UnsupportedEncodingException; - -/** - * Test cases for the {@link Cas10TicketValidator}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class Cas10TicketValidatorTests extends AbstractTicketValidatorTests { - - private Cas10TicketValidator ticketValidator; - - public Cas10TicketValidatorTests() { - super(); - } - - protected void setUp() throws Exception { - this.ticketValidator = new Cas10TicketValidator(CONST_CAS_SERVER_URL, true, new HttpClient()); - } - - public void testNoResponse() throws Exception { - PublicTestHttpServer.instance().content = "no\n\n" - .getBytes(PublicTestHttpServer.instance().encoding); - try { - this.ticketValidator.validate("testTicket", new SimpleService( - "myService")); - fail("ValidationException expected."); - } catch (final ValidationException e) { - // expected - } - } - - public void testYesResponse() throws ValidationException, - UnsupportedEncodingException { - PublicTestHttpServer.instance().content = "yes\nusername\n\n" - .getBytes(PublicTestHttpServer.instance().encoding); - final Assertion assertion = this.ticketValidator.validate("testTicket", - new SimpleService("myService")); - assertEquals(CONST_USERNAME, assertion.getPrincipal().getId()); - } - - public void testBadResponse() throws UnsupportedEncodingException { - PublicTestHttpServer.instance().content = "falalala\n\n" - .getBytes(PublicTestHttpServer.instance().encoding); - try { - this.ticketValidator.validate("testTicket", new SimpleService( - "myService")); - fail("ValidationException expected."); - } catch (final ValidationException e) { - // expected - } - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidatorTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidatorTests.java deleted file mode 100644 index 58ada81..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ProxyTicketValidatorTests.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.PublicTestHttpServer; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl; -import org.jasig.cas.client.proxy.ProxyRetriever; - -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - -/** - * Test cases for the {@link Cas20ProxyTicketValidator}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class Cas20ProxyTicketValidatorTests extends - AbstractTicketValidatorTests { - - private Cas20ProxyTicketValidator ticketValidator; - - public Cas20ProxyTicketValidatorTests() { - super(); - } - - protected void setUp() throws Exception { - final ProxyGrantingTicketStorage proxyGrantingTicketStorage = getProxyGrantingTicketStorage(); - final List list = new ArrayList(); - list.add("proxy1 proxy2 proxy3"); - - this.ticketValidator = new Cas20ProxyTicketValidator(CONST_CAS_SERVER_URL, true, new HttpClient(), new SimpleService("test"), list, false, getProxyGrantingTicketStorage(), getProxyRetriever()); - } - - private ProxyGrantingTicketStorage getProxyGrantingTicketStorage() { - final ProxyGrantingTicketStorageImpl proxyGrantingTicketStorageImpl = new ProxyGrantingTicketStorageImpl(); - - return proxyGrantingTicketStorageImpl; - } - - private ProxyRetriever getProxyRetriever() { - final ProxyRetriever proxyRetriever = new ProxyRetriever() { - - public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) { - return "test"; - } - }; - - return proxyRetriever; - } - - public void testProxyChainWithValidProxy() throws ValidationException, - UnsupportedEncodingException { - final String USERNAME = "username"; - final String RESPONSE = "usernamePGTIOU-84678-8a9d...proxy1proxy2proxy3"; - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - - final Assertion assertion = this.ticketValidator.validate("test", - new SimpleService("test")); - assertEquals(USERNAME, assertion.getPrincipal().getId()); - } - - public void testProxyChainWithInvalidProxy() throws ValidationException, - UnsupportedEncodingException { - final String RESPONSE = "usernamePGTIOU-84678-8a9d...proxy7proxy2proxy3"; - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - - try { - this.ticketValidator.validate("test", new SimpleService("test")); - fail("Invalid proxy chain"); - } catch (InvalidProxyChainValidationException e) { - // expected - } - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidatorTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidatorTests.java deleted file mode 100644 index 721f115..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/Cas20ServiceTicketValidatorTests.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - - -import org.apache.commons.httpclient.HttpClient; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.PublicTestHttpServer; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorageImpl; -import org.jasig.cas.client.proxy.ProxyRetriever; - -import java.io.UnsupportedEncodingException; - -/** - * Test cases for the {@link Cas20ServiceTicketValidator}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class Cas20ServiceTicketValidatorTests extends - AbstractTicketValidatorTests { - - private Cas20ServiceTicketValidator ticketValidator; - - private ProxyGrantingTicketStorage proxyGrantingTicketStorage; - - private ProxyRetriever proxyRetriever; - - public Cas20ServiceTicketValidatorTests() { - super(); - } - - public Cas20ServiceTicketValidatorTests(Cas20ServiceTicketValidator ticketValidator) { - this.ticketValidator = ticketValidator; - } - - protected void setUp() throws Exception { - this.proxyGrantingTicketStorage = getProxyGrantingTicketStorage(); - this.ticketValidator = new Cas20ServiceTicketValidator(CONST_CAS_SERVER_URL, true, new HttpClient(), new SimpleService("test"), this.proxyGrantingTicketStorage, getProxyRetriever()); - } - - private ProxyGrantingTicketStorage getProxyGrantingTicketStorage() { - final ProxyGrantingTicketStorageImpl proxyGrantingTicketStorageImpl = new ProxyGrantingTicketStorageImpl(); - - return proxyGrantingTicketStorageImpl; - } - - private ProxyRetriever getProxyRetriever() { - final ProxyRetriever proxyRetriever = new ProxyRetriever() { - - public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) { - return "test"; - } - }; - - return proxyRetriever; - } - - public void testNoResponse() throws UnsupportedEncodingException { - final String RESPONSE = "Ticket ST-1856339-aA5Yuvrxzpv8Tau1cYQ7 not recognized"; - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - try { - this.ticketValidator.validate("test", new SimpleService("test")); - fail("ValidationException expected due to 'no' response"); - } catch (final ValidationException e) { - // expected - } - } - - public void testYesResponseButNoPgt() throws ValidationException, - UnsupportedEncodingException { - final String USERNAME = "username"; - final String RESPONSE = "" - + USERNAME - + ""; - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - - final Assertion assertion = this.ticketValidator.validate("test", - new SimpleService("test")); - assertEquals(USERNAME, assertion.getPrincipal().getId()); - } - - public void testYesResponseWithPgt() throws ValidationException, - UnsupportedEncodingException { - final String USERNAME = "username"; - final String PGTIOU = "testPgtIou"; - final String PGT = "test"; - final String RESPONSE = "" - + USERNAME - + "" - + PGTIOU - + ""; - - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - - this.proxyGrantingTicketStorage.save(PGTIOU, PGT); - - final Assertion assertion = this.ticketValidator.validate("test", - new SimpleService("test")); - assertEquals(USERNAME, assertion.getPrincipal().getId()); -// assertEquals(PGT, assertion.getProxyGrantingTicketId()); - } - - public void testInvalidResponse() throws Exception { - final String RESPONSE = ""; - PublicTestHttpServer.instance().content = RESPONSE - .getBytes(PublicTestHttpServer.instance().encoding); - try { - this.ticketValidator.validate("test", new SimpleService("test")); - fail("ValidationException expected due to invalid response."); - } catch (final ValidationException e) { - // expected - } - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/validation/SamlTicketValidatorTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/validation/SamlTicketValidatorTests.java deleted file mode 100644 index 70d2d6f..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/validation/SamlTicketValidatorTests.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.validation; - -import junit.framework.TestCase; -import org.jasig.cas.web.view.Saml10SuccessResponseView; -import org.jasig.cas.authentication.Authentication; -import org.jasig.cas.authentication.ImmutableAuthentication; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.validation.ImmutableAssertionImpl; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.apache.commons.httpclient.HttpClient; - -import java.util.Map; -import java.util.HashMap; -import java.util.List; -import java.util.ArrayList; - -/** - * Test cases for the {@link org.jasig.cas.client.validation.Saml10TicketValidator}. - * - * @author Scott Battaglia - * @version $Revision: 11737 $ $Date: 2006-10-03 09:14:02 -0400 (Tue, 03 Oct 2006) $ - * @since 3.1 - */ -public class SamlTicketValidatorTests extends TestCase { - - final Saml10TicketValidator validator = new Saml10TicketValidator("https://cas.rutgers.edu", new HttpClient()); - /* - public void testValidationWithTicketIdWithPlus() throws Exception { - final Saml10SuccessResponseView view = new Saml10SuccessResponseView(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final Map model = new HashMap(); - - final Authentication authentication = new ImmutableAuthentication(new SimplePrincipal("test")); - final List authentications = new ArrayList(); - authentications.add(authentication); - final ImmutableAssertionImpl assertion = new ImmutableAssertionImpl(authentications, new SimpleService("test"), true); - model.put("assertion", assertion); - request.addParameter("SAMLArt", "AAIYG64MrQ2+793pMM8J0sRjXf6uG2h0dHBzOi8vbG9jYWxob3N0Ojg0NDM="); - - view.setIssuer("https://cas.rutgers.edu"); - view.render(model, request, response); - final String content = response.getContentAsString(); - - Assertion assertionResponse = validator.parseResponse(content); - - assertEquals("test", assertionResponse.getPrincipal().getId()); - } */ -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthenticationFilterTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthenticationFilterTests.java deleted file mode 100644 index 7324ea4..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthenticationFilterTests.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.client.validation.AssertionImpl; -import org.springframework.mock.web.MockFilterConfig; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockHttpSession; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; -import java.net.URLEncoder; - -/** - * Tests for the AuthenticationFilter. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AuthenticationFilterTests extends TestCase { - - private static final String CAS_SERVICE_URL = "https://localhost:8443/service"; - - private static final String CAS_LOGIN_URL = "https://localhost:8443/cas/login"; - - private AuthenticationFilter filter; - - protected void setUp() throws Exception { - this.filter = new AuthenticationFilter(CAS_SERVICE_URL, false, CAS_LOGIN_URL); - this.filter.init(new MockFilterConfig()); - } - - protected void tearDown() throws Exception { - this.filter.destroy(); - } - - public void testRedirect() throws Exception { - final MockHttpSession session = new MockHttpSession(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest arg0, ServletResponse arg1) - throws IOException, ServletException { - // nothing to do - } - }; - - request.setSession(session); - this.filter.doFilter(request, response, filterChain); - - assertEquals(CAS_LOGIN_URL + "?service=" - + URLEncoder.encode(CAS_SERVICE_URL, "UTF-8"), response - .getRedirectedUrl()); - } - - public void testRedirectWithQueryString() throws Exception { - final MockHttpSession session = new MockHttpSession(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - request.setQueryString("test=12456"); - request.setRequestURI("/test"); - request.setSecure(true); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest arg0, ServletResponse arg1) - throws IOException, ServletException { - // nothing to do - } - }; - - request.setSession(session); - this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL); - this.filter.doFilter(request, response, filterChain); - - assertEquals(CAS_LOGIN_URL - + "?service=" - + URLEncoder.encode("https://localhost:8443" - + request.getRequestURI() + "?" + request.getQueryString(), - "UTF-8"), response.getRedirectedUrl()); - } - - public void testAssertion() throws Exception { - final MockHttpSession session = new MockHttpSession(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest arg0, ServletResponse arg1) - throws IOException, ServletException { - // nothing to do - } - }; - - request.setSession(session); - session.setAttribute(AbstractCasFilter.CONST_ASSERTION, - new AssertionImpl(new SimplePrincipal("test"))); - this.filter.doFilter(request, response, filterChain); - - assertNull(response.getRedirectedUrl()); - } - - public void testRenew() throws Exception { - final MockHttpSession session = new MockHttpSession(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest arg0, ServletResponse arg1) - throws IOException, ServletException { - // nothing to do - } - }; - - this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL); - this.filter.setRenew(true); - request.setSession(session); - this.filter.doFilter(request, response, filterChain); - - assertNotNull(response.getRedirectedUrl()); - assertTrue(response.getRedirectedUrl().indexOf("renew=true") != -1); - } - - public void testGateway() throws Exception { - final MockHttpSession session = new MockHttpSession(); - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest arg0, ServletResponse arg1) - throws IOException, ServletException { - // nothing to do - } - }; - - request.setSession(session); - this.filter = new AuthenticationFilter("localhost:8443", true, CAS_LOGIN_URL); - this.filter.setRenew(true); - this.filter.setGateway(true);; - this.filter.doFilter(request, response, filterChain); - assertNotNull(session.getAttribute(AbstractCasFilter.CONST_GATEWAY)); - assertNotNull(response.getRedirectedUrl()); - - final MockHttpServletResponse response2 = new MockHttpServletResponse(); - this.filter.doFilter(request, response2, filterChain); - assertNull(session.getAttribute(AbstractCasFilter.CONST_GATEWAY)); - assertNull(response2.getRedirectedUrl()); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthorizationFilterTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthorizationFilterTests.java deleted file mode 100644 index e8041cc..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/AuthorizationFilterTests.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Principal; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.client.authorization.AuthorizationException; -import org.jasig.cas.client.authorization.AuthorizedDecider; -import org.jasig.cas.client.validation.AssertionImpl; -import org.springframework.mock.web.MockFilterConfig; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockHttpSession; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; - -/** - * Tests for the AuthorizationFilter. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class AuthorizationFilterTests extends TestCase { - - private AuthorizationFilter casAuthorizationFilter; - - protected void setUp() throws Exception { - this.casAuthorizationFilter = new AuthorizationFilter(new AuthorizedDecider() { - - public boolean isAuthorizedToUseApplication(Principal principal) { - return principal.getId().equals("scott"); - } - }); - - this.casAuthorizationFilter.init(new MockFilterConfig()); - } - - protected void tearDown() throws Exception { - this.casAuthorizationFilter.destroy(); - } - - public void testSuccesfulAuthorization() { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - - session.setAttribute(AbstractCasFilter.CONST_ASSERTION, - new AssertionImpl(new SimplePrincipal("scott"))); - - try { - this.casAuthorizationFilter.doFilter(request, response, - new FilterChain() { - - public void doFilter(ServletRequest arg0, - ServletResponse arg1) throws IOException, - ServletException { - // nothing to do - } - }); - } catch (Exception e) { - fail("No exception expected"); - } - } - - public void testFailedAuthorization() { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - - session.setAttribute(AbstractCasFilter.CONST_ASSERTION, - new AssertionImpl(new SimplePrincipal("test"))); - - try { - this.casAuthorizationFilter.doFilter(request, response, null); - fail("ServletException expected."); - } catch (AuthorizationException e) { - // expectd - } catch (Exception e) { - fail("AuthorizationException expected, not IOException."); - } - } - - public void testNoAssertionFound() { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - - try { - this.casAuthorizationFilter.doFilter(request, response, null); - fail("ServletException expected."); - } catch (Exception e) { - // expected - } - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilterTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilterTests.java deleted file mode 100644 index 1f79f46..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/HttpServletRequestWrapperFilterTests.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.client.validation.AssertionImpl; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockHttpSession; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import java.io.IOException; - -/** - * Tests for the HttpServletRequestWrapperFilter. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ - -public final class HttpServletRequestWrapperFilterTests extends TestCase { - - private HttpServletRequestWrapperFilter filter = new HttpServletRequestWrapperFilter(); - - protected HttpServletRequest mockRequest; - - protected void setUp() throws Exception { - this.filter.init(null); - this.filter.destroy(); - } - - public void testWrappedRequest() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpSession session = new MockHttpSession(); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(ServletRequest request, - ServletResponse response) throws IOException, ServletException { - HttpServletRequestWrapperFilterTests.this.mockRequest = (HttpServletRequest) request; - } - - }; - session.setAttribute(AbstractCasFilter.CONST_ASSERTION, - new AssertionImpl(new SimplePrincipal("test"))); - - request.setSession(session); - - this.filter.doFilter(request, new MockHttpServletResponse(), - filterChain); - assertEquals("test", this.mockRequest.getRemoteUser()); - } -} diff --git a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/ValidationFilterTests.java b/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/ValidationFilterTests.java deleted file mode 100644 index ac180fb..0000000 --- a/cas-client-core/src/test/java/org/jasig/cas/client/web/filter/ValidationFilterTests.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.web.filter; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.AssertionImpl; -import org.jasig.cas.client.validation.TicketValidator; -import org.jasig.cas.client.validation.ValidationException; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.mock.web.MockHttpSession; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; - -/** - * Tests for the TicketValidationFilter. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ValidationFilterTests extends TestCase { - - private TicketValidationFilter filter; - - protected void setUp() throws Exception { - this.filter = new TicketValidationFilter("localhost:8443", true, new TicketValidator() { - - public Assertion validate(final String ticketId, - final Service service) throws ValidationException { - if (ticketId.equals("true")) { - return new AssertionImpl(new SimplePrincipal("test")); - } - throw new ValidationException("error validating ticket."); - } - }); - } - - protected void tearDown() throws Exception { - this.filter.destroy(); - } - - public void testNoTicket() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(final ServletRequest arg0, - final ServletResponse arg1) throws IOException, - ServletException { - // nothing to do - } - }; - - this.filter.doFilter(request, response, filterChain); - - assertNull(session.getAttribute(AbstractCasFilter.CONST_ASSERTION)); - } - - public void testValidationSuccess() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - request.setParameter("ticket", "true"); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(final ServletRequest arg0, - final ServletResponse arg1) throws IOException, - ServletException { - // nothing to do - } - }; - - this.filter.doFilter(request, response, filterChain); - - assertNotNull(session.getAttribute(AbstractCasFilter.CONST_ASSERTION)); - assertNull(response.getRedirectedUrl()); - } - - public void testValidationFailure() throws Exception { - final MockHttpServletRequest request = new MockHttpServletRequest(); - final MockHttpServletResponse response = new MockHttpServletResponse(); - final MockHttpSession session = new MockHttpSession(); - request.setSession(session); - request.setParameter("ticket", "false"); - final FilterChain filterChain = new FilterChain() { - - public void doFilter(final ServletRequest arg0, - final ServletResponse arg1) throws IOException, - ServletException { - // nothing to do - } - }; - - try { - this.filter.doFilter(request, response, filterChain); - fail("Exception expected."); - } catch (final ServletException e) { - assertTrue(e.getRootCause().getClass().isAssignableFrom( - ValidationException.class)); - // expected - } - } -} diff --git a/cas-client-core/src/test/resources/badProxyGrantingTicketStorageConfig.xml b/cas-client-core/src/test/resources/badProxyGrantingTicketStorageConfig.xml deleted file mode 100644 index 2e8ef16..0000000 --- a/cas-client-core/src/test/resources/badProxyGrantingTicketStorageConfig.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/cas-client-core/src/test/resources/oneProxyGrantingTicketStorageConfig.xml b/cas-client-core/src/test/resources/oneProxyGrantingTicketStorageConfig.xml deleted file mode 100644 index 0861e95..0000000 --- a/cas-client-core/src/test/resources/oneProxyGrantingTicketStorageConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cas-client-core/src/test/resources/proxyGrantingTicketStorageConfig.xml b/cas-client-core/src/test/resources/proxyGrantingTicketStorageConfig.xml deleted file mode 100644 index ea4f3bb..0000000 --- a/cas-client-core/src/test/resources/proxyGrantingTicketStorageConfig.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cas-client-core/src/test/resources/twoProxyGrantingTicketStorageConfig.xml b/cas-client-core/src/test/resources/twoProxyGrantingTicketStorageConfig.xml deleted file mode 100644 index e490dfa..0000000 --- a/cas-client-core/src/test/resources/twoProxyGrantingTicketStorageConfig.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/cas-client-uportal/LICENSE.txt b/cas-client-uportal/LICENSE.txt deleted file mode 100644 index 30c8573..0000000 --- a/cas-client-uportal/LICENSE.txt +++ /dev/null @@ -1,29 +0,0 @@ -License for Use - -Copyright (c) 2000 The JA-SIG Collaborative. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes software developed by the JA-SIG Collaborative - (http://www.ja-sig.org/)." - -This software is provided by the JA-SIG collaborative "as is" and any expressed -or implied warranties, including, but not limited to, the implied warranties of -merchantability and fitness for a particular purpose are disclaimed. In no -event shall the JA-SIG collaborative or its contributors be liable for any -direct, indirect, incidental, special, exemplary, or consequential damages -(including, but not limited to, procurement of substitute goods or services; -loss of use, data, or profits; or business interruption) however caused and on -any theory of liability, whether in contract, strict liability, or tort -(including negligence or otherwise) arising in any way out of the use of this -software, even if advised of the possibility of such damage. \ No newline at end of file diff --git a/cas-client-uportal/README.txt b/cas-client-uportal/README.txt deleted file mode 100644 index f5cd476..0000000 --- a/cas-client-uportal/README.txt +++ /dev/null @@ -1,28 +0,0 @@ -CENTRAL AUTHENTICATION SERVICE (CAS) --------------------------------------------------------------------- -http://www.ja-sig.org/products/cas/ - -1. INTRODUCTION - -The Central Authentication Service (CAS) is the standard mechanism by which web -applications should authenticate users. Any custom applications written benefit -from using CAS. - -Note that CAS provides authentication; that is, it determines that your users -are who they say they are. CAS should not be viewed as an access-control system; -in particular, providers of applications that grant access to anyone who -possesses a NetID should understand that loose affiliates of an organization may -be granted NetIDs. - -The JA-SIG CAS Client for Java is a support library for Java applications to communicate -with the CAS server. - -2. RELEASE INFO - -CAS requires J2SE 1.4 and J2EE1.3. - -Release conents: -* "src/main/java" contains the Java source files for the framework -* "src/test/java" contains the Java source files for CAS's test suite - - diff --git a/cas-client-uportal/cas-client-uportal.iml b/cas-client-uportal/cas-client-uportal.iml deleted file mode 100644 index afbc7b9..0000000 --- a/cas-client-uportal/cas-client-uportal.iml +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cas-client-uportal/pom.xml b/cas-client-uportal/pom.xml deleted file mode 100644 index 476fba1..0000000 --- a/cas-client-uportal/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - org.jasig.cas - cas-client - 3.1-m1 - - 4.0.0 - org.jasig.cas - cas-client-uportal - jar - 3.1-SNAPSHOT - JA-SIG CAS Client for Java - uPortal Integration - http://www.ja-sig.org/products/cas/ - - - src/main/java - src/test/java - - - src/test/resources - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.4 - 1.4 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*Tests* - - - - - org.apache.maven.plugins - maven-clover-plugin - - ${basedir}/src/test/clover/clover.license - - - - pre-site - - instrument - - - - - - - - - - org.jasig.uportal - uportal - 2.5.3-rc1 - provided - - - org.jasig.cas - cas-client-core - 3.1-m1 - - - - false - - - org.apache.maven.plugins - maven-clover-plugin - - ${basedir}/src/test/clover/clover.license - - - - org.apache.maven.plugins - maven-checkstyle-plugin - - - org.apache.maven.plugins - maven-javadoc-plugin - - 128m - 512m - - - - org.apache.maven.plugins - maven-jxr-plugin - - - org.apache.maven.plugins - maven-surefire-report-plugin - - - org.codehaus.mojo - jdepend-maven-plugin - - - - diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/AbstractCasSecurityContextFactory.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/AbstractCasSecurityContextFactory.java deleted file mode 100644 index 825418b..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/AbstractCasSecurityContextFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.validation.TicketValidator; -import org.jasig.portal.security.ISecurityContextFactory; -import org.jasig.portal.security.InitialSecurityContextFactory; -import org.jasig.portal.spring.PortalApplicationContextFacade; - -/** - * Abstract implementation of a SecurityContextFactory that can load all the dependences if a - * CasSecurityCcontext. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public abstract class AbstractCasSecurityContextFactory extends - InitialSecurityContextFactory implements ISecurityContextFactory { - - - /** - * Spring Bean ID for the Ticket Validator. - */ - public static final String CONST_CAS_TICKET_VALIDATOR = "casTicketValidator"; - - /** - * Spring Bean ID for the Service. - */ - public static final String CONST_CAS_SERVICE = "casService"; - - /** - * Spring Bean ID for the ProxyGrantingTicketStorage. - */ - public static final String CONST_CAS_PROXY_GRANTING_TICKET_STORAGE = "casProxyGrantingTicketStorage"; - - /** - * Instance of Commons Logging. - */ - protected final Log log = LogFactory.getLog(this.getClass()); - - /** - * The Ticket Validator referenced by the constant - * CONST_CAS_TICKET_VALIDATOR. - */ - protected final TicketValidator ticketValidator; - - /** - * The Service referenced by the constant CONST_CAS_SERVICE. - */ - protected final Service service; - - /** - * Default constructor retrieves and caches results from looking up entries - * in the PortalApplicationContext for the Ticket Validator, Proxy Retriever - * and Service. - */ - public AbstractCasSecurityContextFactory() { - this.ticketValidator = (TicketValidator) PortalApplicationContextFacade - .getPortalApplicationContext().getBean(CONST_CAS_TICKET_VALIDATOR); - this.service = (Service) PortalApplicationContextFacade - .getPortalApplicationContext().getBean(CONST_CAS_SERVICE); - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasConnectionContext.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasConnectionContext.java deleted file mode 100644 index fad40dc..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasConnectionContext.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.portal.ChannelRuntimeData; -import org.jasig.portal.ChannelStaticData; -import org.jasig.portal.security.ISecurityContext; -import org.jasig.portal.security.LocalConnectionContext; - -import java.util.Enumeration; - -/** - * Extension to LocalConnectionContext that will retrieve and append a proxy - * ticket to a given descriptor. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CasConnectionContext extends LocalConnectionContext { - - /** - * Instance of ICasSecurityContext. - */ - private ICasSecurityContext casSecurityContext; - - public String getDescriptor(String descriptor, - final ChannelRuntimeData channelRuntimeData) { - if (log.isTraceEnabled()) { - log.trace("getDescriptor(" + descriptor + ", " + channelRuntimeData - + ")"); - } - - descriptor = descriptor == null ? "null" : descriptor; - - if (channelRuntimeData.getHttpRequestMethod().equals("GET")) { - - if (this.casSecurityContext != null) { - final String proxyTicket = this.casSecurityContext - .getProxyTicket(new SimpleService(descriptor)); - - if (proxyTicket != null) { - // append ticket parameter and value to query string - if (descriptor.indexOf('?') != -1) { - descriptor = descriptor + "&ticket=" + proxyTicket; - } else { - descriptor = descriptor + "?ticket=" + proxyTicket; - } - } - } - } - - return descriptor; - } - - public void init(final ChannelStaticData channelStaticData) { - final ISecurityContext securityContext = channelStaticData.getPerson() - .getSecurityContext(); - - if (ICasSecurityContext.class.isAssignableFrom(securityContext - .getClass()) - && securityContext.isAuthenticated()) { - this.casSecurityContext = (ICasSecurityContext) securityContext; - } - - final Enumeration enumeration = securityContext.getSubContexts(); - - while (enumeration.hasMoreElements()) { - final ISecurityContext context = (ISecurityContext) enumeration - .nextElement(); - - if (ISecurityContext.class.isAssignableFrom(context.getClass()) - && context.isAuthenticated()) { - this.casSecurityContext = (ICasSecurityContext) context; - } - } - - if (this.casSecurityContext == null) { - log.warn("Unable to find authenticated ICasSecurityContext"); - } - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContext.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContext.java deleted file mode 100644 index 59e91af..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContext.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.TicketValidator; -import org.jasig.cas.client.validation.ValidationException; -import org.jasig.portal.security.PortalSecurityException; -import org.jasig.portal.security.provider.ChainingSecurityContext; - -/** - * Implementation of ICasSecurityContext that knows how to handle CAS ticket - * validation, as well as the retrieval of Proxy Tickets. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public class CasSecurityContext extends ChainingSecurityContext implements - ICasSecurityContext { - - /** - * Unique Id for Serialization - */ - private static final long serialVersionUID = 1L; - - /** - * Instance of TicketValidator to validate tickets. - */ - private final TicketValidator ticketValidator; - - /** - * Instance of Service representing uPortal instance. - */ - private final Service service; - - /** - * Assertion about the person this security context is for. - */ - private Assertion assertion; - - /** - * Instantiate a new CasSecurityContext, setting the required fields. - * - * @param ticketValidator the TicketValidator to validate tickets. - * @param service the Service representing the portal. - */ - public CasSecurityContext(final TicketValidator ticketValidator, final Service service) { - CommonUtils.assertNotNull(ticketValidator, "ticketValidator cannot be null."); - CommonUtils.assertNotNull(service, "service cannot be null."); - - log.trace("Initalizing CasSecurityContext"); - this.ticketValidator = ticketValidator; - this.service = service; - } - - public final String getProxyTicket(final Service targetService) { - return this.assertion.getProxyTicketFor(targetService); - } - - public final int getAuthType() { - return ICasSecurityContext.CAS_AUTHTYPE; - } - - public final synchronized void authenticate() throws PortalSecurityException { - this.isauth = false; - final String serviceTicket = new String( - this.myOpaqueCredentials.credentialstring); - final Service service = getService(); - - if (log.isDebugEnabled()) { - log.debug("Attempting to validate ticket [" + serviceTicket - + "] for service [" + service.toString()); - } - - try { - this.assertion = this.ticketValidator.validate(serviceTicket, - service); - this.myAdditionalDescriptor = null; - this.myPrincipal.setUID(this.assertion.getPrincipal().getId()); - this.isauth = true; - super.authenticate(); - } catch (final ValidationException e) { - log.warn(e, e); - throw new PortalSecurityException(e.getMessage(), e); - } - } - - protected Service getService() { - return this.service; - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactory.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactory.java deleted file mode 100644 index f9ffb98..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.portal.security.ISecurityContext; -import org.jasig.portal.security.ISecurityContextFactory; - -/** - * Implementation of an {@link ISecurityContextFactory} that on creation will - * retrieve references to Spring managed CAS client objects and pass them to all - * new CasSecurityContexts that are created. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CasSecurityContextFactory extends AbstractCasSecurityContextFactory { - - public CasSecurityContextFactory() { - super(); - } - - /** - * Instantiate a new instance of CasSecurityContext. - * - * @return a new ISecurityContext instance, specifically an instance of CasSecurityContext. - */ - public ISecurityContext getSecurityContext() { - log - .trace("Returning CasSecurityContext from CasSecurityContextFactory."); - return new CasSecurityContext(this.ticketValidator, this.service); - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ICasSecurityContext.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ICasSecurityContext.java deleted file mode 100644 index fa01ddc..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ICasSecurityContext.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.Service; - -/** - * Interface implemented by CAS security contexts. These implementations are - * aware of proxying, and can retrieve a ticket from CAS for accessing a - * specific service. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public interface ICasSecurityContext { - - /** - * Authentication type for CAS authentication - */ - public static final int CAS_AUTHTYPE = 0x1701; - - /** - * Retrieve a Proxy Ticket Id for a particular service we wish to proxy against. - * - * @param service the service to retrieve a proxy ticket for. - * @return the ticket id, or null if no ticket could be retrieved. - */ - String getProxyTicket(Service service); -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ServiceHolder.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ServiceHolder.java deleted file mode 100644 index 043f624..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ServiceHolder.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.util.CommonUtils; - -/** - * ThreadLocal container that exposes the service to lower layers in the authentication stack. Because of the ISecurityCcontext - * API this service url is not normally available. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ServiceHolder { - - private static final ThreadLocal threadLocal = new ThreadLocal(); - - public static void setService(final Service service) { - CommonUtils.assertNotNull(service, "service cannot be null."); - threadLocal.set(service); - } - - /** - * Method to retrieve the service from the ThreadLocal - * - * @return the service. Should not ever be null. - */ - public static Service getService() { - return (Service) threadLocal.get(); - } - - /** - * Reset the context to clear it out. - */ - public static void clearContext() { - threadLocal.set(null); - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContext.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContext.java deleted file mode 100644 index d3a360d..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContext.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.client.validation.TicketValidator; - -/** - * Extension of AbstractCasSecurityContext that retrieves the Service from the - * ServiceHolder ThreadLocal object. This allows for a more flexible service to - * be provided for ticket validation. This is needed as the normal - * ISecurityContext has no mechanism for service urls based on requests. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ThreadLocalAwareCasSecurityContext extends - CasSecurityContext { - - /** - * Unique Id for Serialization. - */ - private static final long serialVersionUID = 1L; - - /** - * Instantiate a new CasSecurityContext, setting the required fields. - * - * @param ticketValidator the Ticket Validator. - * @param service the Service instance representing this uPortal instance. - */ - public ThreadLocalAwareCasSecurityContext( - final TicketValidator ticketValidator, final Service service) { - super(ticketValidator, service); - } - - protected Service getService() { - return ServiceHolder.getService(); - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactory.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactory.java deleted file mode 100644 index c09c80d..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactory.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.portal.security.ISecurityContext; - -/** - * Factory to instantiate ThreadLocalAwareCasSecurityContexts. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ThreadLocalAwareCasSecurityContextFactory extends - AbstractCasSecurityContextFactory { - - public ISecurityContext getSecurityContext() { - return new ThreadLocalAwareCasSecurityContext(this.ticketValidator, - this.service); - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilter.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilter.java deleted file mode 100644 index 3efa862..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.util.CommonUtils; -import org.jasig.cas.client.web.filter.AbstractCasFilter; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -/** - * Filter to construct the service url from the request and place it in a - * ThreadLocal so its available to the - * {@link ThreadLocalAwareCasSecurityContext} in order to use it for Ticket - * validation. - *

This filter places the Service in a {@link ServiceHolder}. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ThreadLocalAwareCasServiceFilter extends AbstractCasFilter { - - public ThreadLocalAwareCasServiceFilter(final String service, final boolean isServerName) { - super(service, isServerName); - } - - protected void doFilterInternal(final HttpServletRequest request, - final HttpServletResponse response, final FilterChain filterChain) - throws IOException, ServletException { - final boolean hasTicket = CommonUtils.isNotBlank(request - .getParameter(getArgumentExtractor().getArtifactParameterName())); - try { - if (hasTicket) { - final Service service = new SimpleService(constructServiceUrl( - request, response)); - ServiceHolder.setService(service); - } - - filterChain.doFilter(request, response); - } finally { - if (hasTicket) { - ServiceHolder.clearContext(); - } - } - } -} diff --git a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServlet.java b/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServlet.java deleted file mode 100644 index a67a8f4..0000000 --- a/cas-client-uportal/src/main/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServlet.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2006 The JA-SIG Collaborative. All rights reserved. See license - * distributed with this file and available online at - * http://www.ja-sig.org/products/cas/overview/license/index.html - */ -package org.jasig.cas.client.integration.uportal; - -import org.jasig.cas.client.proxy.AbstractProxyReceptorServlet; -import org.jasig.cas.client.proxy.ProxyGrantingTicketStorage; -import org.jasig.portal.spring.PortalApplicationContextFacade; - -import javax.servlet.ServletConfig; -import javax.servlet.ServletException; - -/** - * Implementation of AbstractProxyReceptorServlet that retrieves the - * ProxyGrantingTicket storage from the Portal Application Context instead of a - * WebApplicationContext. - * - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class UPortalConfiguredProxyReceptorServlet extends - AbstractProxyReceptorServlet { - - /** - * Unique Id for Serialization. - */ - private static final long serialVersionUID = 6596608588362834646L; - - - protected ProxyGrantingTicketStorage retrieveProxyGrantingTicketStorageFromConfiguration(final ServletConfig servletConfig) throws ServletException { - logger.info("Retrieving ProxyGrantingTicketStorage from PortalApplicationContextFacade."); - return (ProxyGrantingTicketStorage) PortalApplicationContextFacade - .getPortalApplicationContext() - .getBean( - AbstractCasSecurityContextFactory.CONST_CAS_PROXY_GRANTING_TICKET_STORAGE); - } -} diff --git a/cas-client-uportal/src/main/resources/uportalCasConfigurationContext.xml b/cas-client-uportal/src/main/resources/uportalCasConfigurationContext.xml deleted file mode 100644 index fc09c28..0000000 --- a/cas-client-uportal/src/main/resources/uportalCasConfigurationContext.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cas-client-uportal/src/test/clover/clover.license b/cas-client-uportal/src/test/clover/clover.license deleted file mode 100644 index 8506a9d..0000000 --- a/cas-client-uportal/src/test/clover/clover.license +++ /dev/null @@ -1,166 +0,0 @@ -Product: Clover -License: Open Source License, 0.x, 1.x -Issued: Sun Feb 13 2005 22:45:43 CST -Expiry: Never -Key: aae4c7035b1208e316fa6d684 -Name: Scott Battaglia -Org: JA-SIG Central Authentication Service -Certificate: AAACCG+Ow8B7/zEbxOMqqKwwrdpP+a1COmJGHco7sCNLjHkHnajPF+dQW -Ct12PMy0uml0s9xuus5wKngJ9OFk5PFeh01dzQF66bhXH1bvegLfvja3Kle6BYtDv4LZgE -gk3E0aJN4IbgTn+TgUckSevXDR4KzK77NWJfrVzkxV3/JepYRA9UAbsXHiki9WjMIJfzoZ -unjvtTFd/vTOcyirgfT/dTPrG9PAGAjH+e37E9Xf7HnRSrmxtrGX+wdaBOlZFUIIcVHKT2 -IaGToLZnx7FvfE3rzyQCYtS+r0E+H61c+dANzySy5PEH2JEyL8M9JrwgYJSju1FWhxbXO2 -Gb7y3Diufo80+HWz6xrGzl9IlXRseoXHki8rllk5taXqVv5G3UIsTFzbjjWUDlykn557C2 -D4o9T0xQ/6dVFxak75o0MxP4aXGFMZNg/pCBH9DAU7/CKVKRBPAVx1PJ8vIy41MF4p9Mi1 -qmELNvjn9K9fwpaeiUG9qT8B0pfq/tTAObG2sZf7B1mFbA3YwEqjhNqLdkoca5swrS0DI1 -9OejIVIqjK+bvUZaqUDMxVX7fM6hwRvI9Wd+rwFG+X3wHYNPsZ+Cos8/BNPzIIoOh4SbTr -8vIqWUdPXM4HO26uAAVRKz6FknmwM/GQ7FyJBWgIXgXK51SLn+NcifxO8uywGewHzP00ki -frTPmy0+GrikleWry6BdWkg76hjrjQBalNlSmasi9yp9J8qdzVYvQlOBjS5EKWsvsSpXGY -MIdupkiv4a25aXsgdpGBy4GzcSUDioChq287HBBmYRIMVvp5OYbV3/+ERNhTlCQqb6Ck4g -891l1OJOEoMiDqcbDL8DNftlH4gybEE7zJXQRmmJKyw== -License Agreement: CLOVER VERSION 1 (ONE) SOFTWARE LICENSE AGREEMENT - -1. Licenses and Software - -Cortex eBusiness Pty Ltd, an Australian Proprietary Limited Company -("CENQUA") hereby grants to the purchaser (the "LICENSEE") a limited, -revocable, worldwide, non-exclusive, non-transferable, -non-sublicensable license to use the Clover version 1 (one) software -(the "Software"), including any minor upgrades thereof during the Term -(hereinafter defined) up to, but not including the next major version -of the Software. The licensee shall not, or knowingly allow others to, -reverse engineer, decompile, disassemble, modify, adapt, create -derivative works from or otherwise attempt to derive source code from -the Software provided. And, in accordance with the terms and -conditions of this Software License Agreement (the "Agreement"), the -Software shall be used solely by the licensed users in accordance with -the following edition specific conditions: - -a) Server Edition - -A Server Edition license entitles the Licensee to execute one instance -of Clover Server Edition on one (1) machine for the purposes of -instrumenting source code and generating reports. There are no -limitations on the use of the instrumented source code or generated -reports produced by Server Edition. - -b) Workstation Edition - -A Workstation Edition license entitles the licensee to use Clover -Workstation Edition on one (1) machine by one (1) individual end -user. Workstation Edition does not permit the generation of reports -for distribution. - -c) Team Edition - -A Team Edition license entitles the licensee to use Clover Team -edition on any number of machines solely by the licensed number of -users. Reports generated by Clover Team Edition are strictly for use -only by the licensed number of individual end users. - -2. License Fee - -In exchange for the License(s), the Licensee shall pay to Cenqua a -one-time, up front, non-refundable license fee. At the sole discretion -of Cenqua this fee will be waived for non-commercial -projects. Notwithstanding the Licensee's payment of the License Fee, -Cenqua reserves the right to terminate the License if Cenqua discovers -that the Licensee and/or the Licensee's use of the Software is in -breach of this Agreement. - -3. Proprietary Rights - -Cenqua will retain all right, title and interest in and to the -Software, all copies thereof, and Cenqua website(s), software, and -other intellectual property, including, but not limited to, ownership -of all copyrights, look and feel, trademark rights, design rights, -trade secret rights and any and all other intellectual property and -other proprietary rights therein. The Licensee will not directly or -indirectly obtain or attempt to obtain at any time, any right, title -or interest by registration or otherwise in or to the trademarks, -service marks, copyrights, trade names, symbols, logos or designations -or other intellectual property rights owned or used by Cenqua. All -technical manuals or other information provided by Cenqua to the -Licensee shall be the sole property of Cenqua. - -4. Term and Termination - -Subject to the other provisions hereof, this Agreement shall commence -upon the Licensee's opting into this Agreement and continue until the -Licensee discontinues use of the Software or the Agreement terminates -automatically upon the Licensee's breach of any term or condition of -this Agreement (the "Term"). Upon any such termination, the Licensee -will delete the Software immediately. - -5. Copying & Transfer - -The Licensee may copy the Software for back-up purposes only. The -Licensee may not assign or otherwise transfer the Software to any -third party. - -6. Specific Disclaimer of Warranty and Limitation of Liability - -THE SOFTWARE IS PROVIDED WITHOUT WARRANTY OF ANY KIND. CENQUA -DISCLAIMS ALL WARRANTIES, EXPRESSED OR IMPLIED, INCLUDING BUT NOT -LIMITED TO THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE. CENQUA WILL NOT BE LIABLE FOR ANY DAMAGES -ASSOCIATED WITH THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ORDINARY, -INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES OF ANY KIND, INCLUDING -BUT NOT LIMITED TO DAMAGES RELATING TO LOST DATA OR LOST PROFITS, EVEN -IF CENQUA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -7. Warranties and Representations - -Licensee Indemnification. CENQUA agrees to indemnify, defend and hold -the Licensee harmless from and against any and all liabilities, -damages, losses, claims, costs, and expenses (including reasonable -legal fees) arising out of or resulting from the Software or the use -thereof infringing upon, misappropriating or violating any patents, -copyrights, trademarks, or trade secret rights or other proprietary -rights of persons, firms or entities who are not parties to this -Agreement. - -CENQUA Indemnification. The Licensee warrants and represents that the -Licensee's actions with regard to the Software will be in compliance -with all applicable laws; and the Licensee agrees to indemnify, -defend, and hold CENQUA harmless from and against any and all -liabilities, damages, losses, claims, costs, and expenses (including -reasonable legal fees) arising out of or resulting from the -Licensee's failure to observe the use restrictions set forth herein. - -8. Publicity - -The Licensee grants permission for CENQUA to use Licensee's name -solely in customer lists. CENQUA shall not, without prior consent in -writing, use the Licensee's name, or that of its affiliates, in any -form with the specific exception of customer lists. CENQUA agrees to -remove Licensee's name from any and all materials within 7 days if -notified by the Licensee in writing. - -9. Governing Law - -This Agreement shall be governed by the laws of New South Wales, -Australia. - -10. Independent Contractors - -The parties are independent contractors with respect to each other, -and nothing in this Agreement shall be construed as creating an -employer-employee relationship, a partnership, agency relationship or -a joint venture between the parties. - -11. Assignment - -This Agreement is not assignable or transferable by the Licensee. -CENQUA in its sole discretion may transfer a license to a third party -at the written request of the Licensee. - -12. Entire Agreement - -This Agreement constitutes the entire agreement between the parties -concerning the Licensee's use of the Software. This Agreement -supersedes any prior verbal understanding between the parties and any -Licensee purchase order or other ordering document, regardless of -whether such document is received by CENQUA before or after execution -of this Agreement. This Agreement may be amended only in writing by -CENQUA. diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactoryTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactoryTests.java deleted file mode 100644 index edcb4db..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextFactoryTests.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.portal.security.ISecurityContext; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CasSecurityContextFactoryTests extends TestCase { - - private CasSecurityContextFactory casSecurityContextFactory; - - - protected void setUp() throws Exception { - this.casSecurityContextFactory = new CasSecurityContextFactory(); - } - - public void testGetter() { - final ISecurityContext casSecurityContext = this.casSecurityContextFactory.getSecurityContext(); - assertNotNull(casSecurityContext); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextTests.java deleted file mode 100644 index 9d3b74e..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/CasSecurityContextTests.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimplePrincipal; -import org.jasig.cas.authentication.principal.SimpleService; -import org.jasig.cas.client.proxy.ProxyRetriever; -import org.jasig.cas.client.validation.Assertion; -import org.jasig.cas.client.validation.AssertionImpl; -import org.jasig.cas.client.validation.TicketValidator; -import org.jasig.cas.client.validation.ValidationException; -import org.jasig.portal.security.PortalSecurityException; - -import java.util.HashMap; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class CasSecurityContextTests extends TestCase { - - private CasSecurityContext context; - - - protected void setUp() throws Exception { - this.context = new CasSecurityContext(new TicketValidator() { - - public Assertion validate(String ticketId, Service service) throws ValidationException { - return new AssertionImpl(new SimplePrincipal("test"), new HashMap()); - } - }, new SimpleService("test")); - this.context.getOpaqueCredentialsInstance().setCredentials("ticket"); - } - - public void testAuthenticate() throws Exception { - this.context.authenticate(); - - assertEquals("test", this.context.getPrincipal().getUID()); - assertTrue(this.context.isAuthenticated()); - assertNull(this.context.getProxyTicket(new SimpleService("test"))); - } - - public void testAuthenticateWithProxy() throws Exception { - this.context = new CasSecurityContext(new TicketValidator() { - - public Assertion validate(String ticketId, Service service) throws ValidationException { - return new AssertionImpl(new SimplePrincipal("test"), new HashMap(), new ProxyRetriever() { - - public String getProxyTicketIdFor(String proxyGrantingTicketId, Service targetService) { - return "test"; - } - }, "proxyTicketId"); - } - }, new SimpleService("test")); - this.context.getOpaqueCredentialsInstance().setCredentials("ticket"); - this.context.authenticate(); - assertEquals("test", this.context.getProxyTicket(new SimpleService("test"))); - - } - - public void testAuthenticateFail() { - this.context = new CasSecurityContext(new TicketValidator() { - - public Assertion validate(String ticketId, Service service) throws ValidationException { - throw new ValidationException("test"); - } - }, new SimpleService("test")); - this.context.getOpaqueCredentialsInstance().setCredentials("ticket"); - - try { - this.context.authenticate(); - fail("Exception expected."); - } catch (PortalSecurityException e) { - assertTrue(e.getCause() instanceof ValidationException); - } - } - - public void testGetAuthType() { - assertEquals(ICasSecurityContext.CAS_AUTHTYPE, this.context.getAuthType()); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ServiceHolderTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ServiceHolderTests.java deleted file mode 100644 index 143b996..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ServiceHolderTests.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; - -/** - * @author Scott Battaglia - * @version $Revision$ $Datet$ - * @since 3.0 - */ -public final class ServiceHolderTests extends TestCase { - - public void testSetGetService() { - final Service service = new SimpleService("test"); - ServiceHolder.setService(service); - - assertEquals(service, ServiceHolder.getService()); - } - - public void testClearContext() { - final Service service = new SimpleService("test"); - ServiceHolder.setService(service); - - assertEquals(service, ServiceHolder.getService()); - - ServiceHolder.clearContext(); - - assertNull(ServiceHolder.getService()); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactoryTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactoryTests.java deleted file mode 100644 index e15b4c2..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextFactoryTests.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.portal.security.ISecurityContext; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ThreadLocalAwareCasSecurityContextFactoryTests extends TestCase { - - private ThreadLocalAwareCasSecurityContextFactory factory; - - protected void setUp() throws Exception { - this.factory = new ThreadLocalAwareCasSecurityContextFactory(); - } - - public void testGetter() { - ISecurityContext context = this.factory.getSecurityContext(); - - assertNotNull(context); - assertTrue(context instanceof ThreadLocalAwareCasSecurityContext); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextTests.java deleted file mode 100644 index 8fc664f..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasSecurityContextTests.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.Service; -import org.jasig.cas.authentication.principal.SimpleService; - -/** - * @author Scott - */ -public final class ThreadLocalAwareCasSecurityContextTests extends TestCase { - - private ThreadLocalAwareCasSecurityContext context; - - - protected void setUp() throws Exception { - final ThreadLocalAwareCasSecurityContextFactory factory = new ThreadLocalAwareCasSecurityContextFactory(); - this.context = (ThreadLocalAwareCasSecurityContext) factory.getSecurityContext(); - } - - public void testGetService() { - final Service service = new SimpleService("test"); - ServiceHolder.setService(service); - - assertEquals(service, this.context.getService()); - - ServiceHolder.clearContext(); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilterTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilterTests.java deleted file mode 100644 index e05dae4..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/ThreadLocalAwareCasServiceFilterTests.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.jasig.cas.authentication.principal.SimpleService; -import org.springframework.mock.web.MockHttpServletRequest; -import org.springframework.mock.web.MockHttpServletResponse; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import java.io.IOException; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class ThreadLocalAwareCasServiceFilterTests extends TestCase { - - private ThreadLocalAwareCasServiceFilter filter; - - - protected void setUp() throws Exception { - this.filter = new ThreadLocalAwareCasServiceFilter("http://localhost", false); - } - - public void testServiceSetter() throws IOException, ServletException { - final MockHttpServletRequest request = new MockHttpServletRequest(); - - request.setParameter("ticket", "test"); - this.filter.doFilter(request, new MockHttpServletResponse(), new FilterChain() { - - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { - assertNotNull(ServiceHolder.getService()); - assertEquals(new SimpleService("http://localhost"), ServiceHolder.getService()); - } - }); - } - - public void testNoServiceSetter() throws IOException, ServletException { - final MockHttpServletRequest request = new MockHttpServletRequest(); - - this.filter.doFilter(request, new MockHttpServletResponse(), new FilterChain() { - - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { - assertNull(ServiceHolder.getService()); - } - }); - } -} diff --git a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServletTests.java b/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServletTests.java deleted file mode 100644 index 70f9d44..0000000 --- a/cas-client-uportal/src/test/java/org/jasig/cas/client/integration/uportal/UPortalConfiguredProxyReceptorServletTests.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.jasig.cas.client.integration.uportal; - -import junit.framework.TestCase; -import org.springframework.mock.web.MockServletConfig; -import org.springframework.mock.web.MockServletContext; - -/** - * @author Scott Battaglia - * @version $Revision$ $Date$ - * @since 3.0 - */ -public final class UPortalConfiguredProxyReceptorServletTests extends TestCase { - - public void testInitialization() throws Exception { - final UPortalConfiguredProxyReceptorServlet servlet = new UPortalConfiguredProxyReceptorServlet(); - servlet.init(new MockServletConfig(new MockServletContext())); - } -} diff --git a/cas-client-uportal/src/test/resources/properties/beanRefFactory.xml b/cas-client-uportal/src/test/resources/properties/beanRefFactory.xml deleted file mode 100644 index a2e0090..0000000 --- a/cas-client-uportal/src/test/resources/properties/beanRefFactory.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - properties/uPortalConfigContext.xml - - - - \ No newline at end of file diff --git a/cas-client-uportal/src/test/resources/properties/uPortalConfigContext.xml b/cas-client-uportal/src/test/resources/properties/uPortalConfigContext.xml deleted file mode 100644 index dd59ed5..0000000 --- a/cas-client-uportal/src/test/resources/properties/uPortalConfigContext.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cas-client.iml b/cas-client.iml deleted file mode 100644 index 37fc5c5..0000000 --- a/cas-client.iml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cas-client.ipr b/cas-client.ipr deleted file mode 100644 index 115837d..0000000 --- a/cas-client.ipr +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cas-client.iws b/cas-client.iws deleted file mode 100644 index 4328cd9..0000000 --- a/cas-client.iws +++ /dev/null @@ -1,786 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index f4fdd0c..0000000 --- a/pom.xml +++ /dev/null @@ -1,218 +0,0 @@ - - 4.0.0 - org.jasig.cas - 3.1-m1 - cas-client - pom - JA-SIG CAS Client for Java - JA-SIG CAS Client for Java is the integration point for applications that want to speak with a CAS - server, either via the CAS 1.0 or CAS 2.0 protocol. - - http://www.ja-sig.org/products/cas/ - - JIRA - http://www.ja-sig.org/issues - - - QuickBuild - http://developer.ja-sig.org/builds/ - - 2006 - - - CAS Community Discussion List - http://tp.its.yale.edu/mailman/listinfo/cas - http://tp.its.yale.edu/mailman/listinfo/cas - cas@tp.its.yale.edu - http://tp.its.yale.edu/pipermail/cas/ - - http://news.gmane.org/gmane.comp.java.jasig.cas.user - - - - CAS Developers Discussion List - http://tp.its.yale.edu/mailman/listinfo/cas-dev - http://tp.its.yale.edu/mailman/listinfo/cas-dev - cas-dev@tp.its.yale.edu - http://tp.its.yale.edu/pipermail/cas-dev/ - - http://news.gmane.org/gmane.comp.java.jasig.cas.devel - - - - - - battags - Scott Battaglia - scott_battaglia@rutgers.edu - http://www.scottbattaglia.com - Rutgers, the State University of New Jersey - http://www.rutgers.edu - - Project Admin - Developer - - -5 - - - - - JA-SIG License for Use - http://www.ja-sig.org/products/cas/overview/license/ - manual - - - - scm:cvs:pserver:anonymous:@developer.ja-sig.org:2401/home/cvs/jasig:cas-clients/java-client - - - scm:cvs:pserver:${username}@developer.ja-sig.org:2401/home/cvs/jasig:cas-clients/java-client - - http://developer.ja-sig.org/source/browse/jasig/cas-clients/java-client - - - JA-SIG - http://www.ja-sig.org - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2-SNAPSHOT - - - ${basedir}/assembly.xml - - - - - - - - - junit - junit - 3.8.1 - test - - - commons-logging - commons-logging - 1.1 - compile - - - log4j - log4j - - - logkit - logkit - - - avalon-framework - avalon-framework - - - - - org.jasig.cas - cas-server-core - 3.1-m1 - compile - - - - xml-security - xmlsec - - - - com.sun.jndi.ldap - ldapbp - - - - org.springframework - spring - - - - log4j - log4j - - - - org.springframework - spring-binding - - - - org.springframework - spring-webflow - - - - commons-lang - commons-lang - - - - org.springframework - spring-ldap - - - - - - org.springframework - spring-beans - 2.0.2 - compile - - - org.springframework - spring-core - 2.0.2 - compile - - - javax.servlet - servlet-api - 2.4 - provided - - - - - - jasig - JA-SIG Maven Repository - http://developer.ja-sig.org/maven2/ - default - - - ibiblio - Ibiblio Repository - http://www.ibiblio.org/maven2 - - - - - mojo - Codehaus Repository - http://snapshots.maven.codehaus.org/maven2 - - - ibiblio - Ibiblio Repository - http://www.ibiblio.org/maven2 - - - - cas-client-core - cas-client-uportal - - \ No newline at end of file