// Path: src/main/java/org/owasp/oneliner/password/HashedPassword.java
// public class HashedPassword {
//     private final String hashedPassword;
//     private final long salt;
// 
//     // Package default to give access to factory class only
//     HashedPassword(String hashedPassword, long salt) {
//         this.salt = salt;
//         this.hashedPassword = hashedPassword;
//     }
// 
//     public long getSalt() {
//         return salt;
//     }
// 
//     public boolean equals(Object other) {
//         if (!(other instanceof HashedPassword)) {
//             return false;
//         } else {
//             HashedPassword otherHashedPassword = (HashedPassword)other;
//             return hashedPassword.equals(otherHashedPassword.hashedPassword) &&
//                     salt == otherHashedPassword.salt;
//         }
//     }
// }
// 
// Path: src/main/java/org/owasp/oneliner/password/HashedPasswordFactory.java
// public class HashedPasswordFactory {
//     @Resource
//     private SecureRandom secureRandom;
// 
//     public HashedPassword createHashedPassword(String plainTextPassword) {
//         long salt = secureRandom.nextLong();
//         return createHashedPassword(plainTextPassword, salt);
//     }
// 
//     public HashedPassword createHashedPassword(String plainTextPassword, long salt) {
//         String hashedPasswordStr = null;
//         try {
//             hashedPasswordStr = new String(sha256.digest((plainTextPassword + salt).getBytes("UTF8")));
//         } catch (UnsupportedEncodingException e) {
//             e.printStackTrace();
//         }
//         return new HashedPassword(hashedPasswordStr, salt);
//     }
// 
//     private static MessageDigest sha256;
//     static {
//         try {
//             sha256 = MessageDigest.getInstance("SHA-256");
//         } catch (NoSuchAlgorithmException e) {
//             e.printStackTrace();
//         }
//     }
// }


import org.owasp.oneliner.password.HashedPassword;
import org.owasp.oneliner.password.HashedPasswordFactory;
import javax.annotation.Resource;
package org.owasp.oneliner.user;



/**
 * Author: @johnwilander
 * Date: 2010-12-18
 */
public class UserFactory {
    @Resource
    HashedPasswordFactory hashedPasswordFactory;

    public User createUser(String userName, String nickName, String password) {
        return createUser(userName, nickName, hashedPasswordFactory.createHashedPassword(password));
    }

// Path: src/main/java/org/owasp/oneliner/password/HashedPassword.java
// public class HashedPassword {
//     private final String hashedPassword;
//     private final long salt;
// 
//     // Package default to give access to factory class only
//     HashedPassword(String hashedPassword, long salt) {
//         this.salt = salt;
//         this.hashedPassword = hashedPassword;
//     }
// 
//     public long getSalt() {
//         return salt;
//     }
// 
//     public boolean equals(Object other) {
//         if (!(other instanceof HashedPassword)) {
//             return false;
//         } else {
//             HashedPassword otherHashedPassword = (HashedPassword)other;
//             return hashedPassword.equals(otherHashedPassword.hashedPassword) &&
//                     salt == otherHashedPassword.salt;
//         }
//     }
// }
// 
// Path: src/main/java/org/owasp/oneliner/password/HashedPasswordFactory.java
// public class HashedPasswordFactory {
//     @Resource
//     private SecureRandom secureRandom;
// 
//     public HashedPassword createHashedPassword(String plainTextPassword) {
//         long salt = secureRandom.nextLong();
//         return createHashedPassword(plainTextPassword, salt);
//     }
// 
//     public HashedPassword createHashedPassword(String plainTextPassword, long salt) {
//         String hashedPasswordStr = null;
//         try {
//             hashedPasswordStr = new String(sha256.digest((plainTextPassword + salt).getBytes("UTF8")));
//         } catch (UnsupportedEncodingException e) {
//             e.printStackTrace();
//         }
//         return new HashedPassword(hashedPasswordStr, salt);
//     }
// 
//     private static MessageDigest sha256;
//     static {
//         try {
//             sha256 = MessageDigest.getInstance("SHA-256");
//         } catch (NoSuchAlgorithmException e) {
//             e.printStackTrace();
//         }
//     }
// }


// Path: src/main/java/org/owasp/oneliner/user/UserFactory.java
import org.owasp.oneliner.password.HashedPassword;
import org.owasp.oneliner.password.HashedPasswordFactory;
import javax.annotation.Resource;

package org.owasp.oneliner.user;



/**
 * Author: @johnwilander
 * Date: 2010-12-18
 */
public class UserFactory {
    @Resource
    HashedPasswordFactory hashedPasswordFactory;

    public User createUser(String userName, String nickName, String password) {
        return createUser(userName, nickName, hashedPasswordFactory.createHashedPassword(password));
    }

    public User createUser(String userName, String nickName, HashedPassword hashedPassword) {