added significantly more logging
This commit is contained in:
Scott Battaglia 2008-06-09 17:24:31 +00:00
parent 88b89a3756
commit 88b87074dc
10 changed files with 66 additions and 3 deletions

View File

@ -1,5 +1,7 @@
package org.jasig.cas.client.authentication;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.proxy.ProxyRetriever;
import org.jasig.cas.client.util.CommonUtils;
@ -14,6 +16,8 @@ import java.util.Map;
* @since 3.1
*/
public class AttributePrincipalImpl implements AttributePrincipal {
private static final Log LOG = LogFactory.getLog(AttributePrincipalImpl.class);
/** Unique Id for Serialization */
private static final long serialVersionUID = -8810123156070148535L;
@ -86,6 +90,8 @@ public class AttributePrincipalImpl implements AttributePrincipal {
if (proxyGrantingTicket != null) {
return this.proxyRetriever.getProxyTicketIdFor(this.proxyGrantingTicket, service);
}
LOG.debug("No ProxyGrantingTicket was supplied, so no Proxy Ticket can be retrieved.");
return null;
}

View File

@ -58,8 +58,11 @@ public class AuthenticationFilter extends AbstractCasFilter {
protected void initInternal(final FilterConfig filterConfig) throws ServletException {
super.initInternal(filterConfig);
setCasServerLoginUrl(getPropertyFromInitParams(filterConfig, "casServerLoginUrl", null));
log.trace("Loaded CasServerLoginUrl parameter: " + this.casServerLoginUrl);
setRenew(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "renew", "false")));
log.trace("Loaded renew parameter: " + this.renew);
setGateway(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "gateway", "false")));
log.trace("Loaded gateway parameter: " + this.gateway);
}
public void init() {
@ -85,6 +88,11 @@ public class AuthenticationFilter extends AbstractCasFilter {
}
final String serviceUrl = constructServiceUrl(request, response);
if (log.isDebugEnabled()) {
log.debug("Constructed service url: " + serviceUrl);
}
final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(), serviceUrl, this.renew, this.gateway);
if (log.isDebugEnabled()) {

View File

@ -11,6 +11,9 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Implementation of {@link ProxyGrantingTicketStorage} that is backed by a
* HashMap that keeps a ProxyGrantingTicket for a specified amount of time.
@ -23,6 +26,8 @@ import java.util.Map;
*/
public final class ProxyGrantingTicketStorageImpl implements
ProxyGrantingTicketStorage {
private final Log log = LogFactory.getLog(getClass());
/**
* Default timeout in milliseconds.
@ -63,11 +68,15 @@ public final class ProxyGrantingTicketStorageImpl implements
.get(proxyGrantingTicketIou);
if (holder == null) {
log.info("No Proxy Ticket found for " + proxyGrantingTicketIou);
return null;
}
this.cache.remove(holder);
if (log.isDebugEnabled()) {
log.debug("Returned ProxyGrantingTicket of " + holder.getProxyGrantingTicket());
}
return holder.getProxyGrantingTicket();
}
@ -76,6 +85,9 @@ public final class ProxyGrantingTicketStorageImpl implements
final ProxyGrantingTicketHolder holder = new ProxyGrantingTicketHolder(
proxyGrantingTicket);
if (log.isDebugEnabled()) {
log.debug("Saving ProxyGrantingTicketIOU and ProxyGrantingTicket combo: [" + proxyGrantingTicketIou + ", " + proxyGrantingTicket + "]");
}
this.cache.put(proxyGrantingTicketIou, holder);
}

View File

@ -71,8 +71,8 @@ public final class SingleSignOutFilter extends AbstractConfigurationFilter {
if (session != null) {
String sessionID = session.getId();
if (log.isTraceEnabled()) {
log.trace ("Invalidating session [" + sessionID + "] for ST [" + sessionIdentifier + "]");
if (log.isDebugEnabled()) {
log.debug ("Invalidating session [" + sessionID + "] for ST [" + sessionIdentifier + "]");
}
try {
@ -85,8 +85,12 @@ public final class SingleSignOutFilter extends AbstractConfigurationFilter {
}
}
} else {
final String artifact = request.getParameter(this.artifactParameterName);
final String artifact = request.getParameter(this.artifactParameterName);
final HttpSession session = request.getSession();
if (log.isDebugEnabled() && session != null) {
log.debug("Storing session identifier for " + session.getId());
}
if (CommonUtils.isNotBlank(artifact)) {
SESSION_MAPPING_STORAGE.addSessionById(artifact, session);
}

View File

@ -9,6 +9,9 @@ import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Listener to detect when an HTTP session is destroyed and remove it from the map of
* managed sessions. Also allows for the programmatic removal of sessions.
@ -21,6 +24,8 @@ import javax.servlet.http.HttpSessionListener;
*/
public final class SingleSignOutHttpSessionListener implements HttpSessionListener {
private Log log = LogFactory.getLog(getClass());
private SessionMappingStorage SESSION_MAPPING_STORAGE;
public void sessionCreated(final HttpSessionEvent event) {
@ -32,6 +37,11 @@ public final class SingleSignOutHttpSessionListener implements HttpSessionListen
SESSION_MAPPING_STORAGE = getSessionMappingStorage();
}
final HttpSession session = event.getSession();
if (log.isDebugEnabled()) {
log.debug("Removing HttpSession: " + session.getId());
}
SESSION_MAPPING_STORAGE.removeBySessionById(session.getId());
}

View File

@ -49,10 +49,15 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
public final void init(final FilterConfig filterConfig) throws ServletException {
setServerName(getPropertyFromInitParams(filterConfig, "serverName", null));
log.trace("Loading serverName property: " + this.serverName);
setService(getPropertyFromInitParams(filterConfig, "service", null));
log.trace("Loading service property: " + this.service);
setArtifactParameterName(getPropertyFromInitParams(filterConfig, "artifactParameterName", "ticket"));
log.trace("Loading artifact parameter name property: " + this.artifactParameterName);
setServiceParameterName(getPropertyFromInitParams(filterConfig, "serviceParameterName", "service"));
log.trace("Loading serviceParameterName property: " + this.serviceParameterName);
setEncodeServiceUrl(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "encodeServiceUrl", "true")));
log.trace("Loading encodeServiceUrl property: " + this.encodeServiceUrl);
initInternal(filterConfig);
init();

View File

@ -62,8 +62,11 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
protected void initInternal(final FilterConfig filterConfig) throws ServletException {
super.initInternal(filterConfig);
setExceptionOnValidationFailure(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "exceptionOnValidationFailure", "true")));
log.trace("Setting exceptionOnValidationFailure parameter: " + this.exceptionOnValidationFailure);
setRedirectAfterValidation(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "redirectAfterValidation", "false")));
log.trace("Setting redirectAfterValidation parameter: " + this.redirectAfterValidation);
setUseSession(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "useSession", "true")));
log.trace("Setting useSession parameter: " + this.useSession);
setTicketValidator(getTicketValidator(filterConfig));
}
@ -154,6 +157,7 @@ public abstract class AbstractTicketValidationFilter extends AbstractCasFilter {
}
if (this.redirectAfterValidation) {
log. debug("Redirecting after successful ticket validation.");
response.sendRedirect(response
.encodeRedirectURL(constructServiceUrl(request, response)));
return;

View File

@ -83,6 +83,7 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
protected final String constructValidationUrl(final String ticket, final String serviceUrl) {
final Map urlParameters = new HashMap();
log.debug("Placing URL parameters in map.");
urlParameters.put("ticket", ticket);
urlParameters.put("service", encodeUrl(serviceUrl));
@ -90,8 +91,10 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
urlParameters.put("renew", "true");
}
log.debug("Calling template URL attribute map.");
populateUrlAttributeMap(urlParameters);
log.debug("Loading custom parameters from configuration.");
if (this.customParameters != null) {
urlParameters.putAll(this.customParameters);
}
@ -164,14 +167,20 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
public Assertion validate(final String ticket, final String service) throws TicketValidationException {
log.debug("Constructing validation url.");
final String validationUrl = constructValidationUrl(ticket, service);
try {
log.debug("Retrieving response from server.");
final String serverResponse = retrieveResponseFromServer(new URL(validationUrl), ticket);
if (serverResponse == null) {
throw new TicketValidationException("The CAS server returned no response.");
}
if (log.isDebugEnabled()) {
log.debug("Server response: " + serverResponse);
}
return parseResponseFromServer(serverResponse);
} catch (final MalformedURLException e) {

View File

@ -64,6 +64,7 @@ public class Cas20ProxyReceivingTicketValidationFilter extends AbstractTicketVal
protected void initInternal(final FilterConfig filterConfig) throws ServletException {
super.initInternal(filterConfig);
setProxyReceptorUrl(getPropertyFromInitParams(filterConfig, "proxyReceptorUrl", null));
log.trace("Setting proxyReceptorUrl parameter: " + this.proxyReceptorUrl);
}
public void init() {

View File

@ -38,4 +38,8 @@ public final class ProxyList {
return false;
}
public String toString() {
return this.proxyChains.toString();
}
}