mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve WallFilter
This commit is contained in:
@@ -313,6 +313,10 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(FilterChain chain, Wrapper wrapper, Class<?> iface) throws SQLException {
|
||||
if (config.isAllowDoPrivileged() && WallProvider.ispPivileged()) {
|
||||
return chain.isWrapperFor(wrapper, iface);
|
||||
}
|
||||
|
||||
if (!this.provider.getConfig().isWrapAllow()) {
|
||||
return false;
|
||||
}
|
||||
@@ -321,6 +325,10 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
||||
|
||||
@Override
|
||||
public <T> T unwrap(FilterChain chain, Wrapper wrapper, Class<T> iface) throws SQLException {
|
||||
if (config.isAllowDoPrivileged() && WallProvider.ispPivileged()) {
|
||||
return chain.unwrap(wrapper, iface);
|
||||
}
|
||||
|
||||
if (!this.provider.getConfig().isWrapAllow()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -176,6 +176,15 @@ public abstract class WallProvider {
|
||||
result.getViolations().addAll(visitor.getViolations());
|
||||
return result;
|
||||
}
|
||||
|
||||
public static boolean ispPivileged() {
|
||||
Boolean value = privileged.get();
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return value.booleanValue();
|
||||
}
|
||||
|
||||
public static <T> T doPrivileged(PrivilegedAction<T> action) {
|
||||
privileged.set(Boolean.TRUE);
|
||||
|
||||
Reference in New Issue
Block a user