refactor(系统设置): ldap参数修改
This commit is contained in:
parent
9ff993682d
commit
3c38b27c1a
|
@ -38,7 +38,7 @@ public class LdapService {
|
|||
}
|
||||
|
||||
private LdapTemplate getConnect(LdapRequest request) {
|
||||
String credentials = EncryptUtils.aesDecrypt(request.getLadpPassword()).toString();
|
||||
String credentials = EncryptUtils.aesDecrypt(request.getLdapPassword()).toString();
|
||||
LdapContextSource sourceLdapCtx;
|
||||
if (StringUtils.startsWithIgnoreCase(request.getLdapUrl(), "ldaps://")) {
|
||||
sourceLdapCtx = new SSLLdapContextSource();
|
||||
|
@ -47,7 +47,7 @@ public class LdapService {
|
|||
sourceLdapCtx = new LdapContextSource();
|
||||
}
|
||||
sourceLdapCtx.setUrl(request.getLdapUrl());
|
||||
sourceLdapCtx.setUserDn(request.getLadpDn());
|
||||
sourceLdapCtx.setUserDn(request.getLdapDn());
|
||||
sourceLdapCtx.setPassword(credentials);
|
||||
sourceLdapCtx.setDirObjectFactory(DefaultDirObjectFactory.class);
|
||||
sourceLdapCtx.afterPropertiesSet();
|
||||
|
@ -59,7 +59,7 @@ public class LdapService {
|
|||
sourceLdapCtx.setBaseEnvironmentProperties(baseEnv);
|
||||
ldapTemplate.setDefaultSearchScope(SearchScope.SUBTREE.getId());
|
||||
try {
|
||||
authenticate(request.getLadpDn(), credentials, ldapTemplate);
|
||||
authenticate(request.getLdapDn(), credentials, ldapTemplate);
|
||||
} catch (AuthenticationException e) {
|
||||
LogUtils.error(e.getMessage(), e);
|
||||
throw new MSException(Translator.get("ldap_connect_fail_user"));
|
||||
|
|
|
@ -18,9 +18,9 @@ public class LdapRequest implements Serializable {
|
|||
|
||||
@Schema(description = "LDAP绑定DN", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{ldap_dn_is_null}")
|
||||
private String ladpDn;
|
||||
private String ldapDn;
|
||||
|
||||
@Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@NotBlank(message = "{ldap_password_is_null}")
|
||||
private String ladpPassword;
|
||||
private String ldapPassword;
|
||||
}
|
||||
|
|
|
@ -90,13 +90,14 @@ public class AuthSourceController {
|
|||
|
||||
|
||||
@PostMapping("/ldap/test-connect")
|
||||
@Operation(summary = "ladp测试连接")
|
||||
@Operation(summary = "ldap测试连接")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_UPDATE)
|
||||
public void ldapTestConnect(@Validated @RequestBody LdapRequest request) {
|
||||
ldapService.testConnect(request);
|
||||
}
|
||||
|
||||
@PostMapping("/ldap/test-login")
|
||||
@Operation(summary = "ldap测试登录")
|
||||
@RequiresPermissions(PermissionConstants.SYSTEM_PARAMETER_SETTING_AUTH_READ_UPDATE)
|
||||
public void testLogin(@RequestBody LdapLoginRequest request) {
|
||||
ldapService.testLogin(request);
|
||||
|
|
|
@ -235,8 +235,8 @@ public class AuthSourceControllerTests extends BaseTest {
|
|||
private LdapRequest getRequest(String ldapUrl, String ldapDn, String ldapPassword) {
|
||||
LdapRequest ldapRequest = new LdapRequest();
|
||||
ldapRequest.setLdapUrl(ldapUrl);
|
||||
ldapRequest.setLadpDn(ldapDn);
|
||||
ldapRequest.setLadpPassword(ldapPassword);
|
||||
ldapRequest.setLdapDn(ldapDn);
|
||||
ldapRequest.setLdapPassword(ldapPassword);
|
||||
return ldapRequest;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,8 +12,8 @@ public class LdapRequestDefinition {
|
|||
private String ldapUrl;
|
||||
|
||||
@NotBlank(message = "{ldap_dn_is_null}")
|
||||
private String ladpDn;
|
||||
private String ldapDn;
|
||||
|
||||
@NotBlank(message = "{ldap_password_is_null}")
|
||||
private String ladpPassword;
|
||||
private String ldapPassword;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue