mirror of
https://github.com/datahub-project/datahub.git
synced 2025-11-12 17:34:18 +00:00
address reviewer comments
This commit is contained in:
parent
58ee2b56f7
commit
d10fdee934
@ -24,20 +24,17 @@ import javax.security.auth.login.LoginException;
|
|||||||
import javax.security.auth.callback.CallbackHandler;
|
import javax.security.auth.callback.CallbackHandler;
|
||||||
import javax.security.auth.callback.Callback;
|
import javax.security.auth.callback.Callback;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
|
||||||
public class AuthenticationManager {
|
public class AuthenticationManager {
|
||||||
|
|
||||||
public static void authenticateUser(String userName, String password) throws NamingException {
|
public static void authenticateUser(String userName, String password) throws NamingException {
|
||||||
if (userName == null || userName.isEmpty() || password == null || password.isEmpty()) {
|
Preconditions.checkNotNull(userName, "Username String cannot be null");
|
||||||
throw new IllegalArgumentException("Username and password can not be blank.");
|
Preconditions.checkNotNull(password, "Password String cannot be null");
|
||||||
}
|
Preconditions.checkArgument(!userName.isEmpty(), "Username cannot be empty");
|
||||||
LoginContext lc = null;
|
Preconditions.checkArgument(!password.isEmpty(), "Password cannot be empty");
|
||||||
try {
|
|
||||||
lc = new LoginContext("WHZ-Authentication", new WHZCallbackHandler(userName, password));
|
|
||||||
} catch (LoginException le) {
|
|
||||||
throw new AuthenticationException(le.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
LoginContext lc = new LoginContext("WHZ-Authentication", new WHZCallbackHandler(userName, password));
|
||||||
lc.login();
|
lc.login();
|
||||||
} catch (LoginException le) {
|
} catch (LoginException le) {
|
||||||
throw new AuthenticationException(le.toString());
|
throw new AuthenticationException(le.toString());
|
||||||
@ -51,6 +48,8 @@ public class AuthenticationManager {
|
|||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void handle(Callback[] callbacks)
|
public void handle(Callback[] callbacks)
|
||||||
throws UnsupportedCallbackException {
|
throws UnsupportedCallbackException {
|
||||||
NameCallback nc = null;
|
NameCallback nc = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user