You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by bh...@apache.org on 2019/04/12 09:51:31 UTC
[incubator-dlab] 02/02: DLAB-602 fixed bug connected with wrong
error message in case of wrong user login entered
This is an automated email from the ASF dual-hosted git repository.
bhliva pushed a commit to branch bugfix-DLAB-602
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
commit d7d9757ece309343d92f1b171a5351341a2b57d1
Author: bhliva <bo...@epam.com>
AuthorDate: Fri Apr 12 12:51:13 2019 +0300
DLAB-602 fixed bug connected with wrong error message in case of wrong user login entered
---
.../main/java/com/epam/dlab/auth/dao/UserInfoDAOMongoImpl.java | 4 ----
.../epam/dlab/auth/service/impl/LdapAuthenticationService.java | 10 ++++++++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/services/security-service/src/main/java/com/epam/dlab/auth/dao/UserInfoDAOMongoImpl.java b/services/security-service/src/main/java/com/epam/dlab/auth/dao/UserInfoDAOMongoImpl.java
index 845c73a..647e46e 100644
--- a/services/security-service/src/main/java/com/epam/dlab/auth/dao/UserInfoDAOMongoImpl.java
+++ b/services/security-service/src/main/java/com/epam/dlab/auth/dao/UserInfoDAOMongoImpl.java
@@ -74,7 +74,6 @@ public class UserInfoDAOMongoImpl implements UserInfoDAO {
@Override
public void deleteUserInfo(String accessToken) {
- //delete used in logout and has to be synchronized
BasicDBObject uiDoc = new BasicDBObject();
uiDoc.put("_id", accessToken);
MongoCollection<BasicDBObject> security = ms.getCollection(SECURITY_COLLECTION, BasicDBObject.class);
@@ -84,9 +83,6 @@ public class UserInfoDAOMongoImpl implements UserInfoDAO {
@Override
public void saveUserInfo(UserInfo ui) {
- //UserInfo first cached and immediately becomes available
- //Saving can be asynch
-
BasicDBObject uiDoc = new BasicDBObject();
uiDoc.put("_id", ui.getAccessToken());
uiDoc.put("name", ui.getName());
diff --git a/services/security-service/src/main/java/com/epam/dlab/auth/service/impl/LdapAuthenticationService.java b/services/security-service/src/main/java/com/epam/dlab/auth/service/impl/LdapAuthenticationService.java
index 3271558..b324cad 100644
--- a/services/security-service/src/main/java/com/epam/dlab/auth/service/impl/LdapAuthenticationService.java
+++ b/services/security-service/src/main/java/com/epam/dlab/auth/service/impl/LdapAuthenticationService.java
@@ -25,6 +25,7 @@ import com.epam.dlab.auth.UserVerificationService;
import com.epam.dlab.auth.dao.LdapUserDAO;
import com.epam.dlab.auth.dto.UserCredentialDTO;
import com.epam.dlab.auth.service.AuthenticationService;
+import com.epam.dlab.exceptions.DlabAuthenticationException;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
@@ -57,8 +58,13 @@ public class LdapAuthenticationService implements AuthenticationService {
@Override
public Optional<UserInfo> login(UserCredentialDTO credentialDTO) {
- final String token = credentialDTO.getAccessToken();
- return StringUtils.isNoneBlank(token) ? getUserInfo(token) : getLdapUserInfo(credentialDTO);
+ try {
+ final String token = credentialDTO.getAccessToken();
+ return StringUtils.isNoneBlank(token) ? getUserInfo(token) : getLdapUserInfo(credentialDTO);
+ } catch (Exception e) {
+ log.error("Error occurred during login for user {}: {}", credentialDTO.getUsername(), e.getMessage());
+ throw new DlabAuthenticationException("Username or password is invalid");
+ }
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org