migrated some to SLF4J
This commit is contained in:
Scott Battaglia 2013-01-08 23:32:35 -05:00
parent 27d89ccb30
commit f2df7a8603
16 changed files with 142 additions and 176 deletions

View File

@ -27,6 +27,12 @@
<version>${opensaml.version}</version> <version>${opensaml.version}</version>
<type>jar</type> <type>jar</type>
<scope>compile</scope> <scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
@ -56,6 +62,12 @@
<artifactId>spring-core</artifactId> <artifactId>spring-core</artifactId>
<version>${spring.version}</version> <version>${spring.version}</version>
<scope>test</scope> <scope>test</scope>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
@ -88,7 +100,7 @@
</dependencies> </dependencies>
<properties> <properties>
<spring.version>2.5.6.SEC01</spring.version> <spring.version>3.1.3.RELEASE</spring.version>
<opensaml.version>2.5.1-1</opensaml.version> <opensaml.version>2.5.1-1</opensaml.version>
</properties> </properties>
</project> </project>

View File

@ -19,10 +19,10 @@
package org.jasig.cas.client.authentication; 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.proxy.ProxyRetriever;
import org.jasig.cas.client.util.CommonUtils; import org.jasig.cas.client.util.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Collections; import java.util.Collections;
import java.util.Map; import java.util.Map;
@ -35,8 +35,8 @@ import java.util.Map;
* @since 3.1 * @since 3.1
*/ */
public class AttributePrincipalImpl extends SimplePrincipal implements AttributePrincipal { public class AttributePrincipalImpl extends SimplePrincipal implements AttributePrincipal {
private static final Log LOG = LogFactory.getLog(AttributePrincipalImpl.class); private static final Logger LOGGER = LoggerFactory.getLogger(AttributePrincipalImpl.class);
/** Unique Id for Serialization */ /** Unique Id for Serialization */
private static final long serialVersionUID = -1443182634624927187L; private static final long serialVersionUID = -1443182634624927187L;
@ -106,7 +106,7 @@ public class AttributePrincipalImpl extends SimplePrincipal implements Attribute
return this.proxyRetriever.getProxyTicketIdFor(this.proxyGrantingTicket, service); return this.proxyRetriever.getProxyTicketIdFor(this.proxyGrantingTicket, service);
} }
LOG.debug("No ProxyGrantingTicket was supplied, so no Proxy Ticket can be retrieved."); LOGGER.debug("No ProxyGrantingTicket was supplied, so no Proxy Ticket can be retrieved.");
return null; return null;
} }
} }

View File

@ -73,11 +73,11 @@ public class AuthenticationFilter extends AbstractCasFilter {
if (!isIgnoreInitConfiguration()) { if (!isIgnoreInitConfiguration()) {
super.initInternal(filterConfig); super.initInternal(filterConfig);
setCasServerLoginUrl(getPropertyFromInitParams(filterConfig, "casServerLoginUrl", null)); setCasServerLoginUrl(getPropertyFromInitParams(filterConfig, "casServerLoginUrl", null));
log.trace("Loaded CasServerLoginUrl parameter: " + this.casServerLoginUrl); logger.trace("Loaded CasServerLoginUrl parameter: {}", this.casServerLoginUrl);
setRenew(parseBoolean(getPropertyFromInitParams(filterConfig, "renew", "false"))); setRenew(parseBoolean(getPropertyFromInitParams(filterConfig, "renew", "false")));
log.trace("Loaded renew parameter: " + this.renew); logger.trace("Loaded renew parameter: {}", this.renew);
setGateway(parseBoolean(getPropertyFromInitParams(filterConfig, "gateway", "false"))); setGateway(parseBoolean(getPropertyFromInitParams(filterConfig, "gateway", "false")));
log.trace("Loaded gateway parameter: " + this.gateway); logger.trace("Loaded gateway parameter: {}", this.gateway);
final String gatewayStorageClass = getPropertyFromInitParams(filterConfig, "gatewayStorageClass", null); final String gatewayStorageClass = getPropertyFromInitParams(filterConfig, "gatewayStorageClass", null);
@ -85,7 +85,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
try { try {
this.gatewayStorage = (GatewayResolver) Class.forName(gatewayStorageClass).newInstance(); this.gatewayStorage = (GatewayResolver) Class.forName(gatewayStorageClass).newInstance();
} catch (final Exception e) { } catch (final Exception e) {
log.error(e,e); logger.error(e.getMessage(),e);
throw new ServletException(e); throw new ServletException(e);
} }
} }
@ -119,23 +119,19 @@ public class AuthenticationFilter extends AbstractCasFilter {
final String modifiedServiceUrl; final String modifiedServiceUrl;
log.debug("no ticket and no assertion found"); logger.debug("no ticket and no assertion found");
if (this.gateway) { if (this.gateway) {
log.debug("setting gateway attribute in session"); logger.debug("setting gateway attribute in session");
modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl); modifiedServiceUrl = this.gatewayStorage.storeGatewayInformation(request, serviceUrl);
} else { } else {
modifiedServiceUrl = serviceUrl; modifiedServiceUrl = serviceUrl;
} }
if (log.isDebugEnabled()) { logger.debug("Constructed service url: {}", modifiedServiceUrl);
log.debug("Constructed service url: " + modifiedServiceUrl);
}
final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway); final String urlToRedirectTo = CommonUtils.constructRedirectUrl(this.casServerLoginUrl, getServiceParameterName(), modifiedServiceUrl, this.renew, this.gateway);
if (log.isDebugEnabled()) { logger.debug("redirecting to \"{}\"", urlToRedirectTo);
log.debug("redirecting to \"" + urlToRedirectTo + "\"");
}
response.sendRedirect(urlToRedirectTo); response.sendRedirect(urlToRedirectTo);
} }

View File

@ -26,8 +26,7 @@ public final class DefaultGatewayResolverImpl implements GatewayResolver {
public static final String CONST_CAS_GATEWAY = "_const_cas_gateway_"; public static final String CONST_CAS_GATEWAY = "_const_cas_gateway_";
public boolean hasGatewayedAlready(final HttpServletRequest request, public boolean hasGatewayedAlready(final HttpServletRequest request, final String serviceUrl) {
final String serviceUrl) {
final HttpSession session = request.getSession(false); final HttpSession session = request.getSession(false);
if (session == null) { if (session == null) {
@ -39,8 +38,7 @@ public final class DefaultGatewayResolverImpl implements GatewayResolver {
return result; return result;
} }
public String storeGatewayInformation(final HttpServletRequest request, public String storeGatewayInformation(final HttpServletRequest request, final String serviceUrl) {
final String serviceUrl) {
request.getSession(true).setAttribute(CONST_CAS_GATEWAY, "yes"); request.getSession(true).setAttribute(CONST_CAS_GATEWAY, "yes");
return serviceUrl; return serviceUrl;
} }

View File

@ -36,8 +36,8 @@ public class Saml11AuthenticationFilter extends AuthenticationFilter {
protected final void initInternal(final FilterConfig filterConfig) throws ServletException { protected final void initInternal(final FilterConfig filterConfig) throws ServletException {
super.initInternal(filterConfig); super.initInternal(filterConfig);
log.warn("SAML1.1 compliance requires the [artifactParameterName] and [serviceParameterName] to be set to specified values."); logger.warn("SAML1.1 compliance requires the [artifactParameterName] and [serviceParameterName] to be set to specified values.");
log.warn("This filter will overwrite any user-provided values (if any are provided)"); logger.warn("This filter will overwrite any user-provided values (if any are provided)");
setArtifactParameterName("SAMLart"); setArtifactParameterName("SAMLart");
setServiceParameterName("TARGET"); setServiceParameterName("TARGET");

View File

@ -45,14 +45,14 @@ import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginException; import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule; import javax.security.auth.spi.LoginModule;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.authentication.SimpleGroup; import org.jasig.cas.client.authentication.SimpleGroup;
import org.jasig.cas.client.authentication.SimplePrincipal; import org.jasig.cas.client.authentication.SimplePrincipal;
import org.jasig.cas.client.util.CommonUtils; import org.jasig.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.ReflectUtils; import org.jasig.cas.client.util.ReflectUtils;
import org.jasig.cas.client.validation.Assertion; import org.jasig.cas.client.validation.Assertion;
import org.jasig.cas.client.validation.TicketValidator; import org.jasig.cas.client.validation.TicketValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* JAAS login module that delegates to a CAS {@link TicketValidator} component * JAAS login module that delegates to a CAS {@link TicketValidator} component
@ -149,7 +149,7 @@ public class CasLoginModule implements LoginModule {
protected static final Map<TicketCredential,Assertion> ASSERTION_CACHE = new HashMap<TicketCredential,Assertion>(); protected static final Map<TicketCredential,Assertion> ASSERTION_CACHE = new HashMap<TicketCredential,Assertion>();
/** Logger instance */ /** Logger instance */
protected final Log log = LogFactory.getLog(getClass()); protected final Logger logger = LoggerFactory.getLogger(getClass());
/** JAAS authentication subject */ /** JAAS authentication subject */
protected Subject subject; protected Subject subject;
@ -232,39 +232,39 @@ public class CasLoginModule implements LoginModule {
String ticketValidatorClass = null; String ticketValidatorClass = null;
for (final String key : options.keySet()) { for (final String key : options.keySet()) {
log.trace("Processing option " + key); logger.trace("Processing option {}", key);
if ("service".equals(key)) { if ("service".equals(key)) {
this.service = (String) options.get(key); this.service = (String) options.get(key);
log.debug("Set service=" + this.service); logger.debug("Set service={}", this.service);
} else if ("ticketValidatorClass".equals(key)) { } else if ("ticketValidatorClass".equals(key)) {
ticketValidatorClass = (String) options.get(key); ticketValidatorClass = (String) options.get(key);
log.debug("Set ticketValidatorClass=" + ticketValidatorClass); logger.debug("Set ticketValidatorClass={}", ticketValidatorClass);
} else if ("defaultRoles".equals(key)) { } else if ("defaultRoles".equals(key)) {
final String roles = (String) options.get(key); final String roles = (String) options.get(key);
log.trace("Got defaultRoles value " + roles); logger.trace("Got defaultRoles value {}", roles);
this.defaultRoles = roles.split(",\\s*"); this.defaultRoles = roles.split(",\\s*");
log.debug("Set defaultRoles=" + Arrays.asList(this.defaultRoles)); logger.debug("Set defaultRoles={}", Arrays.asList(this.defaultRoles));
} else if ("roleAttributeNames".equals(key)) { } else if ("roleAttributeNames".equals(key)) {
final String attrNames = (String) options.get(key); final String attrNames = (String) options.get(key);
log.trace("Got roleAttributeNames value " + attrNames); logger.trace("Got roleAttributeNames value {}", attrNames);
final String[] attributes = attrNames.split(",\\s*"); final String[] attributes = attrNames.split(",\\s*");
this.roleAttributeNames.addAll(Arrays.asList(attributes)); this.roleAttributeNames.addAll(Arrays.asList(attributes));
log.debug("Set roleAttributeNames=" + this.roleAttributeNames); logger.debug("Set roleAttributeNames={}", this.roleAttributeNames);
} else if ("principalGroupName".equals(key)) { } else if ("principalGroupName".equals(key)) {
this.principalGroupName = (String) options.get(key); this.principalGroupName = (String) options.get(key);
log.debug("Set principalGroupName=" + this.principalGroupName); logger.debug("Set principalGroupName={}",this.principalGroupName);
} else if ("roleGroupName".equals(key)) { } else if ("roleGroupName".equals(key)) {
this.roleGroupName = (String) options.get(key); this.roleGroupName = (String) options.get(key);
log.debug("Set roleGroupName=" + this.roleGroupName); logger.debug("Set roleGroupName={}", this.roleGroupName);
} else if ("cacheAssertions".equals(key)) { } else if ("cacheAssertions".equals(key)) {
this.cacheAssertions = Boolean.parseBoolean((String) options.get(key)); this.cacheAssertions = Boolean.parseBoolean((String) options.get(key));
log.debug("Set cacheAssertions=" + this.cacheAssertions); logger.debug("Set cacheAssertions={}", this.cacheAssertions);
} else if ("cacheTimeout".equals(key)) { } else if ("cacheTimeout".equals(key)) {
this.cacheTimeout = Integer.parseInt((String) options.get(key)); this.cacheTimeout = Integer.parseInt((String) options.get(key));
log.debug("Set cacheTimeout=" + this.cacheTimeout); logger.debug("Set cacheTimeout={}", this.cacheTimeout);
} else if ("cacheTimeoutUnit".equals(key)) { } else if ("cacheTimeoutUnit".equals(key)) {
this.cacheTimeoutUnit = Enum.valueOf(TimeUnit.class, (String) options.get(key)); this.cacheTimeoutUnit = Enum.valueOf(TimeUnit.class, (String) options.get(key));
log.debug("Set cacheTimeoutUnit=" + this.cacheTimeoutUnit); logger.debug("Set cacheTimeoutUnit={}", this.cacheTimeoutUnit);
} }
} }
@ -295,10 +295,10 @@ public class CasLoginModule implements LoginModule {
} }
public final boolean login() throws LoginException { public final boolean login() throws LoginException {
log.debug("Performing login."); logger.debug("Performing login.");
if (!preLogin()) { if (!preLogin()) {
log.debug("preLogin failed."); logger.debug("preLogin failed.");
return false; return false;
} }
@ -309,10 +309,10 @@ public class CasLoginModule implements LoginModule {
try { try {
this.callbackHandler.handle(new Callback[] { ticketCallback, serviceCallback }); this.callbackHandler.handle(new Callback[] { ticketCallback, serviceCallback });
} catch (final IOException e) { } catch (final IOException e) {
log.info("Login failed due to IO exception in callback handler: " + e); logger.info("Login failed due to IO exception in callback handler: {}", e);
throw (LoginException) new LoginException("IO exception in callback handler: " + e).initCause(e); throw (LoginException) new LoginException("IO exception in callback handler: " + e).initCause(e);
} catch (final UnsupportedCallbackException e) { } catch (final UnsupportedCallbackException e) {
log.info("Login failed due to unsupported callback: " + e); logger.info("Login failed due to unsupported callback: {}", e);
throw (LoginException) new LoginException( throw (LoginException) new LoginException(
"Callback handler does not support PasswordCallback and TextInputCallback.").initCause(e); "Callback handler does not support PasswordCallback and TextInputCallback.").initCause(e);
} }
@ -325,31 +325,29 @@ public class CasLoginModule implements LoginModule {
if (this.cacheAssertions) { if (this.cacheAssertions) {
this.assertion = ASSERTION_CACHE.get(ticket); this.assertion = ASSERTION_CACHE.get(ticket);
if (this.assertion != null) { if (this.assertion != null) {
log.debug("Assertion found in cache."); logger.debug("Assertion found in cache.");
} }
} }
if (this.assertion == null) { if (this.assertion == null) {
log.debug("CAS assertion is null; ticket validation required."); logger.debug("CAS assertion is null; ticket validation required.");
if (CommonUtils.isBlank(service)) { if (CommonUtils.isBlank(service)) {
log.info("Login failed because required CAS service parameter not provided."); logger.info("Login failed because required CAS service parameter not provided.");
throw new LoginException( throw new LoginException(
"Neither login module nor callback handler provided required service parameter."); "Neither login module nor callback handler provided required service parameter.");
} }
try { try {
if (log.isDebugEnabled()) { logger.debug("Attempting ticket validation with service={} and ticket={}", service, this.ticket);
log.debug("Attempting ticket validation with service=" + service + " and ticket=" + ticket);
}
this.assertion = this.ticketValidator.validate(this.ticket.getName(), service); this.assertion = this.ticketValidator.validate(this.ticket.getName(), service);
} catch (final Exception e) { } catch (final Exception e) {
log.info("Login failed due to CAS ticket validation failure: " + e); logger.info("Login failed due to CAS ticket validation failure: {}", e);
throw (LoginException) new LoginException("CAS ticket validation failed: " + e).initCause(e); throw (LoginException) new LoginException("CAS ticket validation failed: " + e).initCause(e);
} }
} }
log.info("Login succeeded."); logger.info("Login succeeded.");
} else { } else {
log.info("Login failed because callback handler did not provide CAS ticket."); logger.info("Login failed because callback handler did not provide CAS ticket.");
throw new LoginException("Callback handler did not provide CAS ticket."); throw new LoginException("Callback handler did not provide CAS ticket.");
} }
result = true; result = true;
@ -437,16 +435,10 @@ public class CasLoginModule implements LoginModule {
// Place principal name in shared state for downstream JAAS modules (module chaining use case) // Place principal name in shared state for downstream JAAS modules (module chaining use case)
this.sharedState.put(LOGIN_NAME, assertion.getPrincipal().getName()); this.sharedState.put(LOGIN_NAME, assertion.getPrincipal().getName());
if (log.isDebugEnabled()) { logger.debug("Created JAAS subject with principals: {}", subject.getPrincipals());
if (log.isDebugEnabled()) {
log.debug("Created JAAS subject with principals: " + subject.getPrincipals());
}
}
if (this.cacheAssertions) { if (this.cacheAssertions) {
if (log.isDebugEnabled()) { logger.debug("Caching assertion for principal {}", this.assertion.getPrincipal());
log.debug("Caching assertion for principal " + this.assertion.getPrincipal());
}
ASSERTION_CACHE.put(this.ticket, this.assertion); ASSERTION_CACHE.put(this.ticket, this.assertion);
} }
} else { } else {
@ -464,7 +456,7 @@ public class CasLoginModule implements LoginModule {
} }
public final boolean logout() throws LoginException { public final boolean logout() throws LoginException {
log.debug("Performing logout."); logger.debug("Performing logout.");
if (!preLogout()) { if (!preLogout()) {
return false; return false;
@ -478,7 +470,7 @@ public class CasLoginModule implements LoginModule {
// Remove all CAS credentials // Remove all CAS credentials
removeCredentialsOfType(TicketCredential.class); removeCredentialsOfType(TicketCredential.class);
log.info("Logout succeeded."); logger.info("Logout succeeded.");
postLogout(); postLogout();
return true; return true;
@ -520,14 +512,14 @@ public class CasLoginModule implements LoginModule {
for (final String property : propertyMap.keySet()) { for (final String property : propertyMap.keySet()) {
if (!"casServerUrlPrefix".equals(property)) { if (!"casServerUrlPrefix".equals(property)) {
log.debug("Attempting to set TicketValidator property " + property); logger.debug("Attempting to set TicketValidator property {}", property);
final String value = (String) propertyMap.get(property); final String value = (String) propertyMap.get(property);
final PropertyDescriptor pd = ReflectUtils.getPropertyDescriptor(info, property); final PropertyDescriptor pd = ReflectUtils.getPropertyDescriptor(info, property);
if (pd != null) { if (pd != null) {
ReflectUtils.setProperty(property, convertIfNecessary(pd, value), validator, info); ReflectUtils.setProperty(property, convertIfNecessary(pd, value), validator, info);
log.debug("Set " + property + "=" + value); logger.debug("Set {} = {}", property, value);
} else { } else {
log.warn("Cannot find property " + property + " on " + className); logger.warn("Cannot find property {} on {}", property, className);
} }
} }
} }
@ -584,9 +576,7 @@ public class CasLoginModule implements LoginModule {
* Removes expired entries from the assertion cache. * Removes expired entries from the assertion cache.
*/ */
private void cleanCache() { private void cleanCache() {
if (log.isDebugEnabled()) { logger.debug("Cleaning assertion cache of size {}", ASSERTION_CACHE.size());
log.debug("Cleaning assertion cache of size " + ASSERTION_CACHE.size());
}
final Iterator<Map.Entry<TicketCredential, Assertion>> iter = ASSERTION_CACHE.entrySet().iterator(); final Iterator<Map.Entry<TicketCredential, Assertion>> iter = ASSERTION_CACHE.entrySet().iterator();
final Calendar cutoff = Calendar.getInstance(); final Calendar cutoff = Calendar.getInstance();
cutoff.setTimeInMillis(System.currentTimeMillis() - this.cacheTimeoutUnit.toMillis(this.cacheTimeout)); cutoff.setTimeInMillis(System.currentTimeMillis() - this.cacheTimeoutUnit.toMillis(this.cacheTimeout));
@ -595,9 +585,7 @@ public class CasLoginModule implements LoginModule {
final Calendar created = Calendar.getInstance(); final Calendar created = Calendar.getInstance();
created.setTime(assertion.getValidFromDate()); created.setTime(assertion.getValidFromDate());
if (created.before(cutoff)) { if (created.before(cutoff)) {
if (log.isDebugEnabled()) { logger.debug("Removing expired assertion for principal {}", assertion.getPrincipal());
log.debug("Removing expired assertion for principal " + assertion.getPrincipal());
}
iter.remove(); iter.remove();
} }
} }

View File

@ -19,10 +19,10 @@
package org.jasig.cas.client.proxy; 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 org.jasig.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.XmlUtils; import org.jasig.cas.client.util.XmlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
@ -48,7 +48,7 @@ public final class Cas20ProxyRetriever implements ProxyRetriever {
/** /**
* Instance of Commons Logging. * Instance of Commons Logging.
*/ */
private final Log log = LogFactory.getLog(this.getClass()); private final Logger logger = LoggerFactory.getLogger(this.getClass());
/** /**
* Url to CAS server. * Url to CAS server.
@ -77,7 +77,7 @@ public final class Cas20ProxyRetriever implements ProxyRetriever {
final String error = XmlUtils.getTextForElement(response, "proxyFailure"); final String error = XmlUtils.getTextForElement(response, "proxyFailure");
if (CommonUtils.isNotEmpty(error)) { if (CommonUtils.isNotEmpty(error)) {
log.debug(error); logger.debug(error);
return null; return null;
} }

View File

@ -23,9 +23,9 @@ import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.CommonUtils; import org.jasig.cas.client.util.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Implementation of {@link ProxyGrantingTicketStorage} that is backed by a * Implementation of {@link ProxyGrantingTicketStorage} that is backed by a
@ -41,7 +41,7 @@ import org.jasig.cas.client.util.CommonUtils;
*/ */
public final class ProxyGrantingTicketStorageImpl implements ProxyGrantingTicketStorage { public final class ProxyGrantingTicketStorageImpl implements ProxyGrantingTicketStorage {
private final Log log = LogFactory.getLog(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
/** /**
* Default timeout in milliseconds. * Default timeout in milliseconds.
@ -90,24 +90,20 @@ public final class ProxyGrantingTicketStorageImpl implements ProxyGrantingTicket
final ProxyGrantingTicketHolder holder = this.cache.get(proxyGrantingTicketIou); final ProxyGrantingTicketHolder holder = this.cache.get(proxyGrantingTicketIou);
if (holder == null) { if (holder == null) {
log.info("No Proxy Ticket found for [" + proxyGrantingTicketIou + "]."); logger.info("No Proxy Ticket found for [{}].", proxyGrantingTicketIou);
return null; return null;
} }
this.cache.remove(proxyGrantingTicketIou); this.cache.remove(proxyGrantingTicketIou);
if (log.isDebugEnabled()) { logger.debug("Returned ProxyGrantingTicket of [{}]", holder.getProxyGrantingTicket());
log.debug("Returned ProxyGrantingTicket of [" + holder.getProxyGrantingTicket() + "]");
}
return holder.getProxyGrantingTicket(); return holder.getProxyGrantingTicket();
} }
public void save(final String proxyGrantingTicketIou, final String proxyGrantingTicket) { public void save(final String proxyGrantingTicketIou, final String proxyGrantingTicket) {
final ProxyGrantingTicketHolder holder = new ProxyGrantingTicketHolder(proxyGrantingTicket); final ProxyGrantingTicketHolder holder = new ProxyGrantingTicketHolder(proxyGrantingTicket);
if (log.isDebugEnabled()) { logger.debug("Saving ProxyGrantingTicketIOU and ProxyGrantingTicket combo: [{}, {}]", proxyGrantingTicketIou, proxyGrantingTicket);
log.debug("Saving ProxyGrantingTicketIOU and ProxyGrantingTicket combo: [" + proxyGrantingTicketIou + ", " + proxyGrantingTicket + "]");
}
this.cache.put(proxyGrantingTicketIou, holder); this.cache.put(proxyGrantingTicketIou, holder);
} }

View File

@ -38,6 +38,5 @@ public interface ProxyRetriever extends Serializable {
* @param targetService the service we want to proxy. * @param targetService the service we want to proxy.
* @return the ProxyTicket Id if Granted, null otherwise. * @return the ProxyTicket Id if Granted, null otherwise.
*/ */
String getProxyTicketIdFor(String proxyGrantingTicketId, String getProxyTicketIdFor(String proxyGrantingTicketId, String targetService);
String targetService);
} }

View File

@ -19,8 +19,8 @@
package org.jasig.cas.client.session; package org.jasig.cas.client.session;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -47,7 +47,7 @@ public final class HashMapBackedSessionMappingStorage implements SessionMappingS
*/ */
private final Map<String,String> ID_TO_SESSION_KEY_MAPPING = new HashMap<String,String>(); private final Map<String,String> ID_TO_SESSION_KEY_MAPPING = new HashMap<String,String>();
private final Log log = LogFactory.getLog(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
public synchronized void addSessionById(String mappingId, HttpSession session) { public synchronized void addSessionById(String mappingId, HttpSession session) {
ID_TO_SESSION_KEY_MAPPING.put(session.getId(), mappingId); ID_TO_SESSION_KEY_MAPPING.put(session.getId(), mappingId);
@ -55,18 +55,16 @@ public final class HashMapBackedSessionMappingStorage implements SessionMappingS
} }
public synchronized void removeBySessionById(String sessionId) { public synchronized void removeBySessionById(final String sessionId) {
if (log.isDebugEnabled()) { logger.debug("Attempting to remove Session=[{}]", sessionId);
log.debug("Attempting to remove Session=[" + sessionId + "]");
}
final String key = ID_TO_SESSION_KEY_MAPPING.get(sessionId); final String key = ID_TO_SESSION_KEY_MAPPING.get(sessionId);
if (log.isDebugEnabled()) { if (logger.isDebugEnabled()) {
if (key != null) { if (key != null) {
log.debug("Found mapping for session. Session Removed."); logger.debug("Found mapping for session. Session Removed.");
} else { } else {
log.debug("No mapping for session found. Ignoring."); logger.debug("No mapping for session found. Ignoring.");
} }
} }
MANAGED_SESSIONS.remove(key); MANAGED_SESSIONS.remove(key);

View File

@ -22,10 +22,10 @@ package org.jasig.cas.client.session;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.CommonUtils; import org.jasig.cas.client.util.CommonUtils;
import org.jasig.cas.client.util.XmlUtils; import org.jasig.cas.client.util.XmlUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@ -41,7 +41,7 @@ import java.util.List;
public final class SingleSignOutHandler { public final class SingleSignOutHandler {
/** Logger instance */ /** Logger instance */
private final Log log = LogFactory.getLog(getClass()); private final Logger logger = LoggerFactory.getLogger(getClass());
/** Mapping of token IDs and session IDs to HTTP sessions */ /** Mapping of token IDs and session IDs to HTTP sessions */
private SessionMappingStorage sessionMappingStorage = new HashMapBackedSessionMappingStorage(); private SessionMappingStorage sessionMappingStorage = new HashMapBackedSessionMappingStorage();
@ -131,9 +131,7 @@ public final class SingleSignOutHandler {
final HttpSession session = request.getSession(true); final HttpSession session = request.getSession(true);
final String token = CommonUtils.safeGetParameter(request, this.artifactParameterName, this.safeParameters); final String token = CommonUtils.safeGetParameter(request, this.artifactParameterName, this.safeParameters);
if (log.isDebugEnabled()) { logger.debug("Recording session for token {}", token);
log.debug("Recording session for token " + token);
}
try { try {
this.sessionMappingStorage.removeBySessionById(session.getId()); this.sessionMappingStorage.removeBySessionById(session.getId());
@ -150,10 +148,8 @@ public final class SingleSignOutHandler {
*/ */
public void destroySession(final HttpServletRequest request) { public void destroySession(final HttpServletRequest request) {
final String logoutMessage = CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters); final String logoutMessage = CommonUtils.safeGetParameter(request, this.logoutParameterName, this.safeParameters);
if (log.isTraceEnabled()) { logger.trace ("Logout request:\n{}", logoutMessage);
log.trace ("Logout request:\n" + logoutMessage);
}
final String token = XmlUtils.getTextForElement(logoutMessage, "SessionIndex"); final String token = XmlUtils.getTextForElement(logoutMessage, "SessionIndex");
if (CommonUtils.isNotBlank(token)) { if (CommonUtils.isNotBlank(token)) {
final HttpSession session = this.sessionMappingStorage.removeSessionByMappingId(token); final HttpSession session = this.sessionMappingStorage.removeSessionByMappingId(token);
@ -161,13 +157,12 @@ public final class SingleSignOutHandler {
if (session != null) { if (session != null) {
String sessionID = session.getId(); String sessionID = session.getId();
if (log.isDebugEnabled()) { logger.debug ("Invalidating session [{}] for token [{}]", sessionID, token);
log.debug ("Invalidating session [" + sessionID + "] for token [" + token + "]");
}
try { try {
session.invalidate(); session.invalidate();
} catch (final IllegalStateException e) { } catch (final IllegalStateException e) {
log.debug("Error invalidating session.", e); logger.debug("Error invalidating session.", e);
} }
} }
} }

View File

@ -19,8 +19,8 @@
package org.jasig.cas.client.util; package org.jasig.cas.client.util;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -46,9 +46,6 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
/** Represents the constant for where the assertion will be located in memory. */ /** Represents the constant for where the assertion will be located in memory. */
public static final String CONST_CAS_ASSERTION = "_const_cas_assertion_"; public static final String CONST_CAS_ASSERTION = "_const_cas_assertion_";
/** Instance of commons logging for logging purposes. */
protected final Log log = LogFactory.getLog(getClass());
/** Defines the parameter to look for for the artifact. */ /** Defines the parameter to look for for the artifact. */
private String artifactParameterName = "ticket"; private String artifactParameterName = "ticket";
@ -69,15 +66,15 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
public final void init(final FilterConfig filterConfig) throws ServletException { public final void init(final FilterConfig filterConfig) throws ServletException {
if (!isIgnoreInitConfiguration()) { if (!isIgnoreInitConfiguration()) {
setServerName(getPropertyFromInitParams(filterConfig, "serverName", null)); setServerName(getPropertyFromInitParams(filterConfig, "serverName", null));
log.trace("Loading serverName property: " + this.serverName); logger.trace("Loading serverName property: {}", this.serverName);
setService(getPropertyFromInitParams(filterConfig, "service", null)); setService(getPropertyFromInitParams(filterConfig, "service", null));
log.trace("Loading service property: " + this.service); logger.trace("Loading service property: {}", this.service);
setArtifactParameterName(getPropertyFromInitParams(filterConfig, "artifactParameterName", "ticket")); setArtifactParameterName(getPropertyFromInitParams(filterConfig, "artifactParameterName", "ticket"));
log.trace("Loading artifact parameter name property: " + this.artifactParameterName); logger.trace("Loading artifact parameter name property: {}", this.artifactParameterName);
setServiceParameterName(getPropertyFromInitParams(filterConfig, "serviceParameterName", "service")); setServiceParameterName(getPropertyFromInitParams(filterConfig, "serviceParameterName", "service"));
log.trace("Loading serviceParameterName property: " + this.serviceParameterName); logger.trace("Loading serviceParameterName property: {} ", this.serviceParameterName);
setEncodeServiceUrl(parseBoolean(getPropertyFromInitParams(filterConfig, "encodeServiceUrl", "true"))); setEncodeServiceUrl(parseBoolean(getPropertyFromInitParams(filterConfig, "encodeServiceUrl", "true")));
log.trace("Loading encodeServiceUrl property: " + this.encodeServiceUrl); logger.trace("Loading encodeServiceUrl property: {}", this.encodeServiceUrl);
initInternal(filterConfig); initInternal(filterConfig);
} }
@ -122,7 +119,7 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
public final void setServerName(final String serverName) { public final void setServerName(final String serverName) {
if (serverName != null && serverName.endsWith("/")) { if (serverName != null && serverName.endsWith("/")) {
this.serverName = serverName.substring(0, serverName.length()-1); this.serverName = serverName.substring(0, serverName.length()-1);
log.info(String.format("Eliminated extra slash from serverName [%s]. It is now [%s]", serverName, this.serverName)); logger.info("Eliminated extra slash from serverName [{}]. It is now [{}]", serverName, this.serverName);
} else { } else {
this.serverName = serverName; this.serverName = serverName;
} }

View File

@ -24,8 +24,8 @@ import javax.naming.NamingException;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
/** /**
* Abstracts out the ability to configure the filters from the initial properties provided. * Abstracts out the ability to configure the filters from the initial properties provided.
@ -36,7 +36,7 @@ import org.apache.commons.logging.LogFactory;
*/ */
public abstract class AbstractConfigurationFilter implements Filter { public abstract class AbstractConfigurationFilter implements Filter {
protected final Log log = LogFactory.getLog(getClass()); protected final Logger logger = LoggerFactory.getLogger(getClass());
private boolean ignoreInitConfiguration = false; private boolean ignoreInitConfiguration = false;
@ -68,21 +68,21 @@ public abstract class AbstractConfigurationFilter implements Filter {
final String value = filterConfig.getInitParameter(propertyName); final String value = filterConfig.getInitParameter(propertyName);
if (CommonUtils.isNotBlank(value)) { if (CommonUtils.isNotBlank(value)) {
log.info("Property [" + propertyName + "] loaded from FilterConfig.getInitParameter with value [" + value + "]"); logger.info("Property [{}] loaded from FilterConfig.getInitParameter with value [{}]", propertyName, value);
return value; return value;
} }
final String value2 = filterConfig.getServletContext().getInitParameter(propertyName); final String value2 = filterConfig.getServletContext().getInitParameter(propertyName);
if (CommonUtils.isNotBlank(value2)) { if (CommonUtils.isNotBlank(value2)) {
log.info("Property [" + propertyName + "] loaded from ServletContext.getInitParameter with value [" + value2 + "]"); logger.info("Property [{}] loaded from ServletContext.getInitParameter with value [{}]", propertyName, value2);
return value2; return value2;
} }
InitialContext context; InitialContext context;
try { try {
context = new InitialContext(); context = new InitialContext();
} catch (final NamingException e) { } catch (final NamingException e) {
log.warn(e,e); logger.warn(e.getMessage(), e);
return defaultValue; return defaultValue;
} }
@ -91,18 +91,18 @@ public abstract class AbstractConfigurationFilter implements Filter {
final String value3 = loadFromContext(context, "java:comp/env/cas/" + shortName + "/" + propertyName); final String value3 = loadFromContext(context, "java:comp/env/cas/" + shortName + "/" + propertyName);
if (CommonUtils.isNotBlank(value3)) { if (CommonUtils.isNotBlank(value3)) {
log.info("Property [" + propertyName + "] loaded from JNDI Filter Specific Property with value [" + value3 + "]"); logger.info("Property [{}] loaded from JNDI Filter Specific Property with value [{}]", propertyName, value3);
return value3; return value3;
} }
final String value4 = loadFromContext(context, "java:comp/env/cas/" + propertyName); final String value4 = loadFromContext(context, "java:comp/env/cas/" + propertyName);
if (CommonUtils.isNotBlank(value4)) { if (CommonUtils.isNotBlank(value4)) {
log.info("Property [" + propertyName + "] loaded from JNDI with value [" + value4 + "]"); logger.info("Property [{}] loaded from JNDI with value [{}]", propertyName, value4);
return value4; return value4;
} }
log.info("Property [" + propertyName + "] not found. Using default value [" + defaultValue + "]"); logger.info("Property [{}] not found. Using default value [{}]", propertyName, defaultValue);
return defaultValue; return defaultValue;
} }

View File

@ -19,9 +19,9 @@
package org.jasig.cas.client.validation; package org.jasig.cas.client.validation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.CommonUtils; import org.jasig.cas.client.util.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
@ -44,7 +44,7 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
/** /**
* Commons Logging instance. * Commons Logging instance.
*/ */
protected final Log log = LogFactory.getLog(getClass()); protected final Logger logger = LoggerFactory.getLogger(getClass());
/** /**
* Hostname verifier used when making an SSL request to the CAS server. * Hostname verifier used when making an SSL request to the CAS server.
@ -113,7 +113,7 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
protected final String constructValidationUrl(final String ticket, final String serviceUrl) { protected final String constructValidationUrl(final String ticket, final String serviceUrl) {
final Map<String,String> urlParameters = new HashMap<String,String>(); final Map<String,String> urlParameters = new HashMap<String,String>();
log.debug("Placing URL parameters in map."); logger.debug("Placing URL parameters in map.");
urlParameters.put("ticket", ticket); urlParameters.put("ticket", ticket);
urlParameters.put("service", encodeUrl(serviceUrl)); urlParameters.put("service", encodeUrl(serviceUrl));
@ -121,10 +121,10 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
urlParameters.put("renew", "true"); urlParameters.put("renew", "true");
} }
log.debug("Calling template URL attribute map."); logger.debug("Calling template URL attribute map.");
populateUrlAttributeMap(urlParameters); populateUrlAttributeMap(urlParameters);
log.debug("Loading custom parameters from configuration."); logger.debug("Loading custom parameters from configuration.");
if (this.customParameters != null) { if (this.customParameters != null) {
urlParameters.putAll(this.customParameters); urlParameters.putAll(this.customParameters);
} }
@ -198,21 +198,17 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
final String validationUrl = constructValidationUrl(ticket, service); final String validationUrl = constructValidationUrl(ticket, service);
if (log.isDebugEnabled()) { logger.debug("Constructing validation url: {}", validationUrl);
log.debug("Constructing validation url: " + validationUrl);
}
try { try {
log.debug("Retrieving response from server."); logger.debug("Retrieving response from server.");
final String serverResponse = retrieveResponseFromServer(new URL(validationUrl), ticket); final String serverResponse = retrieveResponseFromServer(new URL(validationUrl), ticket);
if (serverResponse == null) { if (serverResponse == null) {
throw new TicketValidationException("The CAS server returned no response."); throw new TicketValidationException("The CAS server returned no response.");
} }
if (log.isDebugEnabled()) { logger.debug("Server response: {}", serverResponse);
log.debug("Server response: " + serverResponse);
}
return parseResponseFromServer(serverResponse); return parseResponseFromServer(serverResponse);
} catch (final MalformedURLException e) { } catch (final MalformedURLException e) {

View File

@ -531,7 +531,11 @@
<exclusion> <exclusion>
<groupId>jndi</groupId> <groupId>jndi</groupId>
<artifactId>jndi</artifactId> <artifactId>jndi</artifactId>
</exclusion> </exclusion>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency> <dependency>

49
pom.xml
View File

@ -162,24 +162,10 @@ NwXMoqnmqmUUnosrspqmmmmmmUUnosrspqmmmmmmUUA1jJ
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-logging</groupId> <groupId>org.slf4j</groupId>
<artifactId>commons-logging</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.1</version> <version>${slf4j.version}</version>
<scope>compile</scope> <scope>compile</scope>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
<exclusion>
<groupId>logkit</groupId>
<artifactId>logkit</artifactId>
</exclusion>
<exclusion>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.servlet</groupId> <groupId>javax.servlet</groupId>
@ -189,19 +175,20 @@ NwXMoqnmqmUUnosrspqmmmmmmUUnosrspqmmmmmmUUA1jJ
</dependency> </dependency>
</dependencies> </dependencies>
<modules> <modules>
<module>cas-client-core</module> <module>cas-client-core</module>
<module>cas-client-integration-atlassian</module> <module>cas-client-integration-atlassian</module>
<module>cas-client-integration-jboss</module> <module>cas-client-integration-jboss</module>
<module>cas-client-support-distributed-ehcache</module> <module>cas-client-support-distributed-ehcache</module>
<module>cas-client-support-distributed-memcached</module> <module>cas-client-support-distributed-memcached</module>
<module>cas-client-integration-tomcat-common</module> <module>cas-client-integration-tomcat-common</module>
<module>cas-client-integration-tomcat-v6</module> <module>cas-client-integration-tomcat-v6</module>
<module>cas-client-integration-tomcat-v7</module> <module>cas-client-integration-tomcat-v7</module>
</modules> </modules>
<properties> <properties>
<ehcache.version>2.2.0</ehcache.version> <ehcache.version>2.2.0</ehcache.version>
<clover.version>3.0.2</clover.version> <clover.version>3.0.2</clover.version>
</properties> <slf4j.version>1.7.1</slf4j.version>
</properties>
</project> </project>