/*
  * (non-Javadoc)
  * @see com.syncnapsis.data.service.PlayerManager#login(java.lang.String, java.lang.String)
  */
 @Override
 public Player login(String username, String password) {
   User user = userManager.login(username, password);
   if (user == null) return null;
   Player player = getByUsername(username);
   if (player != null) {
     securityManager.getPlayerProvider().set(player);
     securityManager.getEmpireProvider().set(player.getCurrentEmpire());
     return player;
   } else {
     userManager.logout();
     return null;
   }
 }
  /*
   * (non-Javadoc)
   * @see com.syncnapsis.data.service.PlayerManager#register(java.lang.String, java.lang.String,
   * java.lang.String, java.lang.String)
   */
  @Override
  public Player register(String username, String email, String password, String passwordConfirm)
      throws PlayerRegistrationFailedException {
    User user;
    try {
      user = userManager.register(username, email, password, passwordConfirm);
    } catch (UserRegistrationFailedException e) {
      throw new PlayerRegistrationFailedException(e.getMessage());
    }

    Player player = new Player();
    player.setAccountStatus(user.getAccountStatus());
    player.setAccountStatusExpireDate(user.getAccountStatusExpireDate());
    player.setActivated(true);
    // player.setCurrentEmpire(null);
    player.setRole(playerRoleManager.getByMask(GameBaseConstants.ROLE_NORMAL_PLAYER));
    player.setRoleExpireDate(user.getRoleExpireDate());
    player.setUser(user);

    player = save(player);

    return player;
  }
 /*
  * (non-Javadoc)
  * @see com.syncnapsis.data.service.PlayerManager#logout()
  */
 @Override
 public boolean logout() {
   securityManager.getPlayerProvider().set(null);
   return userManager.logout();
 }