cn.twelvet.xss.config.XssProperties Maven / Gradle / Ivy
package cn.twelvet.xss.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.util.ArrayList;
import java.util.List;
/**
* Xss配置类
*
* @author twelvet
*/
@ConfigurationProperties(XssProperties.PREFIX)
public class XssProperties {
/**
* PREFIX
*/
public static final String PREFIX = "security.xss";
/**
* 开启xss
*/
private boolean enabled = true;
/**
* 全局:对文件进行首尾 trim
*/
private boolean trimText = true;
/**
* 模式:clear 清理(默认),escape 转义
*/
private Mode mode = Mode.clear;
/**
* [clear 专用] prettyPrint,默认关闭: 保留换行
*/
private boolean prettyPrint = false;
/**
* [clear 专用] 使用转义,默认关闭
*/
private boolean enableEscape = false;
/**
* 拦截的路由,默认为空
*/
private List pathPatterns = new ArrayList<>();
/**
* 放行的路由,默认为空
*/
private List pathExcludePatterns = new ArrayList<>();
/**
* Mode
*/
public enum Mode {
/**
* 清理
*/
clear,
/**
* 转义
*/
escape,
/**
* 校验,抛出异常
*/
validate;
}
/**
* @return boolean
*/
public boolean isEnabled() {
return enabled;
}
/**
* @param enabled boolean
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
/**
* @return boolean
*/
public boolean isTrimText() {
return trimText;
}
/**
* @param trimText boolean
*/
public void setTrimText(boolean trimText) {
this.trimText = trimText;
}
/**
* @return Mode
*/
public Mode getMode() {
return mode;
}
/**
* @param mode Mode
*/
public void setMode(Mode mode) {
this.mode = mode;
}
/**
* @return boolean
*/
public boolean isPrettyPrint() {
return prettyPrint;
}
/**
* @param prettyPrint boolean
*/
public void setPrettyPrint(boolean prettyPrint) {
this.prettyPrint = prettyPrint;
}
/**
* @return boolean
*/
public boolean isEnableEscape() {
return enableEscape;
}
/**
* @param enableEscape boolean
*/
public void setEnableEscape(boolean enableEscape) {
this.enableEscape = enableEscape;
}
/**
* @return List
*/
public List getPathPatterns() {
return pathPatterns;
}
/**
* @param pathPatterns List
*/
public void setPathPatterns(List pathPatterns) {
this.pathPatterns = pathPatterns;
}
/**
* @return List
*/
public List getPathExcludePatterns() {
return pathExcludePatterns;
}
/**
* @param pathExcludePatterns List
*/
public void setPathExcludePatterns(List pathExcludePatterns) {
this.pathExcludePatterns = pathExcludePatterns;
}
}