package eu.dnetlib.enabling.aas.utils;

import org.opensaml.lite.common.SAMLObject;

/**
 * Self-cleanable, {@link SAMLObject} based thread local class.
 * Removes element after returning its value.
 * In most cases used for passing SAML data from interceptors to core AAS model.
 * @author mhorst
 *
 */
public class SelfCleanableSAMLThreadLocal extends ThreadLocal<SAMLObject[]>{

	/* (non-Javadoc)
	 * @see java.lang.ThreadLocal#get()
	 */
	@Override
	public SAMLObject[] get() {
		SAMLObject[] result = null;
		try {
			result = super.get();
			return result;
		} finally {
			super.remove();
		}
	}
	
}
