Package ch.fusun.baron.core.command.base

Source Code of ch.fusun.baron.core.command.base.LoginUserCommand

package ch.fusun.baron.core.command.base;

import ch.fusun.baron.core.command.GameCommand;
import ch.fusun.baron.core.injection.Inject;
import ch.fusun.baron.core.rmi.User;
import ch.fusun.baron.core.service.UserService;

/**
* Tries to log in a user
*/
public class LoginUserCommand extends GameCommand {

  private String name;
  private String password;
  @Inject
  private transient UserService userService;
  private int id;

  /**
   * Constructor
   */
  public LoginUserCommand() {
    // Do nothing
  }

  /**
   * Constructor
   *
   * @param name
   *            the user name
   * @param password
   *            the password
   * @param id
   *            The id
   */
  public LoginUserCommand(String name, String password, int id) {
    this.name = name;
    this.password = password;
    this.id = id;
  }

  @Override
  public boolean isAllowed() {
    return true;
  }

  @Override
  public void execute() {
    userService.login(new User(this.name, this.password), this.id);
  }

}
TOP

Related Classes of ch.fusun.baron.core.command.base.LoginUserCommand

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.