// Path: core/src/main/java/com/jardoapps/usermodule/containers/PasswordResetToken.java
// public class PasswordResetToken {
// 
// 	private final int userId;
// 	private final Date creationTime;
// 	private final String key;
// 
// 	public Date getCreationTime() {
// 		return creationTime;
// 	}
// 
// 	public String getKey() {
// 		return key;
// 	}
// 
// 	public int getUserId() {
// 		return userId;
// 	}
// 
// 	public PasswordResetToken(int userId, String key, Date creationTime) {
// 		this.userId = userId;
// 		this.creationTime = creationTime;
// 		this.key = key;
// 	}
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/containers/SocialAccountDetails.java
// public class SocialAccountDetails {
// 
// 	private final String accountType;
// 
// 	private final String userId;
// 
// 	private final String userName;
// 
// 	private final String email;
// 
// 	public SocialAccountDetails(String accountType, String userId, String userName, String email) {
// 		this.accountType = accountType;
// 		this.userId = userId;
// 		this.userName = userName;
// 		this.email = email;
// 	}
// 
// 	public String getAccountType() {
// 		return accountType;
// 	}
// 
// 	public String getUserId() {
// 		return userId;
// 	}
// 
// 	public String getUserName() {
// 		return userName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/containers/UserPassword.java
// public class UserPassword {
// 
// 	private final String hash;
// 	private final String salt;
// 
// 	public String getHash() {
// 		return hash;
// 	}
// 
// 	public String getSalt() {
// 		return salt;
// 	}
// 
// 	public UserPassword(String hash, String salt) {
// 		this.hash = hash;
// 		this.salt = salt;
// 	}
// 
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/defines/EmailType.java
// public enum EmailType {
// 	LOST_PASSWORD,
// 	MANUAL_REGISTRATION,
// 	REGISTRATION
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/utils/EmailUtils.java
// public final class EmailUtils {
// 
// 	/**
// 	 * Regex for checking email validity. It is designed primarily to determine
// 	 * if an email address is suitable for user registration and therefore is
// 	 * more strict than the RFC 822 specification. For instance address
// 	 * <code>user@localhost</code> is considered valid by RFC 822, but is
// 	 * <b>not</b> considered suitable for user registration.
// 	 */
// 	public static final String EMAIL_REGEX = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})";
// 
// 	/**
// 	 * Check whether the given email matches the {@link #EMAIL_REGEX}. Note that
// 	 * this method is <b>not</b> compliant with RFC 822. See documentation of
// 	 * EMAIL_REGEX for more information. Top level domain validity is not
// 	 * checked.
// 	 * 
// 	 * @param email
// 	 *            email address to check
// 	 * @return true if the given email is considered valid, otherwise false
// 	 */
// 	public static boolean isEmailValid(String email) {
// 		if (email == null) {
// 			return false;
// 		}
// 		return email.matches(EMAIL_REGEX);
// 	}
// 
// 	private EmailUtils() {
// 
// 	}
// 
// }


import org.slf4j.LoggerFactory;
import com.jardoapps.usermodule.containers.PasswordResetToken;
import com.jardoapps.usermodule.containers.SocialAccountDetails;
import com.jardoapps.usermodule.containers.UserPassword;
import com.jardoapps.usermodule.defines.EmailType;
import com.jardoapps.usermodule.utils.EmailUtils;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Date;
import javax.inject.Inject;
import org.slf4j.Logger;

/*
 * This file is part of the User Module library.
 * Copyright (C) 2014 Jaroslav Brtiš
 *
 * User Module library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * User Module library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with User Module library. If not, see <http://www.gnu.org/licenses/>.
 */

package com.jardoapps.usermodule;





/**
 * The main class which contains all the user management logic such as user
 * registration, user log in/out, password changing, password resetting and
 * other.
 * 
 * @author Jaroslav Brtiš
 * 
 */
public class UserManager implements Serializable {

	public static class FatalException extends RuntimeException {

// Path: core/src/main/java/com/jardoapps/usermodule/containers/PasswordResetToken.java
// public class PasswordResetToken {
// 
// 	private final int userId;
// 	private final Date creationTime;
// 	private final String key;
// 
// 	public Date getCreationTime() {
// 		return creationTime;
// 	}
// 
// 	public String getKey() {
// 		return key;
// 	}
// 
// 	public int getUserId() {
// 		return userId;
// 	}
// 
// 	public PasswordResetToken(int userId, String key, Date creationTime) {
// 		this.userId = userId;
// 		this.creationTime = creationTime;
// 		this.key = key;
// 	}
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/containers/SocialAccountDetails.java
// public class SocialAccountDetails {
// 
// 	private final String accountType;
// 
// 	private final String userId;
// 
// 	private final String userName;
// 
// 	private final String email;
// 
// 	public SocialAccountDetails(String accountType, String userId, String userName, String email) {
// 		this.accountType = accountType;
// 		this.userId = userId;
// 		this.userName = userName;
// 		this.email = email;
// 	}
// 
// 	public String getAccountType() {
// 		return accountType;
// 	}
// 
// 	public String getUserId() {
// 		return userId;
// 	}
// 
// 	public String getUserName() {
// 		return userName;
// 	}
// 
// 	public String getEmail() {
// 		return email;
// 	}
// 
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/containers/UserPassword.java
// public class UserPassword {
// 
// 	private final String hash;
// 	private final String salt;
// 
// 	public String getHash() {
// 		return hash;
// 	}
// 
// 	public String getSalt() {
// 		return salt;
// 	}
// 
// 	public UserPassword(String hash, String salt) {
// 		this.hash = hash;
// 		this.salt = salt;
// 	}
// 
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/defines/EmailType.java
// public enum EmailType {
// 	LOST_PASSWORD,
// 	MANUAL_REGISTRATION,
// 	REGISTRATION
// }
// 
// Path: core/src/main/java/com/jardoapps/usermodule/utils/EmailUtils.java
// public final class EmailUtils {
// 
// 	/**
// 	 * Regex for checking email validity. It is designed primarily to determine
// 	 * if an email address is suitable for user registration and therefore is
// 	 * more strict than the RFC 822 specification. For instance address
// 	 * <code>user@localhost</code> is considered valid by RFC 822, but is
// 	 * <b>not</b> considered suitable for user registration.
// 	 */
// 	public static final String EMAIL_REGEX = "[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})";
// 
// 	/**
// 	 * Check whether the given email matches the {@link #EMAIL_REGEX}. Note that
// 	 * this method is <b>not</b> compliant with RFC 822. See documentation of
// 	 * EMAIL_REGEX for more information. Top level domain validity is not
// 	 * checked.
// 	 * 
// 	 * @param email
// 	 *            email address to check
// 	 * @return true if the given email is considered valid, otherwise false
// 	 */
// 	public static boolean isEmailValid(String email) {
// 		if (email == null) {
// 			return false;
// 		}
// 		return email.matches(EMAIL_REGEX);
// 	}
// 
// 	private EmailUtils() {
// 
// 	}
// 
// }


// Path: core/src/main/java/com/jardoapps/usermodule/UserManager.java
import org.slf4j.LoggerFactory;
import com.jardoapps.usermodule.containers.PasswordResetToken;
import com.jardoapps.usermodule.containers.SocialAccountDetails;
import com.jardoapps.usermodule.containers.UserPassword;
import com.jardoapps.usermodule.defines.EmailType;
import com.jardoapps.usermodule.utils.EmailUtils;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Date;
import javax.inject.Inject;
import org.slf4j.Logger;

/*
 * This file is part of the User Module library.
 * Copyright (C) 2014 Jaroslav Brtiš
 *
 * User Module library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * User Module library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with User Module library. If not, see <http://www.gnu.org/licenses/>.
 */

package com.jardoapps.usermodule;





/**
 * The main class which contains all the user management logic such as user
 * registration, user log in/out, password changing, password resetting and
 * other.
 * 
 * @author Jaroslav Brtiš
 * 
 */
public class UserManager implements Serializable {

	public static class FatalException extends RuntimeException {

		private static final long serialVersionUID = 1L;
