public boolean commit() throws LoginException {
if (!hasSucceeded()) {
cleanup();
return false;
}
Player player = getPlayer();
if (player != null) {
getPlayerPrincipals().addAll(player.getSubject().getPrincipals());
logger.info("player principals:");
for (Principal p : getPlayerPrincipals()) {
logger.info(p.getName());
}
getSubject().getPrincipals().addAll(getPlayerPrincipals());
player.setSubject(getSubject()); // update the players principals
PlayerCredentials playerCredentials = new PlayerCredentials(getUsername(), String.valueOf(getPassword()));
getSubject().getPrivateCredentials().add(playerCredentials);
player.setPlayerCredentials(playerCredentials);
cleanup();
setCommitSucceeded(true);
} else {
throw new LoginException("player was null");