/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.security.ldap;

import com.liferay.portal.kernel.util.AutoResetThreadLocal;
import com.liferay.portal.kernel.util.InitialThreadLocal;
import com.liferay.portal.kernel.util.StringPool;

/**
 * @author Edward Han
 * @author Vilmos Papp
 */
public class LDAPUserTransactionThreadLocal {

	public static String getOriginalEmailAddress() {
		return _originalEmailAddress.get();
	}

	public static boolean isOriginatesFromLDAP() {
		return _originatesFromLDAP.get();
	}

	public static void setOriginalEmailAddress(String originalEmailAddress) {
		_originalEmailAddress.set(originalEmailAddress);
	}

	public static void setOriginatesFromLDAP(boolean originatesFromLDAP) {
		_originatesFromLDAP.set(originatesFromLDAP);
	}

	private static ThreadLocal<String> _originalEmailAddress =
		new AutoResetThreadLocal<String>(
			LDAPUserTransactionThreadLocal.class + "._originalEmailAddress",
			StringPool.BLANK);
	private static ThreadLocal<Boolean> _originatesFromLDAP =
		new InitialThreadLocal<Boolean>(
			LDAPUserTransactionThreadLocal.class + "._originatesFromLDAP",
			false);

}