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

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

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;

/**
* Creates a User with the specified name and password
*/
public class CreateUserCommand extends GameCommand {

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

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

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

  @Override
  public boolean isAllowed() {
    return !userService.exists(this.name);
  }

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

}
TOP

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

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.