package gov.va.med.cds.saml;

public class SamlAssertionThreadLocal {
	
	private static SamlAssertionXml samlAssertion;
	
	private static final InheritableThreadLocal<SamlAssertionXml> samlAssertionThreadLocal = 
			new InheritableThreadLocal<SamlAssertionXml>() {
		
		@Override 
		protected SamlAssertionXml initialValue() {
			return samlAssertion;
		}
		
		@Override
		public void remove() {
			set(null);
		}
	};
	
	public static String get()  {
		String xml = null;
		if(samlAssertionThreadLocal.get() != null)
			{xml = samlAssertionThreadLocal.get().getSamlAssertion();}
		
		return xml;
	}
	
	public static void set(SamlAssertionXml samlAssertion) {
		samlAssertionThreadLocal.set(samlAssertion);
	}
	
	public static void cleanup() {
		samlAssertionThreadLocal.remove();
	}
	
}
