// the password is in the first position
if (!new String(tmpPassword).equals(token))
throw new FailedLoginException("Tokens do not match");
principals = new HashSet<Principal>();
principals.add(new UserPrincipal(user));
principals.add(new RolePrincipal("container"));
principals.add(new RolePrincipal("admin"));
subject.getPrivateCredentials().add(new String(tmpPassword));
result = true;
} else {
String userInfos = users.getProperty(user);
if (userInfos == null)
throw new FailedLoginException("User doesn't exist");
// the password is in the first position
String[] infos = userInfos.split(",");
String password = infos[0];
if (!checkPassword(new String(tmpPassword), password))
throw new FailedLoginException("Password does not match");
principals = new HashSet<Principal>();
principals.add(new UserPrincipal(user));
for (int i = 1; i < infos.length; i++) {
if (infos[i].trim().startsWith(BackingEngine.GROUP_PREFIX)) {
// it's a group reference
principals.add(new GroupPrincipal(infos[i].trim().substring(BackingEngine.GROUP_PREFIX.length())));
String groupInfo = (String) users.get(infos[i].trim());