From 1ba21f7f7180db593e1de26445e1f78c662c8b84 Mon Sep 17 00:00:00 2001 From: Jeremy Long Date: Wed, 17 Jun 2015 20:46:51 -0400 Subject: [PATCH] fixed copyright Former-commit-id: 8e49185e3efef904af121a69fb04c8c577ef0b6e --- .../ant/logging/AntLoggerAdapter.java | 6 +- .../ant/logging/AntLoggerFactory.java | 6 +- .../org/slf4j/impl/StaticLoggerBinder.java | 17 +- .../dependencycheck/utils/DCResources.java | 24 +- .../maven/slf4j/MavenLoggerAdapter.java | 321 ++++++++++++++++++ .../maven/slf4j/MavenLoggerFactory.java | 39 +++ .../org/slf4j/impl/StaticLoggerBinder.java | 26 +- 7 files changed, 413 insertions(+), 26 deletions(-) create mode 100644 dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerAdapter.java create mode 100644 dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerFactory.java diff --git a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerAdapter.java b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerAdapter.java index 1eb932070..137863026 100644 --- a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerAdapter.java +++ b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerAdapter.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright (c) 2013 Jeremy Long. All Rights Reserved. + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. */ package org.owasp.dependencycheck.ant.logging; @@ -24,12 +24,12 @@ import org.slf4j.helpers.MarkerIgnoringBase; import org.slf4j.helpers.MessageFormatter; /** - * An instance of {@link org.slf4j.Logger} which simply calls the log method - * on the delegate Ant task + * An instance of {@link org.slf4j.Logger} which simply calls the log method on the delegate Ant task * * @author colezlaw */ public class AntLoggerAdapter extends MarkerIgnoringBase { + private Task task; public AntLoggerAdapter(Task task) { diff --git a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerFactory.java b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerFactory.java index f47b2c9c3..262e38326 100644 --- a/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerFactory.java +++ b/dependency-check-ant/src/main/java/org/owasp/dependencycheck/ant/logging/AntLoggerFactory.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright (c) 2013 Jeremy Long. All Rights Reserved. + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. */ package org.owasp.dependencycheck.ant.logging; @@ -22,12 +22,12 @@ import org.slf4j.ILoggerFactory; import org.slf4j.Logger; /** - * An implementation of {@link org.slf4j.ILoggerFactory} which always returns - * {@link AntLoggerAdapter} instances. + * An implementation of {@link org.slf4j.ILoggerFactory} which always returns {@link AntLoggerAdapter} instances. * * @author colezlaw */ public class AntLoggerFactory implements ILoggerFactory { + private AntLoggerAdapter antLoggerAdapter; public AntLoggerFactory(Task task) { diff --git a/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java index 7caff75ee..baaeea05a 100644 --- a/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ b/dependency-check-ant/src/main/java/org/slf4j/impl/StaticLoggerBinder.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright (c) 2013 Jeremy Long. All Rights Reserved. + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. */ package org.slf4j.impl; @@ -23,12 +23,13 @@ import org.slf4j.ILoggerFactory; import org.slf4j.spi.LoggerFactoryBinder; /** - * The binding of {@link LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. + * The binding of {@link LoggerFactory} class with an actual instance of {@link ILoggerFactory} is performed using information + * returned by this class. * * @author colezlaw */ public class StaticLoggerBinder implements LoggerFactoryBinder { + /** * The unique instance of this class * @@ -45,8 +46,7 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { } /** - * Ant tasks have the log method we actually want to call. So we hang onto - * the task as a delegate + * Ant tasks have the log method we actually want to call. So we hang onto the task as a delegate */ private Task task; @@ -61,8 +61,8 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { } /** - * Declare the version of the SLF4J API this implementation is compiled - * against. The value of this filed is usually modified with each release. + * Declare the version of the SLF4J API this implementation is compiled against. The value of this filed is usually modified + * with each release. */ // to avoid constant folding by the compiler, this field must *not* be final public static String REQUESTED_API_VERSION = "1.7.12"; // final @@ -70,8 +70,7 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { private static final String loggerFactoryClassStr = AntLoggerFactory.class.getName(); /** - * The ILoggerFactory instance returned by the {@link #getLoggerFactory} - * method should always be the smae object + * The ILoggerFactory instance returned by the {@link #getLoggerFactory} method should always be the smae object */ private ILoggerFactory loggerFactory; diff --git a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/DCResources.java b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/DCResources.java index 2d3327429..10454861d 100644 --- a/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/DCResources.java +++ b/dependency-check-core/src/main/java/org/owasp/dependencycheck/utils/DCResources.java @@ -1,3 +1,20 @@ +/* + * This file is part of dependency-check-ant. + * + * Licensed 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 + * + * 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. + * + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. + */ package org.owasp.dependencycheck.utils; import ch.qos.cal10n.BaseName; @@ -9,11 +26,12 @@ import ch.qos.cal10n.LocaleData; */ @BaseName("dependencycheck-resources") @LocaleData(defaultCharset = "UTF-8", - value = { - @Locale("en") - } + value = { + @Locale("en") + } ) public enum DCResources { + NOTDEPLOYED, GROKERROR, NOTASSEMBLY, diff --git a/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerAdapter.java b/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerAdapter.java new file mode 100644 index 000000000..ca132299f --- /dev/null +++ b/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerAdapter.java @@ -0,0 +1,321 @@ +/* + * This file is part of dependency-check-ant. + * + * Licensed 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 + * + * 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. + * + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. + */ +package org.owasp.dependencycheck.maven.slf4j; + +import org.apache.maven.plugin.logging.Log; +import org.slf4j.helpers.FormattingTuple; +import org.slf4j.helpers.MarkerIgnoringBase; +import org.slf4j.helpers.MessageFormatter; + +/** + * Created by colezlaw on 6/14/15. + */ +public class MavenLoggerAdapter extends MarkerIgnoringBase { + + private Log log; + + public MavenLoggerAdapter(Log log) { + super(); + this.log = log; + } + + @Override + public boolean isTraceEnabled() { + if (log != null) { + return log.isDebugEnabled(); + } + return true; + } + + @Override + public void trace(String msg) { + if (log != null) { + log.debug(msg); + } else { + System.out.println(msg); + } + } + + @Override + public void trace(String format, Object arg) { + String message = MessageFormatter.format(format, arg).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void trace(String format, Object arg1, Object arg2) { + String message = MessageFormatter.format(format, arg1, arg2).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void trace(String format, Object... arguments) { + String message = MessageFormatter.format(format, arguments).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void trace(String msg, Throwable t) { + if (log != null) { + log.debug(msg, t); + } else { + System.out.println(msg); + t.printStackTrace(); + } + } + + @Override + public boolean isDebugEnabled() { + if (log != null) { + return log.isDebugEnabled(); + } + return true; + } + + @Override + public void debug(String msg) { + if (log != null) { + log.debug(msg); + } else { + System.out.println(msg); + } + } + + @Override + public void debug(String format, Object arg) { + String message = MessageFormatter.format(format, arg).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void debug(String format, Object arg1, Object arg2) { + String message = MessageFormatter.format(format, arg1, arg2).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void debug(String format, Object... arguments) { + String message = MessageFormatter.format(format, arguments).getMessage(); + if (log != null) { + log.debug(message); + } else { + System.out.println(message); + } + } + + @Override + public void debug(String msg, Throwable t) { + if (log != null) { + log.debug(msg, t); + } else { + System.out.println(msg); + t.printStackTrace(); + } + } + + @Override + public boolean isInfoEnabled() { + if (log != null) { + return log.isInfoEnabled(); + } + return true; + } + + @Override + public void info(String msg) { + if (log != null) { + log.info(msg); + } else { + System.out.println(msg); + } + } + + @Override + public void info(String format, Object arg) { + String message = MessageFormatter.format(format, arg).getMessage(); + if (log != null) { + log.info(message); + } else { + System.out.println(message); + } + } + + @Override + public void info(String format, Object arg1, Object arg2) { + String message = MessageFormatter.format(format, arg1, arg2).getMessage(); + if (log != null) { + log.info(message); + } else { + System.out.println(message); + } + } + + @Override + public void info(String format, Object... arguments) { + String message = MessageFormatter.format(format, arguments).getMessage(); + if (log != null) { + log.info(message); + } else { + System.out.println(message); + } + } + + @Override + public void info(String msg, Throwable t) { + if (log != null) { + log.info(msg, t); + } else { + System.out.println(msg); + t.printStackTrace(); + } + } + + @Override + public boolean isWarnEnabled() { + if (log != null) { + return log.isWarnEnabled(); + } + return true; + } + + @Override + public void warn(String msg) { + if (log != null) { + log.warn(msg); + } else { + System.out.println(msg); + } + } + + @Override + public void warn(String format, Object arg) { + String message = MessageFormatter.format(format, arg).getMessage(); + if (log != null) { + log.warn(message); + } else { + System.out.println(message); + } + } + + @Override + public void warn(String format, Object arg1, Object arg2) { + String message = MessageFormatter.format(format, arg1, arg2).getMessage(); + if (log != null) { + log.warn(message); + } else { + System.out.println(message); + } + } + + @Override + public void warn(String format, Object... arguments) { + String message = MessageFormatter.format(format, arguments).getMessage(); + if (log != null) { + log.warn(message); + } else { + System.out.println(message); + } + } + + @Override + public void warn(String msg, Throwable t) { + if (log != null) { + log.warn(msg, t); + } else { + System.out.println(msg); + t.printStackTrace(); + } + } + + @Override + public boolean isErrorEnabled() { + if (log != null) { + return log.isErrorEnabled(); + } + return true; + } + + @Override + public void error(String msg) { + if (log != null) { + log.error(msg); + } else { + System.out.println(msg); + } + } + + @Override + public void error(String format, Object arg) { + String message = MessageFormatter.format(format, arg).getMessage(); + if (log != null) { + log.error(message); + } else { + System.out.println(message); + } + } + + @Override + public void error(String format, Object arg1, Object arg2) { + String message = MessageFormatter.format(format, arg1, arg2).getMessage(); + if (log != null) { + log.error(message); + } else { + System.out.println(message); + } + } + + @Override + public void error(String format, Object... arguments) { + String message = MessageFormatter.format(format, arguments).getMessage(); + if (log != null) { + log.error(message); + } else { + System.out.println(message); + } + } + + @Override + public void error(String msg, Throwable t) { + if (log != null) { + log.error(msg, t); + } else { + System.out.println(msg); + t.printStackTrace(); + } + } +} diff --git a/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerFactory.java b/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerFactory.java new file mode 100644 index 000000000..091f16fa9 --- /dev/null +++ b/dependency-check-maven/src/main/java/org/owasp/dependencycheck/maven/slf4j/MavenLoggerFactory.java @@ -0,0 +1,39 @@ +/* + * This file is part of dependency-check-ant. + * + * Licensed 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 + * + * 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. + * + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. + */ +package org.owasp.dependencycheck.maven.slf4j; + +import org.apache.maven.plugin.logging.Log; +import org.slf4j.ILoggerFactory; +import org.slf4j.Logger; + +/** + * Created by colezlaw on 6/14/15. + */ +public class MavenLoggerFactory implements ILoggerFactory { + + private MavenLoggerAdapter mavenLoggerAdapter; + + public MavenLoggerFactory(Log log) { + super(); + this.mavenLoggerAdapter = new MavenLoggerAdapter(log); + } + + public Logger getLogger(String name) { + return mavenLoggerAdapter; + } +} diff --git a/dependency-check-maven/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/dependency-check-maven/src/main/java/org/slf4j/impl/StaticLoggerBinder.java index dd2bd998c..5b61ea85c 100644 --- a/dependency-check-maven/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ b/dependency-check-maven/src/main/java/org/slf4j/impl/StaticLoggerBinder.java @@ -13,22 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. * - * Copyright (c) 2013 Jeremy Long. All Rights Reserved. + * Copyright (c) 2015 The OWASP Foundation. All Rights Reserved. */ package org.slf4j.impl; import org.apache.maven.plugin.logging.Log; -import org.owasp.dependencycheck.maven.MavenLoggerFactory; +import org.owasp.dependencycheck.maven.slf4j.MavenLoggerFactory; import org.slf4j.ILoggerFactory; import org.slf4j.spi.LoggerFactoryBinder; /** - * The binding of {@link org.slf4j.LoggerFactory} class with an actual instance of - * {@link ILoggerFactory} is performed using information returned by this class. + * The binding of {@link org.slf4j.LoggerFactory} class with an actual instance of {@link ILoggerFactory} is performed using + * information returned by this class. * * @author colezlaw */ public class StaticLoggerBinder implements LoggerFactoryBinder { + /** * The unique instance of this class * @@ -60,8 +61,8 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { } /** - * Declare the version of the SLF4J API this implementation is compiled - * against. The value of this filed is usually modified with each release. + * Declare the version of the SLF4J API this implementation is compiled against. The value of this filed is usually modified + * with each release. */ // to avoid constant folding by the compiler, this field must *not* be final public static String REQUESTED_API_VERSION = "1.7.12"; // final @@ -69,8 +70,7 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { private static final String loggerFactoryClassStr = MavenLoggerFactory.class.getName(); /** - * The ILoggerFactory instance returned by the {@link #getLoggerFactory} - * method should always be the smae object + * The ILoggerFactory instance returned by the {@link #getLoggerFactory} method should always be the smae object */ private ILoggerFactory loggerFactory; @@ -78,10 +78,20 @@ public class StaticLoggerBinder implements LoggerFactoryBinder { loggerFactory = new MavenLoggerFactory(log); } + /** + * Returns the logger factory. + * + * @return the logger factory + */ public ILoggerFactory getLoggerFactory() { return loggerFactory; } + /** + * Returns the logger factory class string. + * + * @return the logger factory class string + */ public String getLoggerFactoryClassStr() { return loggerFactoryClassStr; }