Logging improvements.
This commit is contained in:
Marvin S. Addison 2010-09-22 15:00:48 +00:00
parent 29866f923e
commit c7c8404259
10 changed files with 68 additions and 33 deletions

View File

@ -70,7 +70,7 @@ public abstract class AbstractAuthenticator extends AuthenticatorBase implements
public void start() throws LifecycleException {
super.start();
this.log.debug("Starting...");
this.log.debug(getName() + " starting.");
final Realm realm = this.context.getRealm();
try {
CommonUtils.assertTrue(realm instanceof CasRealm, "Expected CasRealm but got " + realm.getInfo());
@ -153,7 +153,7 @@ public abstract class AbstractAuthenticator extends AuthenticatorBase implements
/** {@inheritDoc} */
public void lifecycleEvent(final LifecycleEvent event) {
if (AFTER_START_EVENT.equals(event.getType())) {
this.log.debug("Processing lifecycle event " + AFTER_START_EVENT);
this.log.debug(getName() + " processing lifecycle event " + AFTER_START_EVENT);
this.delegate.setTicketValidator(getTicketValidator());
this.delegate.setArtifactParameterName(getArtifactParameterName());
this.delegate.setServiceParameterName(getServiceParameterName());
@ -162,6 +162,11 @@ public abstract class AbstractAuthenticator extends AuthenticatorBase implements
/** {@inheritDoc} */
public String getInfo() {
return getClass().getName() + "/1.0";
return getName() + "/1.0";
}
/**
* @return Authenticator descriptive name.
*/
protected abstract String getName();
}

View File

@ -46,12 +46,16 @@ public abstract class AbstractLifecycleValve extends ValveBase implements Lifecy
/** {@inheritDoc} */
public void start() throws LifecycleException {
log.debug("Valve starting.");
log.debug(getName() + " starting.");
}
/** {@inheritDoc} */
public void stop() throws LifecycleException {
log.debug("Valve stopping.");
log.debug(getName() + " stopping.");
}
/**
* @return Descriptive valve name.
*/
protected abstract String getName();
}

View File

@ -24,6 +24,12 @@ import java.io.IOException;
*/
public abstract class AbstractLogoutValve extends AbstractLifecycleValve {
protected String redirectUrl;
public void setRedirectUrl(final String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public final void invoke(final Request request, final Response response) throws IOException, ServletException {
if (!isLogoutRequest(request)) {
this.log.debug("URI is not a logout request: " + request.getRequestURI());
@ -53,6 +59,16 @@ public abstract class AbstractLogoutValve extends AbstractLifecycleValve {
}
}
/**
* Constructs a url to redirect to.
*
* @param request the original request.
* @return the url to redirect to. CAN be NULL.
*/
protected String constructRedirectUrl(final Request request) {
return redirectUrl;
}
/**
* Determines if this is a request to destroy the container-managed single sign on session.
*
@ -61,11 +77,4 @@ public abstract class AbstractLogoutValve extends AbstractLifecycleValve {
*/
protected abstract boolean isLogoutRequest(Request request);
/**
* Constructs a url to redirect to.
*
* @param request the original request.
* @return the url to redirect to. CAN be NULL.
*/
protected abstract String constructRedirectUrl(Request request);
}

View File

@ -19,6 +19,8 @@ import org.jasig.cas.client.validation.TicketValidator;
public class Cas10CasAuthenticator extends AbstractCasAuthenticator {
public static final String AUTH_METHOD = "CAS10";
private static final String NAME = Cas10CasAuthenticator.class.getName();
private Cas10TicketValidator ticketValidator;
protected TicketValidator getTicketValidator() {
@ -29,6 +31,10 @@ public class Cas10CasAuthenticator extends AbstractCasAuthenticator {
return AUTH_METHOD;
}
protected String getName() {
return NAME;
}
public void start() throws LifecycleException {
super.start();
this.ticketValidator = new Cas10TicketValidator(getCasServerUrlPrefix());

View File

@ -18,6 +18,8 @@ import org.jasig.cas.client.validation.TicketValidator;
*/
public final class Cas20CasAuthenticator extends AbstractCasAuthenticator {
public static final String AUTH_METHOD = "CAS20";
private static final String NAME = Cas20CasAuthenticator.class.getName();
private Cas20ServiceTicketValidator ticketValidator;
@ -29,6 +31,10 @@ public final class Cas20CasAuthenticator extends AbstractCasAuthenticator {
return AUTH_METHOD;
}
protected String getName() {
return NAME;
}
public void start() throws LifecycleException {
super.start();
this.ticketValidator = new Cas20ServiceTicketValidator(getCasServerUrlPrefix());

View File

@ -20,6 +20,8 @@ import org.jasig.cas.client.validation.TicketValidator;
public final class Cas20ProxyCasAuthenticator extends AbstractCasAuthenticator {
public static final String AUTH_METHOD = "CAS20-PROXY";
private static final String NAME = Cas20ProxyCasAuthenticator.class.getName();
private Cas20ProxyTicketValidator ticketValidator;
private boolean acceptAnyProxy;
@ -42,6 +44,10 @@ public final class Cas20ProxyCasAuthenticator extends AbstractCasAuthenticator {
return AUTH_METHOD;
}
protected String getName() {
return NAME;
}
public void start() throws LifecycleException {
super.start();
this.ticketValidator = new Cas20ProxyTicketValidator(getCasServerUrlPrefix());

View File

@ -26,6 +26,7 @@ import java.io.IOException;
* @since 3.1.12
*/
public final class ProxyCallbackValve extends AbstractLifecycleValve {
private static final String NAME = ProxyCallbackValve.class.getName();
private static ProxyGrantingTicketStorage PROXY_GRANTING_TICKET_STORAGE;
@ -68,4 +69,9 @@ public final class ProxyCallbackValve extends AbstractLifecycleValve {
getNext().invoke(request, response);
}
/** {@inheritDoc} */
protected String getName() {
return NAME;
}
}

View File

@ -20,21 +20,16 @@ import java.util.regex.Pattern;
* @since 3.1.12
*/
public final class RegExpBasedLogoutValve extends AbstractLogoutValve {
private static final String NAME = RegExpBasedLogoutValve.class.getName();
private String regexpUri;
private Pattern regexpUriPattern;
private String redirectUrl;
public void setRegexpUri(final String regexpUri) {
this.regexpUri = regexpUri;
}
public void setRedirectUrl(final String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public void start() throws LifecycleException {
super.start();
@ -52,7 +47,8 @@ public final class RegExpBasedLogoutValve extends AbstractLogoutValve {
return this.regexpUriPattern.matcher(request.getRequestURI()).matches();
}
protected String constructRedirectUrl(final Request request) {
return this.redirectUrl;
/** {@inheritDoc} */
protected String getName() {
return NAME;
}
}

View File

@ -19,6 +19,8 @@ import org.jasig.cas.client.validation.TicketValidator;
public class Saml11Authenticator extends AbstractAuthenticator {
public static final String AUTH_METHOD = "SAML11";
private static final String NAME = Saml11Authenticator.class.getName();
private Saml11TicketValidator ticketValidator;
/** SAML protocol clock drift tolerance in ms */
@ -64,4 +66,8 @@ public class Saml11Authenticator extends AbstractAuthenticator {
return "TARGET";
}
protected String getName() {
return NAME;
}
}

View File

@ -17,11 +17,10 @@ import org.jasig.cas.client.util.CommonUtils;
* @since 3.1.12
*/
public final class UrlBasedLogoutValve extends AbstractLogoutValve {
private static final String NAME = UrlBasedLogoutValve.class.getName();
private String logoutUri;
private String redirectUrl;
/**
* The logout url to watch for logout requests.
*
@ -31,15 +30,6 @@ public final class UrlBasedLogoutValve extends AbstractLogoutValve {
this.logoutUri = logoutUri;
}
/**
* Optional url to redirect to after logout is complete.
*
* @param redirectUrl the url. CAN be NULL.
*/
public void setRedirectUrl(final String redirectUrl) {
this.redirectUrl = redirectUrl;
}
public void start() throws LifecycleException {
super.start();
try {
@ -55,7 +45,8 @@ public final class UrlBasedLogoutValve extends AbstractLogoutValve {
return this.logoutUri.equals(request.getRequestURI());
}
protected String constructRedirectUrl(final Request request) {
return redirectUrl;
/** {@inheritDoc} */
protected String getName() {
return NAME;
}
}