String auditId;
String userId=null;
String documentId;
String executionId;
IEngUserProfile profile = null;
String requestUrl;
logger.debug("IN");
try {
FilterIOManager ioManager = new FilterIOManager(request, response);
documentId = (String) request.getParameter(DOCUMENT_ID_PARAM_NAME);
logger.info("Filter documentId from request:" + documentId);
auditId = request.getParameter( AUDIT_ID_PARAM_NAME );
logger.debug("Filter auditId from request::" + auditId);
executionId = (String)request.getParameter(EXECUTION_ID);
logger.debug("Filter executionId from request::" + executionId);
userId = request.getParameter( SsoServiceInterface.USER_ID );
logger.debug("Filter userId from request::" + userId);
if (request instanceof HttpServletRequest) {
HttpServletRequest httpRequest = (HttpServletRequest) request;
requestUrl = httpRequest.getRequestURL().toString();
logger.info("requestUrl: " + requestUrl);
ioManager.initConetxtManager();
ioManager.setInSession(DOCUMENT_ID_PARAM_NAME, documentId);
ioManager.setInSession(IS_BACKEND_ATTR_NAME, "false");
ioManager.contextManager.set(DOCUMENT_ID_PARAM_NAME, documentId);
ioManager.contextManager.set(IS_BACKEND_ATTR_NAME, "false");
boolean isBackend = false;
if (requestUrl.endsWith("BackEnd")) {
String passTicket = (String) request.getParameter(SpagoBIConstants.PASS_TICKET);
if (passTicket != null && passTicket.equalsIgnoreCase(EnginConf.getInstance().getPass())) {
// if a request is coming from SpagoBI context
isBackend = true;
profile=UserProfile.createSchedulerUserProfile();
ioManager.setInSession(IS_BACKEND_ATTR_NAME, "true");
ioManager.contextManager.set(IS_BACKEND_ATTR_NAME, "true");
if (userId!=null && UserProfile.isSchedulerUser(userId)){
ioManager.setInSession(IEngUserProfile.ENG_USER_PROFILE, UserProfile.createSchedulerUserProfile());
ioManager.contextManager.set(IEngUserProfile.ENG_USER_PROFILE, UserProfile.createSchedulerUserProfile());
logger.info("IS a Scheduler Request ...");
}else if(userId!=null && UserProfile.isWorkflowUser(userId)){
ioManager.setInSession(IEngUserProfile.ENG_USER_PROFILE, UserProfile.createWorkFlowUserProfile());
ioManager.contextManager.set(IEngUserProfile.ENG_USER_PROFILE, UserProfile.createWorkFlowUserProfile());
logger.info("IS a Workflow Request ...");
}else{
logger.info("IS a backEnd Request ...");
}
} else {
logger.warn("PassTicked is NULL in BackEnd call");
throw new ServletException();
}
}else {
userId = getUserWithSSO(httpRequest);
}
String spagobiContext = request.getParameter(SpagoBIConstants.SBI_CONTEXT);
String spagoUrl = request.getParameter(SpagoBIConstants.SBI_HOST);
if (spagobiContext != null) {
logger.debug("spagobiContext:" + spagobiContext);
ioManager.setInSession(SpagoBIConstants.SBI_CONTEXT, spagobiContext);
ioManager.contextManager.set(SpagoBIConstants.SBI_CONTEXT, spagobiContext);
} else {
logger.warn("spagobiContext is null.");
}
if (spagoUrl != null) {
logger.debug("spagoUrl:" + spagoUrl);
ioManager.setInSession(SpagoBIConstants.SBI_HOST, spagoUrl);
ioManager.contextManager.set(SpagoBIConstants.SBI_HOST, spagoUrl);
} else {
logger.warn("spagoUrl is null.");
}
if(userId != null) {
try {
// this is not correct. profile in session can come also from a concurrent execution
profile = (IEngUserProfile) ioManager.getFromSession(IEngUserProfile.ENG_USER_PROFILE);
if (profile == null || !profile.getUserUniqueIdentifier().toString().equals(userId)) {
SecurityServiceProxy proxy = new SecurityServiceProxy(userId, ioManager.getSession());
profile = proxy.getUserProfile();
if (profile!=null){
ioManager.setInSession(IEngUserProfile.ENG_USER_PROFILE, profile);
ioManager.setInSession("userId", profile.getUserUniqueIdentifier());
ioManager.contextManager.set(IEngUserProfile.ENG_USER_PROFILE, profile);
ioManager.contextManager.set("userId", profile.getUserUniqueIdentifier());
}else {
logger.error("ERROR WHILE GETTING USER PROFILE!!!!!!!!!!!");
}
} else {
logger.debug("Found user profile in session");