Merge branch 'jenkins_with_weblogic' of http://192.168.240.178:18080/eapim/elink-online-common.git into jenkins_with_weblogic
This commit is contained in:
+3
@@ -36,6 +36,9 @@ public class HttpAdapterFilterFactoryKjb extends HttpAdapterFilterFactory {
|
|||||||
case HMAC_SHA256:
|
case HMAC_SHA256:
|
||||||
filter = new HmacSha256VerifyFilterKjb();
|
filter = new HmacSha256VerifyFilterKjb();
|
||||||
break;
|
break;
|
||||||
|
case REFLECTALLHEADER:
|
||||||
|
filter = new ReflectAllHeaderFilter();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
filter = classForName(type);
|
filter = classForName(type);
|
||||||
if (filter == null) {
|
if (filter == null) {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ public enum HttpAdapterFilterType {
|
|||||||
IPWHITELISTFILTER,
|
IPWHITELISTFILTER,
|
||||||
ADAPTERALLOWIPLISTFILTER,
|
ADAPTERALLOWIPLISTFILTER,
|
||||||
HMAC_SHA256,
|
HMAC_SHA256,
|
||||||
|
REFLECTALLHEADER,
|
||||||
UNKNOWN;
|
UNKNOWN;
|
||||||
|
|
||||||
public static HttpAdapterFilterType getValue(String type) {
|
public static HttpAdapterFilterType getValue(String type) {
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package com.eactive.eai.adapter.http.dynamic.filter;
|
||||||
|
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import com.eactive.eai.common.util.Logger;
|
||||||
|
import com.eactive.eai.common.property.PropManager;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class ReflectAllHeaderFilter implements HttpAdapterFilter {
|
||||||
|
|
||||||
|
public ReflectAllHeaderFilter() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static Logger logger = Logger.getLogger(Logger.LOGGER_ADAPTER);
|
||||||
|
|
||||||
|
public static final String PROPERTIES_GROUP_NAME = "HttpHeaderFilter";
|
||||||
|
public static final String HEADER_KEY_NAMES = "AllHeaderFilter.blackList";
|
||||||
|
|
||||||
|
String[] HttpHeaderRelayBlackList = {
|
||||||
|
"Content-Length",
|
||||||
|
"Transfer-Encoding",
|
||||||
|
"Host",
|
||||||
|
"Authorization",
|
||||||
|
"Accept",
|
||||||
|
"Host",
|
||||||
|
"Cookie",
|
||||||
|
"Connection",
|
||||||
|
"Keep-Alive",
|
||||||
|
"Proxy-Authenticate",
|
||||||
|
"Proxy-Authorization",
|
||||||
|
"TE",
|
||||||
|
"Trailer",
|
||||||
|
"Transfer-Encoding",
|
||||||
|
"Upgrade",
|
||||||
|
"Content-Type",
|
||||||
|
"Content-Encoding",
|
||||||
|
"Content-Language",
|
||||||
|
"Content-Location",
|
||||||
|
"Content-MD5",
|
||||||
|
"Expect",
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPreFilter(String adptGrpName, String adptName, Object message, Properties prop,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object doPostFilter(String adptGrpName, String adptName, Object resultMessage, Properties prop,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||||
|
|
||||||
|
logger.debug("doPreFilter ReflectAllHeaderFilter Start.");
|
||||||
|
|
||||||
|
String propValue = PropManager.getInstance().getProperty(PROPERTIES_GROUP_NAME, HEADER_KEY_NAMES, "").trim();
|
||||||
|
String[] userSettingBlackList = propValue.split(",");
|
||||||
|
|
||||||
|
if( userSettingBlackList.length > 0 ) {
|
||||||
|
HttpHeaderRelayBlackList = Stream
|
||||||
|
.concat(Arrays.stream(HttpHeaderRelayBlackList), Arrays.stream(userSettingBlackList))
|
||||||
|
.toArray(String[]::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Enumeration<String> headerNames = request.getHeaderNames();
|
||||||
|
while (headerNames.hasMoreElements()) {
|
||||||
|
|
||||||
|
String headerName = headerNames.nextElement();
|
||||||
|
String headerValue = request.getHeader(headerName);
|
||||||
|
|
||||||
|
if( StringUtils.equalsAnyIgnoreCase( headerName, HttpHeaderRelayBlackList ) ) {
|
||||||
|
logger.debug("Skip Processing Key ["+headerName+"], value ["+headerValue+"] in HttpHeaderRelayBlackList");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setHeader(headerName, headerValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("doPreFilter ReflectAllHeaderFilter End.");
|
||||||
|
|
||||||
|
return resultMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user