Display proper error message when LDAP is unavailable
At the moment the error message 'Incorrect username or password.' is displayed when querying the LDAP server fails because it is unavailable. This message is misleading since the user cannot make the login succeed by correcting the username or password. With this change now a proper error message is displayed so that the user can understand that login is not possible due to the LDAP server not being available. Change-Id: I4afa503642537dbdb33c1031220281f923dddfc8 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2011 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.auth;
|
||||
|
||||
import com.google.gerrit.server.account.AccountException;
|
||||
|
||||
/** A query to the authentication server failed */
|
||||
public class AuthenticationUnavailableException extends AccountException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public AuthenticationUnavailableException(final String message, final Throwable why) {
|
||||
super(message, why);
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.EmailExpander;
|
||||
import com.google.gerrit.server.account.Realm;
|
||||
import com.google.gerrit.server.auth.AuthenticationUnavailableException;
|
||||
import com.google.gerrit.server.auth.ldap.Helper.LdapSchema;
|
||||
import com.google.gerrit.server.cache.Cache;
|
||||
import com.google.gerrit.server.cache.EntryCreator;
|
||||
@@ -238,7 +239,7 @@ class LdapRealm implements Realm {
|
||||
}
|
||||
} catch (NamingException e) {
|
||||
log.error("Cannot query LDAP to autenticate user", e);
|
||||
throw new AccountException("Cannot query LDAP for account", e);
|
||||
throw new AuthenticationUnavailableException("Cannot query LDAP for account", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user