You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
187 lines
6.2 KiB
187 lines
6.2 KiB
3 years ago
|
package com.fr.plugin.xxx.xxx.sso;
|
||
|
|
||
|
import com.fr.config.*;
|
||
|
import com.fr.config.holder.Conf;
|
||
|
import com.fr.config.holder.factory.Holders;
|
||
|
import com.fr.stable.StringUtils;
|
||
|
|
||
|
/**
|
||
|
* @Author xxx
|
||
|
* @Date 2022/3/3
|
||
|
* @Description
|
||
|
**/
|
||
|
@Visualization(category = "单点配置")
|
||
|
public class xxxConfig extends DefaultConfiguration {
|
||
|
|
||
|
private static volatile xxxConfig config = null;
|
||
|
|
||
|
public static xxxConfig getInstance() {
|
||
|
if (config == null) {
|
||
|
config = ConfigContext.getConfigInstance(xxxConfig.class);
|
||
|
}
|
||
|
return config;
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "debugSwitch", name = "插件调试开关", description = "日志调试模式", status = Status.SHOW)
|
||
|
private Conf<Boolean> debugSwitch = Holders.simple(true);
|
||
|
|
||
|
public Boolean getDebugSwitch() {
|
||
|
return this.debugSwitch.get();
|
||
|
}
|
||
|
|
||
|
public void setDebugSwitch(Boolean debugSwitch) {
|
||
|
this.debugSwitch.set(debugSwitch);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "timeout", name = "授权超时时间", description = "授权超时时间,单位分钟", status = Status.SHOW)
|
||
|
private Conf<Integer> timeout = Holders.simple(5);
|
||
|
|
||
|
public Integer getTimeout() {
|
||
|
return timeout.get();
|
||
|
}
|
||
|
|
||
|
public void setTimeout(Integer timeout) {
|
||
|
this.timeout.set(timeout);
|
||
|
}
|
||
|
@Identifier(value = "key", name = "解密秘钥", description = "解密秘钥", status = Status.SHOW)
|
||
|
private Conf<String> key = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getKey() {
|
||
|
return key.get();
|
||
|
}
|
||
|
|
||
|
public void setKey(String key) {
|
||
|
this.key.set(key);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "loginUrl", name = "跳转登录地址", description = "跳转登录地址", status = Status.SHOW)
|
||
|
private Conf<String> loginUrl = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getLoginUrl() {
|
||
|
return loginUrl.get();
|
||
|
}
|
||
|
|
||
|
public void setLoginUrl(String loginUrl) {
|
||
|
this.loginUrl.set(loginUrl);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "clientId", name = "clientId", description = "服务端预设的访问代码,即应用名称", status = Status.SHOW)
|
||
|
private Conf<String> clientId = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getClientId() {
|
||
|
return clientId.get();
|
||
|
}
|
||
|
|
||
|
public void setClientId(String clientId) {
|
||
|
this.clientId.set(clientId);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "clientSecret", name = "clientSecret", description = "服务端预设的访问密钥", status = Status.SHOW)
|
||
|
private Conf<String> clientSecret = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getClientSecret() {
|
||
|
return clientSecret.get();
|
||
|
}
|
||
|
|
||
|
public void setClientSecret(String clientSecret) {
|
||
|
this.clientSecret.set(clientSecret);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "grantType", name = "grant_type", description = "grant_type", status = Status.SHOW)
|
||
|
private Conf<String> grantType = Holders.simple("authorization_cod");
|
||
|
|
||
|
public String getGrantType() {
|
||
|
return grantType.get();
|
||
|
}
|
||
|
|
||
|
public void setGrantType(String grantType) {
|
||
|
this.grantType.set(grantType);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "responseType", name = "response_type", description = "response_type", status = Status.SHOW)
|
||
|
private Conf<String> responseType = Holders.simple("code");
|
||
|
|
||
|
public String getResponseType() {
|
||
|
return responseType.get();
|
||
|
}
|
||
|
|
||
|
public void setResponseType(String responseType) {
|
||
|
this.responseType.set(responseType);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "accessUrl", name = "accessUrl", description = "换取access_token的地址", status = Status.SHOW)
|
||
|
private Conf<String> accessUrl = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getAccessUrl() {
|
||
|
return accessUrl.get();
|
||
|
}
|
||
|
|
||
|
public void setAccessUrl(String accessUrl) {
|
||
|
this.accessUrl.set(accessUrl);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "profileUrl", name = "profileUrl", description = "换取用户信息的地址", status = Status.SHOW)
|
||
|
private Conf<String> profileUrl = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getProfileUrl() {
|
||
|
return profileUrl.get();
|
||
|
}
|
||
|
|
||
|
public void setProfileUrl(String profileUrl) {
|
||
|
this.profileUrl.set(profileUrl);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "redirectUrl", name = "回调地址", description = "回调地址,默认配置的回调地址", status = Status.SHOW)
|
||
|
private Conf<String> redirectUrl = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getRedirectUrl() {
|
||
|
return redirectUrl.get();
|
||
|
}
|
||
|
|
||
|
public void setRedirectUrl(String redirectUrl) {
|
||
|
this.redirectUrl.set(redirectUrl);
|
||
|
}
|
||
|
|
||
|
@Identifier(value = "logout", name = "登出地址", description = "登出地址", status = Status.SHOW)
|
||
|
private Conf<String> logout = Holders.simple(StringUtils.EMPTY);
|
||
|
|
||
|
public String getLogout() {
|
||
|
return logout.get();
|
||
|
}
|
||
|
|
||
|
public void setLogout(String logout) {
|
||
|
this.logout.set(logout);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
@Override
|
||
|
public Object clone() throws CloneNotSupportedException {
|
||
|
xxxConfig cloned = (xxxConfig) super.clone();
|
||
|
cloned.debugSwitch = (Conf<Boolean>) debugSwitch.clone();
|
||
|
cloned.timeout = (Conf<Integer>) timeout.clone();
|
||
|
cloned.key = (Conf<String>) key.clone();
|
||
|
cloned.loginUrl = (Conf<String>) loginUrl.clone();
|
||
|
cloned.clientId = (Conf<String>) clientId.clone();
|
||
|
cloned.clientSecret = (Conf<String>) clientSecret.clone();
|
||
|
cloned.grantType = (Conf<String>) grantType.clone();
|
||
|
cloned.responseType = (Conf<String>) responseType.clone();
|
||
|
cloned.accessUrl = (Conf<String>) accessUrl.clone();
|
||
|
cloned.profileUrl = (Conf<String>) profileUrl.clone();
|
||
|
cloned.redirectUrl = (Conf<String>) redirectUrl.clone();
|
||
|
cloned.logout = (Conf<String>) logout.clone();
|
||
|
return cloned;
|
||
|
}
|
||
|
|
||
|
public boolean isTokenConfig(){
|
||
|
return StringUtils.isNotBlank(getKey()) && timeout != null;
|
||
|
}
|
||
|
|
||
|
|
||
|
public boolean isConfiged() {
|
||
|
return StringUtils.isNotBlank(getLoginUrl()) && StringUtils.isNotBlank(getClientId())
|
||
|
&& StringUtils.isNotBlank(getClientSecret()) && StringUtils.isNotBlank(getGrantType())
|
||
|
&& StringUtils.isNotBlank(getResponseType()) && StringUtils.isNotBlank(getAccessUrl())
|
||
|
&& StringUtils.isNotBlank(getProfileUrl()) && StringUtils.isNotBlank(getRedirectUrl());
|
||
|
}
|
||
|
}
|