package it.mice.voila.runtime.springmvc.security;

import it.mice.voila.runtime.springmvc.controller.DefaultController;
import it.mice.voila.runtime.springmvc.form.JfFormBean;
import it.mice.voila.runtime.springmvc.util.SpringMvcUtil;

import java.util.Map;

import javax.servlet.http.HttpSession;

public class SkyGenSecurityContext {
	private JfFormBean form;
	private Map<String, Object> context;
	
	public SkyGenSecurityContext() {
		super();
	}
	public SkyGenSecurityContext(Map<String, Object> context) {
		super();
		this.context = context;
	}

	public Object getSessionContext() {
		return context;
	}

	public Object getForm() {
		if (form != null) {
			return form;
		}
		Object result = null;
		HttpSession session = SpringMvcUtil.getSession();
		String formId = (String)session.getAttribute(DefaultController.FORM_ID);
		if (formId != null) {
			result = session.getAttribute(formId);
		}
		
		return result;
	}

	/**
	 * @param form the form to set
	 */
	public void setForm(JfFormBean form) {
		this.form = form;
	}
	
	
}
