package org.bench4q.master.domain.factory;

import org.bench4q.master.domain.entity.User;
import org.bench4q.master.helper.HashHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserFactory {
	private HashHelper hashHelper;

	private HashHelper getHashHelper() {
		return hashHelper;
	}

	@Autowired
	private void setHashHelper(HashHelper hashHelper) {
		this.hashHelper = hashHelper;
	}

	public User createUser(String userName, String password, byte scope) {
		User user = new User();
		user.setUserName(userName);
		user.setPassword(this.getHashHelper().sha1Hash(password));
		user.setScope(scope);
		return user;
	}
}
