Commit 5c9fb183 authored by Predrag Josipovic's avatar Predrag Josipovic
Browse files

[Fixed] KNOWAGE-3479 - Copy Link: direct link does not land into required...

[Fixed] KNOWAGE-3479 - Copy Link: direct link does not land into required document after authentication
parent a4820694
......@@ -17,11 +17,8 @@
*/
package it.eng.spagobi.analiticalmodel.execution.service;
import java.io.IOException;
import java.util.HashMap;
import javax.servlet.ServletException;
import org.apache.log4j.Logger;
import it.eng.spago.base.SourceBeanException;
......@@ -36,8 +33,6 @@ import it.eng.spagobi.commons.dao.DAOFactory;
import it.eng.spagobi.commons.services.AbstractSpagoBIAction;
import it.eng.spagobi.commons.utilities.AuditLogUtilities;
import it.eng.spagobi.commons.utilities.ObjectsAccessVerifier;
import it.eng.spagobi.utilities.exceptions.SpagoBIRuntimeException;
import it.eng.spagobi.utilities.themes.ThemesManager;
/**
*
......@@ -57,24 +52,6 @@ public class ExecuteDocumentAction extends AbstractSpagoBIAction {
UserProfile profile = (UserProfile) this.getUserProfile();
BIObject obj = null;
if (profile == null) {
logger.warn("User is not authenticated - redirect to login");
try {
String currTheme = ThemesManager.getCurrentTheme(getRequestContainer());
// set publisher name
String url = "/themes/" + currTheme + "/jsp/login.jsp";
// getHttpRequest().setAttribute("start_url", url);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
} catch (ServletException e) {
logger.error("Error in redirecting to login page", e);
throw new SpagoBIRuntimeException("Error in redirecting to login page");
} catch (IOException e) {
logger.error("Error in redirecting to login page", e);
throw new SpagoBIRuntimeException("Error in redirecting to login page");
}
}
try {
obj = getRequiredBIObject();
} catch (EMFUserError e) {
......
......@@ -24,7 +24,6 @@ import java.util.Date;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Properties;
......@@ -39,7 +38,6 @@ import it.eng.spago.base.Constants;
import it.eng.spago.base.RequestContainer;
import it.eng.spago.base.SessionContainer;
import it.eng.spago.base.SourceBean;
import it.eng.spago.base.SourceBeanAttribute;
import it.eng.spago.dispatching.module.AbstractHttpModule;
import it.eng.spago.error.EMFErrorHandler;
import it.eng.spago.error.EMFErrorSeverity;
......@@ -57,6 +55,7 @@ import it.eng.spagobi.commons.metadata.SbiExtRoles;
import it.eng.spagobi.commons.utilities.AuditLogUtilities;
import it.eng.spagobi.commons.utilities.GeneralUtilities;
import it.eng.spagobi.commons.utilities.HibernateSessionManager;
import it.eng.spagobi.commons.utilities.ObjectsAccessVerifier;
import it.eng.spagobi.commons.utilities.StringUtilities;
import it.eng.spagobi.commons.utilities.UserUtilities;
import it.eng.spagobi.commons.utilities.messages.MessageBuilder;
......@@ -117,41 +116,12 @@ public class LoginModule extends AbstractHttpModule {
boolean activeSoo = isSSOActive();
// Set BACK URL if present
String backUrl = (String) request.getAttribute(SpagoBIConstants.BACK_URL);
String fromLogin = (String) request.getAttribute("fromLogin");
String docLabel = (String) request.getAttribute(SpagoBIConstants.OBJECT_LABEL);
boolean isPublicDoc = false;
boolean isPublicUser = false;
if (docLabel != null) {
BIObject obj = DAOFactory.getBIObjectDAO().loadBIObjectByLabel(docLabel);
if (obj.isPublicDoc())
isPublicDoc = true;
}
if (backUrl != null && !backUrl.equalsIgnoreCase("") && fromLogin == null) {
String parametersStr = "";
List params = request.getContainedAttributes();
ListIterator it = params.listIterator();
int count = 0;
while (it.hasNext()) {
SourceBeanAttribute par = (SourceBeanAttribute) it.next();
String name = par.getKey();
String val = (String) par.getValue();
if (count == 0) {
parametersStr += "?" + name + "=" + val;
} else {
parametersStr += "&" + name + "=" + val;
}
count++;
}
// append to back url
backUrl += parametersStr;
getHttpRequest().setAttribute(SpagoBIConstants.BACK_URL, backUrl);
isPublicDoc = ObjectsAccessVerifier.isObjectPublic(obj);
}
errorHandler = getErrorHandler();
......@@ -174,20 +144,16 @@ public class LoginModule extends AbstractHttpModule {
logger.debug("User is authenticated");
// fill response
List lstMenu = MenuUtilities.getMenuItems(profile);
if (backUrl == null) {
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
// response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "userhome");
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
servletRequest.getSession().setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
getHttpResponse().sendRedirect(backUrl);
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
return;
} else {
// user must authenticate
......@@ -221,20 +187,16 @@ public class LoginModule extends AbstractHttpModule {
logger.debug("User is authenticated");
// fill response
List lstMenu = MenuUtilities.getMenuItems(profile);
if (backUrl == null) {
// set publisher name
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
// set publisher name
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
servletRequest.getSession().setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
getHttpResponse().sendRedirect(backUrl);
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
return;
}
......@@ -418,22 +380,15 @@ public class LoginModule extends AbstractHttpModule {
// End writing log in the DB
List lstMenu = MenuUtilities.getMenuItems(profile);
if (backUrl == null) {
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
// response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "userhome");
String url = "/themes/" + currTheme + "/jsp/";
if (UserUtilities.isTechnicalUser(profile)) {
url += "adminHome.jsp";
} else {
servletRequest.getSession().setAttribute(IEngUserProfile.ENG_USER_PROFILE, profile);
getHttpResponse().sendRedirect(backUrl);
url += "userHome.jsp";
}
servletRequest.getSession().setAttribute(LIST_MENU, lstMenu);
getHttpRequest().getRequestDispatcher(url).forward(getHttpRequest(), getHttpResponse());
} finally {
// since TenantManager uses a ThreadLocal, we must clean after request processed in each case
TenantManager.unset();
......
......@@ -358,21 +358,36 @@
return;
}
var publicStr = canExec == true ? "/public" : "";
if(host.endsWith("/")){
host = host.substring(0, host.length - 1);
}
var url = host
+ context
+ publicStr
+ adapter
+ "?"
+ "ACTION_NAME=EXECUTE_DOCUMENT_ACTION"
+ "&OBJECT_LABEL="+label
+ "&TOOLBAR_VISIBLE=true"
+ "&ORGANIZATION="+tenant;
var url;
if(canExec == true) {
// If document is public, authentication is not needed
url = host
+ context
+ "/public"
+ adapter
+ "?"
+ "ACTION_NAME=EXECUTE_DOCUMENT_ACTION"
+ "&OBJECT_LABEL="+label
+ "&TOOLBAR_VISIBLE=true"
+ "&ORGANIZATION="+tenant
+ "&NEW_SESSION=true";
} else {
// Document is not public, so user need to be redirected to login page firstly, then execute the document
url = host
+ context
+ adapter
+ "?"
+ "PAGE=LoginPage"
+ "&OBJECT_LABEL="+label
+ "&TOOLBAR_VISIBLE=true"
+ "&NEW_SESSION=true";
}
if(parameters != undefined && parameters != ''){
url += "&PARAMETERS="+parameters;
......@@ -395,7 +410,6 @@
$mdDialog.show({
locals: {publicUrl: urlToSend, embedHTML: embedHTML, isPublic: canExec},
//flex: 80,
templateUrl: sbiModule_config.contextName+"/js/src/angular_1.4/tools/documentexecution/templates/publicExecutionUrl.html",
parent: angular.element(document.body),
clickOutsideToClose:true,
......@@ -404,11 +418,6 @@
fullscreen: true,
controller: publicExecutionUrlControllerFunction
});
// else {
// sbiModule_messaging.showWarningMessage(sbiModule_translate.load("sbi.execution.publicUrlExecutionEnable"), sbiModule_translate.load('sbi.generic.warning'));
// }
},function(response, status, headers, config) {
sbiModule_restServices.errorHandler(response.data,"error while checking if public url can be delivered")
});
......
......@@ -187,25 +187,13 @@
<form class="form-signin" id="formId" name="login" action="<%=contextName%>/servlet/AdapterHTTP?PAGE=LoginPage&NEW_SESSION=TRUE" method="POST" onsubmit="return escapeUserName()">
<input type="hidden" id="isInternalSecurity" name="isInternalSecurity" value="<%=isInternalSecurity %>" />
<input type="hidden" id="<%=roleToCheckLbl%>" name="<%=roleToCheckLbl%>" value="<%=roleToCheckVal%>" />
<%
//manages backUrl after login
String backUrl = (String)request.getAttribute(SpagoBIConstants.BACK_URL);
if (backUrl != null && !backUrl.equals("")) {
String objLabel = (String)request.getAttribute(SpagoBIConstants.OBJECT_LABEL);
backUrl += (backUrl.indexOf("?")<0)?"?":"&";
backUrl += "fromLogin=true";
%>
<input type="hidden" name="<%= SpagoBIConstants.BACK_URL %>" value="<%= backUrl %>" />
<input type="hidden" name="<%= SpagoBIConstants.OBJECT_LABEL %>" value="<%= objLabel %>" />
<input type="hidden" name="fromLogin" value="true" />
<%
}
<%
// propagates parameters (if any) for document execution
if (request.getParameter(ObjectsTreeConstants.OBJECT_LABEL) != null) {
String label = request.getParameter(ObjectsTreeConstants.OBJECT_LABEL);
String subobjectName = request.getParameter(SpagoBIConstants.SUBOBJECT_NAME);
%>
<input type="hidden" name="<%= ObjectsTreeConstants.OBJECT_LABEL %>" value="<%= StringEscapeUtils.escapeHtml(label) %>" />
<input type="hidden" name="<%= SpagoBIConstants.OBJECT_LABEL %>" value="<%= label %>" />
<% if (subobjectName != null && !subobjectName.trim().equals("")) { %>
<input type="hidden" name="<%= SpagoBIConstants.SUBOBJECT_NAME %>" value="<%= StringEscapeUtils.escapeHtml(subobjectName) %>" />
<% } %>
......
......@@ -836,14 +836,14 @@ public class ObjectsAccessVerifier {
Role[] execRoles = funct.getExecRoles();
for (int i = 0; i < execRoles.length && !isPublic; i++) {
Role role = execRoles[i];
if (role.getIsPublic() == true) {
if (role.getIsPublic() != null && role.getIsPublic() == true) {
isPublic = true;
}
}
return isPublic;
}
private static boolean isObjectPublic(BIObject obj) {
public static boolean isObjectPublic(BIObject obj) {
// check if is a public folder
boolean isPublic = false;
try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment