Support set default serialize check status (#12333)

This commit is contained in:
Albumen Kevin 2023-05-17 10:46:08 +08:00 committed by GitHub
parent 6777c073a1
commit 2e1fcef156
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 4 deletions

View File

@ -16,13 +16,13 @@
*/
package org.apache.dubbo.common.utils;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;
import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
import org.apache.dubbo.common.logger.LoggerFactory;
public class SerializeSecurityManager {
private static final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(SerializeSecurityManager.class);
@ -38,6 +38,8 @@ public class SerializeSecurityManager {
private volatile SerializeCheckStatus checkStatus = null;
private volatile SerializeCheckStatus defaultCheckStatus = AllowClassNotifyListener.DEFAULT_STATUS;
private volatile Boolean checkSerializable = null;
public void addToAlwaysAllowed(String className) {
@ -92,6 +94,12 @@ public class SerializeSecurityManager {
notifyCheckStatus();
}
public void setDefaultCheckStatus(SerializeCheckStatus checkStatus) {
this.defaultCheckStatus = checkStatus;
logger.info("Serialize check default level: " + checkStatus.name());
notifyCheckStatus();
}
public void setCheckSerializable(boolean checkSerializable) {
if (this.checkSerializable == null || (Boolean.TRUE.equals(this.checkSerializable) && !checkSerializable)) {
this.checkSerializable = checkSerializable;
@ -126,7 +134,7 @@ public class SerializeSecurityManager {
}
protected SerializeCheckStatus getCheckStatus() {
return checkStatus == null ? AllowClassNotifyListener.DEFAULT_STATUS : checkStatus;
return checkStatus == null ? defaultCheckStatus : checkStatus;
}
protected Set<String> getAllowedPrefix() {