mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve WallFilter
This commit is contained in:
@@ -61,7 +61,7 @@ public class WallConfig implements WallConfigMBean {
|
||||
|
||||
private boolean mustParameterized = false;
|
||||
|
||||
private boolean allowDoPrivileged = false;
|
||||
private boolean doPrivilegedAllow = false;
|
||||
|
||||
protected final Set<String> permitFunctions = new HashSet<String>();
|
||||
protected final Set<String> permitTables = new HashSet<String>();
|
||||
@@ -117,12 +117,12 @@ public class WallConfig implements WallConfigMBean {
|
||||
this.wrapAllow = wrapAllow;
|
||||
}
|
||||
|
||||
public boolean isAllowDoPrivileged() {
|
||||
return allowDoPrivileged;
|
||||
public boolean isDoPrivilegedAllow() {
|
||||
return doPrivilegedAllow;
|
||||
}
|
||||
|
||||
public void setAllowDoPrivileged(boolean allowDoPrivileged) {
|
||||
this.allowDoPrivileged = allowDoPrivileged;
|
||||
public void setDoPrivilegedAllow(boolean doPrivilegedAllow) {
|
||||
this.doPrivilegedAllow = doPrivilegedAllow;
|
||||
}
|
||||
|
||||
public boolean isSelectAllColumnAllow() {
|
||||
|
||||
@@ -320,7 +320,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
||||
|
||||
@Override
|
||||
public boolean isWrapperFor(FilterChain chain, Wrapper wrapper, Class<?> iface) throws SQLException {
|
||||
if (config.isAllowDoPrivileged() && WallProvider.ispPivileged()) {
|
||||
if (config.isDoPrivilegedAllow() && WallProvider.ispPivileged()) {
|
||||
return chain.isWrapperFor(wrapper, iface);
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ 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()) {
|
||||
if (config.isDoPrivilegedAllow() && WallProvider.ispPivileged()) {
|
||||
return chain.unwrap(wrapper, iface);
|
||||
}
|
||||
|
||||
@@ -346,7 +346,7 @@ public class WallFilter extends FilterAdapter implements WallFilterMBean {
|
||||
|
||||
@Override
|
||||
public DatabaseMetaData connection_getMetaData(FilterChain chain, ConnectionProxy connection) throws SQLException {
|
||||
if (config.isAllowDoPrivileged() && WallProvider.ispPivileged()) {
|
||||
if (config.isDoPrivilegedAllow() && WallProvider.ispPivileged()) {
|
||||
return chain.connection_getMetaData(connection);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ public abstract class WallProvider {
|
||||
public WallCheckResult check(String sql) {
|
||||
WallCheckResult result = new WallCheckResult();
|
||||
|
||||
if (config.isAllowDoPrivileged() && privileged.get() == Boolean.TRUE) {
|
||||
if (config.isDoPrivilegedAllow() && ispPivileged()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ public class DoPrivilegedTest extends TestCase {
|
||||
|
||||
public void test_1() throws Exception {
|
||||
final WallConfig config = new WallConfig();
|
||||
config.setAllowDoPrivileged(true);
|
||||
config.setDoPrivilegedAllow(true);
|
||||
|
||||
WallProvider.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user