mirror of https://gitee.com/topiam/eiam
⚡ 优化认证提供商
parent
d79a22c88d
commit
fdcea2f108
|
@ -110,7 +110,7 @@ public final class IdentityProviderType {
|
||||||
* 支付宝认证
|
* 支付宝认证
|
||||||
*/
|
*/
|
||||||
public static final IdentityProviderType ALIPAY_OAUTH = new IdentityProviderType(
|
public static final IdentityProviderType ALIPAY_OAUTH = new IdentityProviderType(
|
||||||
"alipay_oauth", "支付宝认证", "通过支付宝进行身份认证");
|
"alipay_oauth", "支付宝认证", "通过支付宝进行身份认证");
|
||||||
|
|
||||||
private final String value;
|
private final String value;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -104,6 +105,10 @@ public class DingtalkOauthAuthenticationFilter extends AbstractIdpAuthentication
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
TraceUtils.put(UUID.randomUUID().toString());
|
TraceUtils.put(UUID.randomUUID().toString());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -110,6 +111,10 @@ public class DingtalkScanCodeAuthenticationFilter extends
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
|
|
|
@ -131,24 +131,9 @@ public class DingtalkScanCodeAuthorizationRequestGetFilter extends OncePerReques
|
||||||
.state(DEFAULT_STATE_GENERATOR.generateKey())
|
.state(DEFAULT_STATE_GENERATOR.generateKey())
|
||||||
.attributes(attributes);
|
.attributes(attributes);
|
||||||
builder.parameters(parameters -> {
|
builder.parameters(parameters -> {
|
||||||
HashMap<String, Object> linkedParameters = new LinkedHashMap<>();
|
parameters.put(APP_ID, parameters.get(OAuth2ParameterNames.CLIENT_ID));
|
||||||
parameters.forEach((key, value) -> {
|
parameters.remove(OAuth2ParameterNames.CLIENT_ID);
|
||||||
if (OAuth2ParameterNames.CLIENT_ID.equals(key)) {
|
parameters.put(RESPONSE_TYPE, CODE);
|
||||||
linkedParameters.put(APP_ID, value);
|
|
||||||
}
|
|
||||||
if (OAuth2ParameterNames.SCOPE.equals(key)) {
|
|
||||||
linkedParameters.put(OAuth2ParameterNames.SCOPE, value);
|
|
||||||
}
|
|
||||||
if (OAuth2ParameterNames.STATE.equals(key)) {
|
|
||||||
linkedParameters.put(OAuth2ParameterNames.STATE, value);
|
|
||||||
}
|
|
||||||
if (OAuth2ParameterNames.REDIRECT_URI.equals(key)) {
|
|
||||||
linkedParameters.put(OAuth2ParameterNames.REDIRECT_URI, value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
linkedParameters.put(RESPONSE_TYPE, CODE);
|
|
||||||
parameters.clear();
|
|
||||||
parameters.putAll(linkedParameters);
|
|
||||||
});
|
});
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
this.writeForAuthorization(request, response, builder.build());
|
this.writeForAuthorization(request, response, builder.build());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.Objects;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.message.BasicHeader;
|
import org.apache.http.message.BasicHeader;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -90,6 +91,10 @@ public class FeiShuLoginAuthenticationFilter extends AbstractIdpAuthenticationPr
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -94,6 +95,10 @@ public class GiteeLoginAuthenticationFilter extends AbstractIdpAuthenticationPro
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -94,6 +95,10 @@ public class GithubOAuth2LoginAuthenticationFilter extends
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
TraceUtils.put(UUID.randomUUID().toString());
|
TraceUtils.put(UUID.randomUUID().toString());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -96,6 +97,10 @@ public class QqOAuth2LoginAuthenticationFilter extends AbstractIdpAuthentication
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
TraceUtils.put(UUID.randomUUID().toString());
|
TraceUtils.put(UUID.randomUUID().toString());
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -94,6 +95,10 @@ public class WeChatScanCodeLoginAuthenticationFilter extends
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
RequestMatcher.MatchResult matcher = REQUEST_MATCHER.matcher(request);
|
||||||
|
|
|
@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.http.HttpMethod;
|
import org.springframework.http.HttpMethod;
|
||||||
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||||
|
@ -96,6 +97,10 @@ public class WeChatWorkScanCodeLoginAuthenticationFilter extends
|
||||||
public Authentication attemptAuthentication(HttpServletRequest request,
|
public Authentication attemptAuthentication(HttpServletRequest request,
|
||||||
HttpServletResponse response) throws AuthenticationException,
|
HttpServletResponse response) throws AuthenticationException,
|
||||||
IOException {
|
IOException {
|
||||||
|
if (!REQUEST_MATCHER.matches(request)) {
|
||||||
|
throw new AuthenticationServiceException(
|
||||||
|
"Authentication method not supported: " + request.getMethod());
|
||||||
|
}
|
||||||
TraceUtils.put(UUID.randomUUID().toString());
|
TraceUtils.put(UUID.randomUUID().toString());
|
||||||
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
OAuth2AuthorizationRequest authorizationRequest = getOauth2AuthorizationRequest(request,
|
||||||
response);
|
response);
|
||||||
|
|
|
@ -58,7 +58,6 @@ import cn.topiam.employee.support.repository.page.domain.QueryDslRequest;
|
||||||
import cn.topiam.employee.support.validation.ValidationUtils;
|
import cn.topiam.employee.support.validation.ValidationUtils;
|
||||||
|
|
||||||
import jakarta.validation.ConstraintViolationException;
|
import jakarta.validation.ConstraintViolationException;
|
||||||
|
|
||||||
import static cn.topiam.employee.authentication.common.IdentityProviderType.*;
|
import static cn.topiam.employee.authentication.common.IdentityProviderType.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,16 +113,16 @@ public interface IdentityProviderConverter {
|
||||||
}
|
}
|
||||||
IdentityProviderCategory category = IdentityProviderCategory.getType(param.getCategory());
|
IdentityProviderCategory category = IdentityProviderCategory.getType(param.getCategory());
|
||||||
if (!category.getProviders().stream().map(IdentityProviderType::value).toList()
|
if (!category.getProviders().stream().map(IdentityProviderType::value).toList()
|
||||||
.contains(param.getType())) {
|
.contains(param.getType())) {
|
||||||
throw new TopIamException("认证源类型与认证源提供商不匹配");
|
throw new TopIamException("认证源类型与认证源提供商不匹配");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
IdentityProviderConfig identityProviderConfig = getIdentityProviderConfig(
|
IdentityProviderConfig identityProviderConfig = getIdentityProviderConfig(
|
||||||
param.getType(), param.getConfig());
|
param.getType(), param.getConfig());
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// 指定序列化输入的类型
|
// 指定序列化输入的类型
|
||||||
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
||||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||||
//封装数据
|
//封装数据
|
||||||
IdentityProviderEntity entity = new IdentityProviderEntity();
|
IdentityProviderEntity entity = new IdentityProviderEntity();
|
||||||
entity.setName(param.getName());
|
entity.setName(param.getName());
|
||||||
|
@ -161,15 +160,15 @@ public interface IdentityProviderConverter {
|
||||||
result.setRemark(entity.getRemark());
|
result.setRemark(entity.getRemark());
|
||||||
//回调地址
|
//回调地址
|
||||||
result.setRedirectUri(ServerHelp.getPortalPublicBaseUrl()
|
result.setRedirectUri(ServerHelp.getPortalPublicBaseUrl()
|
||||||
+ getIdentityProviderType(entity.getType()).getLoginPathPrefix() + "/"
|
+ getIdentityProviderType(entity.getType()).getLoginPathPrefix() + "/"
|
||||||
+ entity.getCode());
|
+ entity.getCode());
|
||||||
try {
|
try {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// 指定序列化输入的类型
|
// 指定序列化输入的类型
|
||||||
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
||||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||||
IdentityProviderConfig config = objectMapper.readValue(entity.getConfig(),
|
IdentityProviderConfig config = objectMapper.readValue(entity.getConfig(),
|
||||||
IdentityProviderConfig.class);
|
IdentityProviderConfig.class);
|
||||||
result.setConfig(config);
|
result.setConfig(config);
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -189,7 +188,7 @@ public interface IdentityProviderConverter {
|
||||||
QueryDslRequest request = new QueryDslRequest();
|
QueryDslRequest request = new QueryDslRequest();
|
||||||
QIdentityProviderEntity queryEntity = QIdentityProviderEntity.identityProviderEntity;
|
QIdentityProviderEntity queryEntity = QIdentityProviderEntity.identityProviderEntity;
|
||||||
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
|
Predicate predicate = ExpressionUtils.and(queryEntity.isNotNull(),
|
||||||
queryEntity.deleted.eq(Boolean.FALSE));
|
queryEntity.deleted.eq(Boolean.FALSE));
|
||||||
//查询条件
|
//查询条件
|
||||||
//@formatter:off
|
//@formatter:off
|
||||||
predicate = Objects.isNull(query.getCategory()) ? predicate : ExpressionUtils.and(predicate, queryEntity.category.eq(query.getCategory()));
|
predicate = Objects.isNull(query.getCategory()) ? predicate : ExpressionUtils.and(predicate, queryEntity.category.eq(query.getCategory()));
|
||||||
|
@ -198,7 +197,7 @@ public interface IdentityProviderConverter {
|
||||||
request.setPredicate(predicate);
|
request.setPredicate(predicate);
|
||||||
//分页条件
|
//分页条件
|
||||||
request.setPageRequest(QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
|
request.setPageRequest(QPageRequest.of(pageModel.getCurrent(), pageModel.getPageSize(),
|
||||||
queryEntity.updateTime.desc()));
|
queryEntity.updateTime.desc()));
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,11 +212,11 @@ public interface IdentityProviderConverter {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IdentityProviderConfig identityProviderConfig = getIdentityProviderConfig(param.getType(),
|
IdentityProviderConfig identityProviderConfig = getIdentityProviderConfig(param.getType(),
|
||||||
param.getConfig());
|
param.getConfig());
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
// 指定序列化输入的类型
|
// 指定序列化输入的类型
|
||||||
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
objectMapper.activateDefaultTyping(objectMapper.getPolymorphicTypeValidator(),
|
||||||
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||||
try {
|
try {
|
||||||
//封装数据
|
//封装数据
|
||||||
IdentityProviderEntity identityProviderEntity = new IdentityProviderEntity();
|
IdentityProviderEntity identityProviderEntity = new IdentityProviderEntity();
|
||||||
|
@ -227,7 +226,7 @@ public interface IdentityProviderConverter {
|
||||||
identityProviderEntity.setRemark(param.getRemark());
|
identityProviderEntity.setRemark(param.getRemark());
|
||||||
//配置
|
//配置
|
||||||
identityProviderEntity
|
identityProviderEntity
|
||||||
.setConfig(objectMapper.writeValueAsString(identityProviderConfig));
|
.setConfig(objectMapper.writeValueAsString(identityProviderConfig));
|
||||||
return identityProviderEntity;
|
return identityProviderEntity;
|
||||||
} catch (JsonProcessingException e) {
|
} catch (JsonProcessingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -280,7 +279,7 @@ public interface IdentityProviderConverter {
|
||||||
throw new NullPointerException("提供商配置不能为空");
|
throw new NullPointerException("提供商配置不能为空");
|
||||||
}
|
}
|
||||||
ValidationUtils.ValidationResult<?> validationResult = ValidationUtils
|
ValidationUtils.ValidationResult<?> validationResult = ValidationUtils
|
||||||
.validateEntity(identityProviderConfig);
|
.validateEntity(identityProviderConfig);
|
||||||
if (validationResult.isHasErrors()) {
|
if (validationResult.isHasErrors()) {
|
||||||
throw new ConstraintViolationException(validationResult.getConstraintViolations());
|
throw new ConstraintViolationException(validationResult.getConstraintViolations());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue