diff --git a/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java b/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java index e019e426ac..506629dcaf 100644 --- a/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java +++ b/backend/src/main/java/io/metersphere/ldap/controller/LdapController.java @@ -5,6 +5,7 @@ import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.controller.ResultHolder; import io.metersphere.controller.request.LoginRequest; +import io.metersphere.i18n.Translator; import io.metersphere.ldap.service.LdapService; import io.metersphere.ldap.domain.LdapInfo; import io.metersphere.service.SystemParameterService; @@ -30,7 +31,7 @@ public class LdapController { String isOpen = systemParameterService.getValue(ParamConstants.LDAP.OPEN.getValue()); if (StringUtils.isBlank(isOpen) || StringUtils.equals(Boolean.FALSE.toString(), isOpen)) { - MSException.throwException("LDAP 认证未启用!"); + MSException.throwException(Translator.get("ldap_authentication_not_enabled")); } ldapService.authenticate(request); diff --git a/backend/src/main/java/io/metersphere/ldap/dao/PersonRepoImpl.java b/backend/src/main/java/io/metersphere/ldap/dao/PersonRepoImpl.java index a743b8f05b..d453f4c6ef 100644 --- a/backend/src/main/java/io/metersphere/ldap/dao/PersonRepoImpl.java +++ b/backend/src/main/java/io/metersphere/ldap/dao/PersonRepoImpl.java @@ -5,6 +5,7 @@ import io.metersphere.commons.constants.ParamConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.EncryptUtils; import io.metersphere.commons.utils.LogUtil; +import io.metersphere.i18n.Translator; import io.metersphere.ldap.domain.Person; import io.metersphere.service.SystemParameterService; import org.apache.commons.lang3.StringUtils; @@ -42,13 +43,13 @@ public class PersonRepoImpl implements PersonRepo { } catch (AuthenticationException e) { LogUtil.error("ldap authenticate failed..." + e); System.out.println("Login failed: " + e); - MSException.throwException("用户认证失败!"); + MSException.throwException(Translator.get("authentication_failed")); return false; } catch (Exception e) { // Context creation failed - authentication did not succeed LogUtil.error("ldap authenticate failed..." + e); System.out.println("Login failed: " + e); - MSException.throwException("连接失败"); + MSException.throwException(Translator.get("ldap_connect_fail")); return false; } finally { // It is imperative that the created DirContext instance is always closed @@ -78,7 +79,7 @@ public class PersonRepoImpl implements PersonRepo { }); if (result.size() != 1) { - throw new RuntimeException("User not found or not unique"); + throw new RuntimeException(Translator.get("user_not_found_or_not_unique")); } return result.get(0); @@ -126,19 +127,19 @@ public class PersonRepoImpl implements PersonRepo { private void preConnect(String url, String dn, String ou, String password) { if (StringUtils.isBlank(url)) { - MSException.throwException("ldap url is null"); + MSException.throwException(Translator.get("ldap_url_is_null")); } if (StringUtils.isBlank(dn)) { - MSException.throwException("ldap dn is null"); + MSException.throwException(Translator.get("ldap_dn_is_null")); } if (StringUtils.isBlank(ou)) { - MSException.throwException("ldap ou is null"); + MSException.throwException(Translator.get("ldap_ou_is_null")); } if (StringUtils.isBlank(password)) { - MSException.throwException("ldap password is null"); + MSException.throwException(Translator.get("ldap_password_is_null")); } } diff --git a/backend/src/main/java/io/metersphere/ldap/service/LdapService.java b/backend/src/main/java/io/metersphere/ldap/service/LdapService.java index 4a9b92f11e..f5bc5b573a 100644 --- a/backend/src/main/java/io/metersphere/ldap/service/LdapService.java +++ b/backend/src/main/java/io/metersphere/ldap/service/LdapService.java @@ -32,10 +32,10 @@ public class LdapService { } else if (user.size() == 0) { MSException.throwException(Translator.get("user_not_exist") + username); } else { - MSException.throwException("Found multiple users"); + MSException.throwException(Translator.get("find_more_user")); } } catch (CommunicationException e) { - MSException.throwException("LDAP Server connection failed!"); + MSException.throwException(Translator.get("ldap_connect_fail")); } personRepo.authenticate(dn, credentials); } diff --git a/backend/src/main/resources/i18n/messages_en_US.properties b/backend/src/main/resources/i18n/messages_en_US.properties index cd0bf2223f..a4408167b7 100644 --- a/backend/src/main/resources/i18n/messages_en_US.properties +++ b/backend/src/main/resources/i18n/messages_en_US.properties @@ -113,3 +113,14 @@ test_case_report_template_repeat=The workspace has the same name template plan_name_already_exists=Test plan name already exists test_case_already_exists_excel=There are duplicate test cases in the import file api_test_name_already_exists=Test name already exists + +#ldap +ldap_url_is_null=LDAP address is empty +ldap_dn_is_null=LDAP binding DN is empty +ldap_ou_is_null=LDAP parameter OU is empty +ldap_password_is_null=LDAP password is empty +ldap_connect_fail=Connection failed +authentication_failed=User authentication failed +user_not_found_or_not_unique=User does not exist or is not unique +find_more_user=Multiple users found +ldap_authentication_not_enabled=LDAP authentication is not enabled \ No newline at end of file diff --git a/backend/src/main/resources/i18n/messages_zh_CN.properties b/backend/src/main/resources/i18n/messages_zh_CN.properties index d8ce92c489..08f872d5d9 100644 --- a/backend/src/main/resources/i18n/messages_zh_CN.properties +++ b/backend/src/main/resources/i18n/messages_zh_CN.properties @@ -114,6 +114,16 @@ plan_name_already_exists=测试计划名称已存在 test_case_already_exists_excel=导入文件中存在重复用例 api_test_name_already_exists=测试名称已经存在 +#ldap +ldap_url_is_null=LDAP地址为空 +ldap_dn_is_null=LDAP绑定DN为空 +ldap_ou_is_null=LDAP参数OU为空 +ldap_password_is_null=LDAP密码为空 +ldap_connect_fail=连接失败 +authentication_failed=用户认证失败 +user_not_found_or_not_unique=用户不存在或者不唯一 +find_more_user=查找到多个用户 +ldap_authentication_not_enabled=LDAP认证未启用 diff --git a/backend/src/main/resources/i18n/messages_zh_TW.properties b/backend/src/main/resources/i18n/messages_zh_TW.properties index 45ac9d5749..41ae94a8cc 100644 --- a/backend/src/main/resources/i18n/messages_zh_TW.properties +++ b/backend/src/main/resources/i18n/messages_zh_TW.properties @@ -114,3 +114,13 @@ plan_name_already_exists=測試計劃名稱已存在 test_case_already_exists_excel=導入文件中存在重復用例 api_test_name_already_exists=測試名稱已經存在 +#ldap +ldap_url_is_null=LDAP地址為空 +ldap_dn_is_null=LDAP綁定DN為空 +ldap_ou_is_null=LDAP參數OU為空 +ldap_password_is_null=LDAP密碼為空 +ldap_connect_fail=連接失敗 +authentication_failed=用戶認證失敗 +user_not_found_or_not_unique=用戶不存在或者不唯一 +find_more_user=查找到多個用戶 +ldap_authentication_not_enabled=LDAP認證未啟用 diff --git a/frontend/src/business/components/settings/system/LdapSetting.vue b/frontend/src/business/components/settings/system/LdapSetting.vue index 4878ce91e8..a300155338 100644 --- a/frontend/src/business/components/settings/system/LdapSetting.vue +++ b/frontend/src/business/components/settings/system/LdapSetting.vue @@ -2,44 +2,49 @@