convert Commons Logging to SLF4J.  Add Enforcer.
This commit is contained in:
Scott Battaglia 2013-01-11 23:25:52 -05:00
parent 06ccec017d
commit 2f9d384b1e
7 changed files with 42 additions and 51 deletions

View File

@ -77,13 +77,6 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>

View File

@ -520,6 +520,10 @@
<groupId>bouncycastle</groupId>
<artifactId>bcprov-jdk14</artifactId>
</exclusion>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

View File

@ -24,10 +24,10 @@ import com.atlassian.confluence.event.events.security.LoginFailedEvent;
import com.atlassian.confluence.user.ConfluenceAuthenticator;
import com.atlassian.seraph.auth.AuthenticatorException;
import com.atlassian.seraph.auth.LoginReason;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -49,14 +49,12 @@ import java.security.Principal;
public final class Confluence35CasAuthenticator extends ConfluenceAuthenticator {
private static final long serialVersionUID = -6097438206488390678L;
private static final Log LOG = LogFactory.getLog(Confluence35CasAuthenticator.class);
private static final Logger LOGGER = LoggerFactory.getLogger(Confluence35CasAuthenticator.class);
public Principal getUser(final HttpServletRequest request, final HttpServletResponse response) {
Principal existingUser = getUserFromSession(request);
if (existingUser != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Session found; user already logged in.");
}
LOGGER.debug("Session found; user already logged in.");
LoginReason.OK.stampRequestResponse(request, response);
return existingUser;
}
@ -76,13 +74,9 @@ public final class Confluence35CasAuthenticator extends ConfluenceAuthenticator
// Firing this event is necessary to ensure the user's personal information is initialised correctly.
getEventPublisher().publish(new LoginEvent(this, username, request.getSession().getId(), remoteHost, remoteIP));
LoginReason.OK.stampRequestResponse(request, response);
if (LOG.isDebugEnabled()) {
LOG.debug("Logging in [" + username + "] from CAS.");
}
LOGGER.debug("Logging in [{}] from CAS.", username);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Failed logging [" + username + "] from CAS.");
}
LOGGER.debug("Failed logging [{}] from CAS.", username);
getElevatedSecurityGuard().onFailedLoginAttempt(request, username);
getEventPublisher().publish(new LoginFailedEvent(this, username, request.getSession().getId(), remoteHost, remoteIP));
}
@ -97,8 +91,8 @@ public final class Confluence35CasAuthenticator extends ConfluenceAuthenticator
final Principal principal = (Principal) session.getAttribute(LOGGED_IN_KEY);
if (LOG.isDebugEnabled() && principal != null) {
LOG.debug("Logging out [" + principal.getName() + "] from CAS.");
if (principal != null) {
LOGGER.debug("Logging out [{}] from CAS.", principal.getName());
}
removePrincipalFromSessionContext(request);

View File

@ -21,10 +21,10 @@ package org.jasig.cas.client.integration.atlassian;
import com.atlassian.confluence.user.ConfluenceAuthenticator;
import com.atlassian.seraph.auth.AuthenticatorException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@ -45,16 +45,14 @@ public final class ConfluenceCasAuthenticator extends ConfluenceAuthenticator {
/** ConfluenceCasAuthenticator.java */
private static final long serialVersionUID = -6097438206488390677L;
private static final Log LOG = LogFactory.getLog(ConfluenceCasAuthenticator.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ConfluenceCasAuthenticator.class);
public Principal getUser(final HttpServletRequest request, final HttpServletResponse response) {
final HttpSession session = request.getSession();
// user already exists
if (session.getAttribute(LOGGED_IN_KEY) != null) {
if (LOG.isDebugEnabled()) {
LOG.debug("Session found; user already logged in.");
}
LOGGER.debug("Session found; user already logged in.");
return (Principal) session.getAttribute(LOGGED_IN_KEY);
}
@ -63,9 +61,7 @@ public final class ConfluenceCasAuthenticator extends ConfluenceAuthenticator {
if (assertion != null) {
final Principal p = getUser(assertion.getPrincipal().getName());
if (LOG.isDebugEnabled()) {
LOG.debug("Logging in [" + p.getName() + "] from CAS.");
}
LOGGER.debug("Logging in [{}] from CAS.", p.getName());
session.setAttribute(LOGGED_IN_KEY, p);
session.setAttribute(LOGGED_OUT_KEY, null);
@ -80,9 +76,7 @@ public final class ConfluenceCasAuthenticator extends ConfluenceAuthenticator {
final Principal principal = (Principal) session.getAttribute(LOGGED_IN_KEY);
if (LOG.isDebugEnabled()) {
LOG.debug("Logging out [" + principal.getName() + "] from CAS.");
}
LOGGER.debug("Logging out [{}] from CAS.", principal.getName());
session.setAttribute(LOGGED_OUT_KEY, principal);
session.setAttribute(LOGGED_IN_KEY, null);

View File

@ -22,8 +22,6 @@ package org.jasig.cas.client.integration.atlassian;
import com.atlassian.jira.security.login.JiraSeraphAuthenticator;
import com.atlassian.seraph.auth.AuthenticatorException;
import com.atlassian.seraph.auth.LoginReason;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
import org.slf4j.Logger;

View File

@ -22,10 +22,7 @@ package org.jasig.cas.client.integration.atlassian;
import com.atlassian.seraph.auth.DefaultAuthenticator;
import com.atlassian.seraph.auth.AuthenticatorException;
import com.opensymphony.user.EntityNotFoundException;
import com.opensymphony.user.User;
import com.opensymphony.user.UserManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
import org.slf4j.Logger;

37
pom.xml
View File

@ -166,7 +166,6 @@ NwXMoqnmqmUUnosrspqmmmmmmUUnosrspqmmmmmmUUA1jJ
<bannedDependencies>
<excludes>
<exclude>commons-logging</exclude>
<exclude>cglib:cglib</exclude>
</excludes>
</bannedDependencies>
</rules>
@ -180,23 +179,35 @@ NwXMoqnmqmUUnosrspqmmmmmmUUnosrspqmmmmmmUUA1jJ
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<modules>