}
} else { // doLogin returning false
Logger.warn(this.getClass(), "Request IP: " + ip + ". Can't authenticate user. Username: " + username);
SecurityLogger.logDebug(this.getClass(), "Request IP: " + ip + ". Can't authenticate user. Username: " + username);
throw new SecurityException("Invalid credentials", Response.Status.UNAUTHORIZED);
}
} catch(SecurityException e) {
throw e;
} catch (Exception e) { // doLogin throwing Exception
Logger.warn(this.getClass(), "Request IP: " + ip + ". Can't authenticate user. Username: " + username);
SecurityLogger.logDebug(this.getClass(), "Request IP: " + ip + ". Can't authenticate user. Username: " + username);
throw new SecurityException("Authentication credentials are required", Response.Status.UNAUTHORIZED);
}
} else if(UtilMethods.isSet(username) || UtilMethods.isSet(password)){ // providing login or password
Logger.warn(this.getClass(), "Request IP: " + ip + ". Can't authenticate user.");
SecurityLogger.logDebug(this.getClass(), "Request IP: " + ip + ". Can't authenticate user.");
throw new SecurityException("Authentication credentials are required", Response.Status.UNAUTHORIZED);
}
return user;
}