diff --git a/samples/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java b/samples/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java index 56b2d2a838..369278e13c 100644 --- a/samples/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java +++ b/samples/jaas/src/main/java/samples/jaas/UsernameEqualsPasswordLoginModule.java @@ -71,6 +71,9 @@ public class UsernameEqualsPasswordLoginModule implements LoginModule { if (username == null || !username.equals(password)) { throw new LoginException("username is not equal to password"); } + if("".equals(username)) { + throw new LoginException("username cannot be empty string"); + } subject.getPrincipals().add(new UsernamePrincipal(username)); return true;