- Map<String,String> userCredentials = MusicUtil.extractBasicAuthentication(authorization);
- String userId = userCredentials.get(MusicUtil.USERID);
- String password = userCredentials.get(MusicUtil.PASSWORD);
- resultMap.remove("keyspace");
- resultMap = MusicAuthentication.autheticateUser(ns, userId, password, keyspaceName, aid,
- "currentLockHolder");
- if (resultMap.containsKey("aid"))
- resultMap.remove("aid");
- if (!resultMap.isEmpty()) {
- logger.error(EELFLoggerDelegate.errorLogger,"", AppMessages.MISSINGDATA ,ErrorSeverity.CRITICAL, ErrorTypes.AUTHENTICATIONERROR);
- response.status(Status.UNAUTHORIZED);
- return response.entity(new JsonResponse(ResultType.FAILURE).setError(String.valueOf(resultMap.get("Error"))).toMap()).build();
+ if (!authenticator.authenticateUser(ns, authorization, keyspaceName, aid, Operation.CURRENT_LOCK)) {
+ return response.status(Status.UNAUTHORIZED)
+ .entity(new JsonResponse(ResultType.FAILURE)
+ .setError("Unauthorized: Please check username, password and make sure your app is onboarded")
+ .toMap()).build();