org.slf4j.impl
+ * in order to find other avaliable factories.
+ */
+ public CasLoggerFactory() {
+ this.loggerMap = new ConcurrentHashMapAttempts to find the real Logger
instance that
+ * is doing the heavy lifting and routes the request to an instance of
+ * {@link CasDelegatingLogger}. The instance is cached by the logger name.
Logger
instance that is available on the classpath.
+ * This is usually the logger adapter that is provided by the real logging framework,
+ * such as log4j, etc. The method will scan the runtime to find logger factories that
+ * are of type {@link org.slf4j.ILoggerFactory}. It will remove itself from this list
+ * first and then attempts to locate the next best factory from which real logger instances
+ * can be created.
+ * @param name requested logger name
+ * @return the logger instance created by the logger factory available on the classpath during runtime, or null.
+ */
+ private Logger getRealLoggerInstance(final String name) {
+ try {
+ final ILoggerFactory factInstance = this.realLoggerFactoryClass.newInstance();
+ return factInstance.getLogger(name);
+ } catch (final Exception e) {
+ throw new RuntimeException(e.getMessage(), e);
+ }
+ }
+
+}
diff --git a/cas-server-core/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/cas-server-core/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
new file mode 100644
index 000000000000..24bdc6c01155
--- /dev/null
+++ b/cas-server-core/src/main/java/org/slf4j/impl/StaticLoggerBinder.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to Jasig under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work
+ * for additional information regarding copyright ownership.
+ * Jasig licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a
+ * copy of the License at the following location:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.slf4j.impl;
+
+import org.slf4j.ILoggerFactory;
+import org.slf4j.spi.LoggerFactoryBinder;
+
+/**
+ * The static binder for slf4j logging, which allows CAS
+ * to select its own {@Link ILoggerFactory} instance at runtime.
+ * Note that this class MUST reside in the org.slf4j.impl
+ * package so it can be loaded by the runtime dynamic lookup.
+ * @author Misagh Moayyed
+ * @since 4.1
+ */
+public final class StaticLoggerBinder implements LoggerFactoryBinder {
+
+ /**
+ * The unique instance of this class.
+ */
+ private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
+
+ /**
+ * Return the singleton of this class.
+ *
+ * @return the StaticLoggerBinder singleton
+ */
+ public static StaticLoggerBinder getSingleton() {
+ return SINGLETON;
+ }
+
+ /**
+ * The {@link ILoggerFactory} instance returned by the
+ * {@link #getLoggerFactory} method should always be the same
+ * object.
+ */
+ private final ILoggerFactory loggerFactory;
+
+ /**
+ * Instantiates a new Static logger binder.
+ */
+ private StaticLoggerBinder() {
+ this.loggerFactory = new CasLoggerFactory();
+ }
+
+ public ILoggerFactory getLoggerFactory() {
+ return this.loggerFactory;
+ }
+
+ public String getLoggerFactoryClassStr() {
+ return CasLoggerFactory.class.getName();
+ }
+}
diff --git a/cas-server-core/src/test/java/org/jasig/cas/authentication/handler/support/HttpBasedServiceCredentialsAuthenticationHandlerTests.java b/cas-server-core/src/test/java/org/jasig/cas/authentication/handler/support/HttpBasedServiceCredentialsAuthenticationHandlerTests.java
index fea3b3fe3d6b..6d0ee10c932f 100644
--- a/cas-server-core/src/test/java/org/jasig/cas/authentication/handler/support/HttpBasedServiceCredentialsAuthenticationHandlerTests.java
+++ b/cas-server-core/src/test/java/org/jasig/cas/authentication/handler/support/HttpBasedServiceCredentialsAuthenticationHandlerTests.java
@@ -66,7 +66,7 @@ public void testRejectsInProperCertificateCredentials() throws Exception {
public void testAcceptsNonHttpsCredentials() throws Exception {
this.authenticationHandler.setHttpClient(new SimpleHttpClient());
assertNotNull(this.authenticationHandler.authenticate(
- TestUtils.getHttpBasedServiceCredentials("http://www.jasig.org")));
+ TestUtils.getHttpBasedServiceCredentials("http://www.google.com")));
}
@Test(expected = FailedLoginException.class)
diff --git a/cas-server-core/src/test/java/org/jasig/cas/services/AttributeReleasePolicyTests.java b/cas-server-core/src/test/java/org/jasig/cas/services/AttributeReleasePolicyTests.java
index 9b846cf3562f..a1d3fa954ab8 100644
--- a/cas-server-core/src/test/java/org/jasig/cas/services/AttributeReleasePolicyTests.java
+++ b/cas-server-core/src/test/java/org/jasig/cas/services/AttributeReleasePolicyTests.java
@@ -26,7 +26,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.commons.lang.SerializationUtils;
+import org.apache.commons.lang3.SerializationUtils;
import org.jasig.cas.authentication.principal.Principal;
import org.jasig.cas.services.support.RegisteredServiceRegexAttributeFilter;
import org.junit.Test;
diff --git a/cas-server-core/src/test/java/org/jasig/cas/services/support/RegisteredServiceRegexAttributeFilterTests.java b/cas-server-core/src/test/java/org/jasig/cas/services/support/RegisteredServiceRegexAttributeFilterTests.java
index 49816b17bdc2..26038473048b 100644
--- a/cas-server-core/src/test/java/org/jasig/cas/services/support/RegisteredServiceRegexAttributeFilterTests.java
+++ b/cas-server-core/src/test/java/org/jasig/cas/services/support/RegisteredServiceRegexAttributeFilterTests.java
@@ -29,7 +29,7 @@
import java.util.List;
import java.util.Map;
-import org.apache.commons.lang.SerializationUtils;
+import org.apache.commons.lang3.SerializationUtils;
import org.jasig.cas.services.AttributeFilter;
import org.jasig.cas.services.RegisteredService;
import org.junit.Before;
diff --git a/cas-server-core/src/test/java/org/jasig/cas/util/SimpleHttpClientTests.java b/cas-server-core/src/test/java/org/jasig/cas/util/SimpleHttpClientTests.java
index 27cd5f600c0b..a03384109295 100644
--- a/cas-server-core/src/test/java/org/jasig/cas/util/SimpleHttpClientTests.java
+++ b/cas-server-core/src/test/java/org/jasig/cas/util/SimpleHttpClientTests.java
@@ -43,7 +43,7 @@ private SimpleHttpClient getHttpClient() {
@Test
public void testOkayUrl() {
- assertTrue(this.getHttpClient().isValidEndPoint("http://www.apereo.org"));
+ assertTrue(this.getHttpClient().isValidEndPoint("http://www.google.com"));
}
@Test
diff --git a/cas-server-core/src/test/java/org/slf4j/impl/CasLoggerFactoryTests.java b/cas-server-core/src/test/java/org/slf4j/impl/CasLoggerFactoryTests.java
new file mode 100644
index 000000000000..4640f6936629
--- /dev/null
+++ b/cas-server-core/src/test/java/org/slf4j/impl/CasLoggerFactoryTests.java
@@ -0,0 +1,353 @@
+/*
+ * Licensed to Jasig under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work
+ * for additional information regarding copyright ownership.
+ * Jasig licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a
+ * copy of the License at the following location:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.slf4j.impl;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jasig.cas.ticket.InvalidTicketException;
+import org.jasig.cas.ticket.TicketGrantingTicket;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.Marker;
+import org.slf4j.helpers.Util;
+
+import java.io.File;
+import java.io.IOException;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * @author Misagh Moayyed
+ */
+public class CasLoggerFactoryTests {
+
+ private static final File LOG_FILE = new File("target", "slf4j.log");
+
+ private static final String ID1 = "TGT-1-B0tjWgMIhUU4kgCZdXbxnWccTFYpTbRbArjaoutXnlNMbIShEu-cas";
+ private static final String ID2 = "PGT-1-B0tjWgMIhUU4kgCZd32xnWccTFYpTbRbArjaoutXnlNMbIShEu-cas";
+
+ private Logger logger;
+
+ @BeforeClass
+ public static void beforeClass() throws IOException {
+ if (LOG_FILE.exists()) {
+ Util.report("Initializing log file " + LOG_FILE.getCanonicalPath());
+ FileUtils.write(LOG_FILE, "", false);
+ }
+ }
+
+ @After
+ public void after() throws IOException {
+ FileUtils.write(LOG_FILE, "", false);
+ }
+
+ @Before
+ public void beforeTest() {
+ logger = LoggerFactory.getLogger(CasLoggerFactoryTests.class);
+ }
+
+ @Test
+ public void testLoggerSelectedCorrectly() {
+ assertTrue(logger instanceof CasDelegatingLogger);
+ }
+
+ @Test
+ public void testLogging1() {
+ logger.trace(mock(Marker.class), getMessageToLogWithParams(), null, null);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging2() {
+ logger.trace(mock(Marker.class), getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging3() {
+ logger.trace(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging4() {
+ logger.trace(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging5() {
+ logger.trace(mock(Marker.class), getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging6() {
+ logger.trace(getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging7() {
+ logger.trace(getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging8() {
+ logger.trace(getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging9() {
+ logger.trace(getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging21() {
+ logger.debug(mock(Marker.class), getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging31() {
+ logger.debug(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging41() {
+ logger.debug(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging51() {
+ logger.debug(mock(Marker.class), getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging61() {
+ logger.debug(getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging771() {
+ final TicketGrantingTicket t = mock(TicketGrantingTicket.class);
+ when(t.getId()).thenReturn(ID1);
+ when(t.toString()).thenReturn(ID1);
+
+ logger.debug(getMessageToLogWithParams(), ID2, t);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging71() {
+ logger.debug(getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging81() {
+ logger.debug(getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging91() {
+ logger.debug(getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging211() {
+ logger.info(mock(Marker.class), getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging311() {
+ logger.info(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging411() {
+ logger.info(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging511() {
+ logger.info(mock(Marker.class), getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging611() {
+ logger.info(getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging711() {
+ logger.info(getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging811() {
+ logger.info(getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging911() {
+ logger.info(getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging2111() {
+ logger.warn(mock(Marker.class), getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging3111() {
+ logger.warn(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging4111() {
+ logger.warn(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging5111() {
+ logger.warn(mock(Marker.class), getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging6111() {
+ logger.warn(getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging7111() {
+ logger.warn(getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging8111() {
+ logger.warn(getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging9111() {
+ logger.warn(getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging21110() {
+ logger.error(mock(Marker.class), getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging31110() {
+ logger.error(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging41110() {
+ logger.error(mock(Marker.class), getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging51110() {
+ logger.error(mock(Marker.class), getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging61110() {
+ logger.error(getMessageToLog());
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging71110() {
+ logger.error(getMessageToLogWithParams(), ID2, ID1);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging81110() {
+ logger.error(getMessageToLogWithParams(), ID2, ID1, ID2);
+ validateLogData();
+ }
+
+ @Test
+ public void testLogging91110() {
+ logger.error(getMessageToLog(), new RuntimeException(ID1, new InvalidTicketException(ID2)));
+ validateLogData();
+ }
+
+ private String getMessageToLog() {
+ return String.format("Here is one %s and here is another %s", ID1, ID2);
+ }
+
+ private String getMessageToLogWithParams() {
+ return "Here is one {} and here is another {}";
+ }
+
+ private void validateLogData() {
+ try {
+ assertTrue("Log file " + LOG_FILE.getCanonicalPath() + " does not exist", LOG_FILE.exists());
+
+ final String data = FileUtils.readFileToString(LOG_FILE);
+ assertTrue("Logged buffer data is blank in " + LOG_FILE.getCanonicalPath(), StringUtils.isNotBlank(data));
+ assertFalse("Logged buffer data should not contain " + ID1, data.contains(ID1));
+ assertFalse("Logged buffer data should not contain " + ID2, data.contains(ID2));
+ } catch (final IOException e) {
+ fail(e.getMessage());
+ }
+ }
+}
+
diff --git a/cas-server-core/src/test/resources/log4j.properties b/cas-server-core/src/test/resources/log4j.properties
index b081a01aac2c..ee1fe02ff39d 100644
--- a/cas-server-core/src/test/resources/log4j.properties
+++ b/cas-server-core/src/test/resources/log4j.properties
@@ -21,9 +21,17 @@
# under the License.
#
-log4j.rootCategory=INFO, stdout
+log4j.appender.file=org.apache.log4j.RollingFileAppender
+log4j.appender.file.File=target/slf4j.log
+log4j.appender.file.MaxFileSize=10MB
+log4j.appender.file.MaxBackupIndex=1
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%-5p %d{ISO8601} %t::%c{1} - %m%n
-log4j.logger.org.jasig.cas=DEBUG
+log4j.rootCategory=WARN, stdout
+log4j.logger.org.jasig.cas=WARN, stdout
+log4j.logger.org.slf4j.impl=TRACE, file
diff --git a/cas-server-extension-clearpass/src/main/java/org/jasig/cas/extension/clearpass/ClearPassController.java b/cas-server-extension-clearpass/src/main/java/org/jasig/cas/extension/clearpass/ClearPassController.java
index 9ab6103090c7..1d87ea562d59 100644
--- a/cas-server-extension-clearpass/src/main/java/org/jasig/cas/extension/clearpass/ClearPassController.java
+++ b/cas-server-extension-clearpass/src/main/java/org/jasig/cas/extension/clearpass/ClearPassController.java
@@ -25,7 +25,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.ModelAndView;
diff --git a/cas-server-integration-ehcache/src/main/java/org/jasig/cas/ticket/registry/EhCacheTicketRegistry.java b/cas-server-integration-ehcache/src/main/java/org/jasig/cas/ticket/registry/EhCacheTicketRegistry.java
index 1851f1256486..045050dd0ffc 100644
--- a/cas-server-integration-ehcache/src/main/java/org/jasig/cas/ticket/registry/EhCacheTicketRegistry.java
+++ b/cas-server-integration-ehcache/src/main/java/org/jasig/cas/ticket/registry/EhCacheTicketRegistry.java
@@ -24,8 +24,8 @@
import net.sf.ehcache.Element;
import net.sf.ehcache.config.CacheConfiguration;
-import org.apache.commons.lang.BooleanUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jasig.cas.ticket.ServiceTicket;
import org.jasig.cas.ticket.Ticket;
import org.jasig.cas.ticket.TicketGrantingTicket;
diff --git a/cas-server-integration-memcached/src/test/java/org/jasig/cas/ticket/registry/support/kryo/KryoTranscoderTests.java b/cas-server-integration-memcached/src/test/java/org/jasig/cas/ticket/registry/support/kryo/KryoTranscoderTests.java
index c39ca514d5d4..ab0f7f2c2941 100644
--- a/cas-server-integration-memcached/src/test/java/org/jasig/cas/ticket/registry/support/kryo/KryoTranscoderTests.java
+++ b/cas-server-integration-memcached/src/test/java/org/jasig/cas/ticket/registry/support/kryo/KryoTranscoderTests.java
@@ -20,7 +20,7 @@
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.serialize.FieldSerializer;
-import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.jasig.cas.authentication.Authentication;
import org.jasig.cas.authentication.AuthenticationBuilder;
import org.jasig.cas.authentication.AuthenticationHandler;
diff --git a/cas-server-integration-restlet/src/main/java/org/jasig/cas/integration/restlet/TicketResource.java b/cas-server-integration-restlet/src/main/java/org/jasig/cas/integration/restlet/TicketResource.java
index be6677a737a8..36fc1777d7e1 100644
--- a/cas-server-integration-restlet/src/main/java/org/jasig/cas/integration/restlet/TicketResource.java
+++ b/cas-server-integration-restlet/src/main/java/org/jasig/cas/integration/restlet/TicketResource.java
@@ -28,7 +28,7 @@
import java.util.Set;
import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
import org.jasig.cas.CentralAuthenticationService;
import org.jasig.cas.authentication.Credential;
import org.jasig.cas.authentication.UsernamePasswordCredential;
diff --git a/cas-server-support-jdbc/pom.xml b/cas-server-support-jdbc/pom.xml
index 66fd1d80593d..76e3d772cb47 100644
--- a/cas-server-support-jdbc/pom.xml
+++ b/cas-server-support-jdbc/pom.xml
@@ -37,8 +37,9 @@