This is an automated email from the ASF dual-hosted git repository.
lukaszlenart pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/struts.git
The following commit(s) were added to refs/heads/master by this push:
new bab276e Uses Log4j instead of SLF4J
bab276e is described below
commit bab276e29d1f45434db33cbf3db544298b6ecfe1
Author: Lukasz Lenart <[email protected]>
AuthorDate: Sat Jan 1 14:25:32 2022 +0100
Uses Log4j instead of SLF4J
---
.../struts2/interceptor/CoepInterceptor.java | 25 +++++++++++-----------
.../struts2/interceptor/CoopInterceptor.java | 23 ++++++++++----------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git
a/core/src/main/java/org/apache/struts2/interceptor/CoepInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/CoepInterceptor.java
index 1a3dfa2..1c1b7ee 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/CoepInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/CoepInterceptor.java
@@ -22,28 +22,26 @@ import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import com.opensymphony.xwork2.util.TextParseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
-
/**
* Interceptor that implements Cross-Origin Embedder Policy on incoming
requests used to protect a
* document from loading any non-same-origin resources which don't explicitly
grant the document
* permission to be loaded.
*
- *
* @see <a
href="https://web.dev/why-coop-coep/#coep">https://web.dev/why-coop-coep/#coep</a>
* @see <a
href="https://wicg.github.io/cross-origin-embedder-policy/">https://wicg.github.io/cross-origin-embedder-policy/</a>
**/
public class CoepInterceptor extends AbstractInterceptor implements
PreResultListener {
- private static final Logger LOG =
LoggerFactory.getLogger(CoepInterceptor.class);
+ private static final Logger LOG =
LogManager.getLogger(CoepInterceptor.class);
+
private static final String REQUIRE_COEP_HEADER = "require-corp";
private static final String COEP_ENFORCING_HEADER =
"Cross-Origin-Embedder-Policy";
private static final String COEP_REPORT_HEADER =
"Cross-Origin-Embedder-Policy-Report-Only";
@@ -64,28 +62,29 @@ public class CoepInterceptor extends AbstractInterceptor
implements PreResultLis
HttpServletResponse res =
invocation.getInvocationContext().getServletResponse();
final String path = req.getContextPath();
- if (exemptedPaths.contains(path)){
+ if (exemptedPaths.contains(path)) {
// no need to add headers
- LOG.debug(String.format("Skipping COEP header for exempted path
%s", path));
- } else if (!disabled){
+ LOG.debug("Skipping COEP header for exempted path {}", path);
+ } else if (!disabled) {
res.setHeader(header, REQUIRE_COEP_HEADER);
}
}
- public void setExemptedPaths(String paths){
+ public void setExemptedPaths(String paths) {
this.exemptedPaths.addAll(TextParseUtil.commaDelimitedStringToSet(paths));
}
- public void setEnforcingMode(String mode){
+ public void setEnforcingMode(String mode) {
boolean enforcingMode = Boolean.parseBoolean(mode);
- if (enforcingMode){
+ if (enforcingMode) {
header = COEP_ENFORCING_HEADER;
} else {
header = COEP_REPORT_HEADER;
}
}
- public void setDisabled(String value){
+ public void setDisabled(String value) {
disabled = Boolean.parseBoolean(value);
}
+
}
diff --git
a/core/src/main/java/org/apache/struts2/interceptor/CoopInterceptor.java
b/core/src/main/java/org/apache/struts2/interceptor/CoopInterceptor.java
index 9cf6b2e..97043ac 100644
--- a/core/src/main/java/org/apache/struts2/interceptor/CoopInterceptor.java
+++ b/core/src/main/java/org/apache/struts2/interceptor/CoopInterceptor.java
@@ -22,15 +22,14 @@ import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.opensymphony.xwork2.interceptor.PreResultListener;
import com.opensymphony.xwork2.util.TextParseUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashSet;
import java.util.Set;
-
/**
* Interceptor that implements Cross-Origin Opener Policy on incoming
requests. COOP is a mitigation against
* cross-origin information leaks and is used to make websites, cross-origin
isolated. Setting the COOP header allows you to ensure that a top-level window
is
@@ -42,7 +41,8 @@ import java.util.Set;
**/
public class CoopInterceptor extends AbstractInterceptor implements
PreResultListener {
- private static final Logger LOG =
LoggerFactory.getLogger(CoopInterceptor.class);
+ private static final Logger LOG =
LogManager.getLogger(CoopInterceptor.class);
+
private static final String SAME_ORIGIN = "same-origin";
private static final String SAME_ORIGIN_ALLOW_POPUPS =
"same-origin-allow-popups";
private static final String UNSAFE_NONE = "unsafe-none";
@@ -63,30 +63,31 @@ public class CoopInterceptor extends AbstractInterceptor
implements PreResultLis
HttpServletResponse response =
invocation.getInvocationContext().getServletResponse();
String path = request.getContextPath();
- if (isExempted(path)){
+ if (isExempted(path)) {
// no need to add headers
- LOG.debug(String.format("Skipping COOP header for exempted path
%s", path));
+ LOG.debug("Skipping COOP header for exempted path {}", path);
} else {
response.setHeader(COOP_HEADER, getMode());
}
}
- public boolean isExempted(String path){
+ public boolean isExempted(String path) {
return exemptedPaths.contains(path);
}
- public void setExemptedPaths(String paths){
+ public void setExemptedPaths(String paths) {
exemptedPaths.addAll(TextParseUtil.commaDelimitedStringToSet(paths));
}
- private String getMode(){
+ private String getMode() {
return mode;
}
public void setMode(String mode) {
- if (!(mode.equals(SAME_ORIGIN) ||
mode.equals(SAME_ORIGIN_ALLOW_POPUPS) || mode.equals(UNSAFE_NONE))){
+ if (!(mode.equals(SAME_ORIGIN) ||
mode.equals(SAME_ORIGIN_ALLOW_POPUPS) || mode.equals(UNSAFE_NONE))) {
throw new IllegalArgumentException(String.format("Mode '%s' not
recognized!", mode));
}
this.mode = mode;
}
-}
\ No newline at end of file
+
+}