user timeout session management generating a SessionExpiredException in order to show the session checker dialog and redirect to login
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/databases-manager-portlet@100252 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ddf6dc33c4
commit
6a96111918
|
@ -9,6 +9,7 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.Result;
|
|||
import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SamplingResultWithFileFromServlet;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
|
@ -56,7 +57,7 @@ public interface GWTdbManagerService extends RemoteService {
|
|||
|
||||
Boolean removeComputation(String submitQueryUID) throws Exception;
|
||||
|
||||
void refreshDataOnServer(String submitQueryUID);
|
||||
void refreshDataOnServer(String submitQueryUID) throws Exception;
|
||||
|
||||
GeneralOutputFromServlet refreshDataTree(String ElementType,
|
||||
LinkedHashMap<String, String> inputData, FileModel element) throws Exception;
|
||||
|
|
|
@ -34,6 +34,8 @@ import org.gcube.portlets.user.databasesmanager.client.events.interfaces.SubmitQ
|
|||
import org.gcube.portlets.user.databasesmanager.client.resources.Images;
|
||||
import org.gcube.portlets.user.databasesmanager.client.toolbar.GxtToolbarFunctionality;
|
||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style;
|
||||
import com.extjs.gxt.ui.client.Style.LayoutRegion;
|
||||
|
@ -404,6 +406,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC LoadTables");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
// caught.printStackTrace();
|
||||
callback.onFailure(caught);
|
||||
// hide the dialog
|
||||
|
@ -840,6 +848,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
rootLogger
|
||||
.log(Level.SEVERE, "FAILURE RPC submitQuery ");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
// Listener<MessageBoxEvent> l = new
|
||||
// Listener<MessageBoxEvent>() {
|
||||
// public void handleEvent(MessageBoxEvent ce) {
|
||||
|
@ -995,6 +1009,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC loadSubmitQueryResult");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
Listener<MessageBoxEvent> l = new Listener<MessageBoxEvent>() {
|
||||
public void handleEvent(MessageBoxEvent ce) {
|
||||
|
@ -1184,6 +1204,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC refreshDataOnServer");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1277,6 +1303,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC sample");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (caught.getMessage()
|
||||
.contains("Result not available")) {
|
||||
MessageBox.alert("Warning ", "<br/>Message:"
|
||||
|
@ -1415,6 +1448,12 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC smartSample");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
if (caught.getMessage()
|
||||
.contains("The table has 0 rows")) {
|
||||
MessageBox.alert("Warning ", "<br/>Message:"
|
||||
|
@ -1518,6 +1557,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
// Window.alert(caught.getMessage());
|
||||
rootLogger
|
||||
.log(Level.SEVERE, "FAILURE RPC randomSample");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
if (caught.getMessage()
|
||||
.contains("Result not available")) {
|
||||
MessageBox.alert("Warning ", "<br/>Message:"
|
||||
|
@ -1572,6 +1618,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC parseResult");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
@ -1922,6 +1975,13 @@ public class GxtBorderLayoutPanel extends ContentPanel {
|
|||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE,
|
||||
"FAILURE RPC getTableDetails");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ import com.google.gwt.user.client.Event;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.AbstractImagePrototype;
|
||||
import org.gcube.portlets.user.databasesmanager.client.datamodel.GeneralOutputFromServlet;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
|
||||
//class that implements the tree object
|
||||
public class GxtTreePanel extends LayoutContainer {
|
||||
|
@ -481,6 +483,13 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC getResource");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
@ -520,6 +529,13 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC getDBInfo");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
@ -684,6 +700,13 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
public void onFailure(Throwable caught) {
|
||||
// Window.alert(caught.getMessage());
|
||||
rootLogger.log(Level.SEVERE, "FAILURE RPC getDBSchema");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
@ -884,6 +907,12 @@ public class GxtTreePanel extends LayoutContainer {
|
|||
public void onFailure(Throwable caught) {
|
||||
rootLogger.log(Level.SEVERE, "FAILURE refreshDataTree");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
MessageBox.alert("Error ",
|
||||
"<br/>Message:" + caught.getMessage(), null);
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.gcube.portlets.user.databasesmanager.client.events.interfaces.Selecte
|
|||
import org.gcube.portlets.user.databasesmanager.client.form.GxtFormSubmitQuery;
|
||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||
import org.gcube.portlets.user.databasesmanager.client.utils.UIDGenerator;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
|
||||
import com.extjs.gxt.ui.client.Style.ButtonArrowAlign;
|
||||
import com.extjs.gxt.ui.client.Style.ButtonScale;
|
||||
|
@ -341,6 +343,13 @@ public class GxtToolbarFunctionality {
|
|||
rootLogger
|
||||
.log(Level.SEVERE,
|
||||
"FAILURE RPC removeComputation");
|
||||
|
||||
if(caught instanceof SessionExpiredException){
|
||||
rootLogger.log(Level.INFO, "Session expired");
|
||||
CheckSession.showLogoutDialog();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ import org.gcube.portlets.user.databasesmanager.client.datamodel.Row;
|
|||
import org.gcube.portlets.user.databasesmanager.client.datamodel.SubmitQueryResultWithFileFromServlet;
|
||||
import org.gcube.portlets.user.databasesmanager.client.utils.ConstantsPortlet;
|
||||
import org.gcube.portlets.user.databasesmanager.server.util.SessionUtil;
|
||||
import org.gcube.portlets.user.databasesmanager.shared.SessionExpiredException;
|
||||
|
||||
import com.extjs.gxt.ui.client.data.BasePagingLoadResult;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadConfig;
|
||||
import com.extjs.gxt.ui.client.data.PagingLoadResult;
|
||||
|
@ -264,6 +266,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// to get resources from IS
|
||||
@Override
|
||||
public List<FileModel> getResource() throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// initialize variables with application startup
|
||||
initVariables();
|
||||
|
@ -354,6 +360,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public LinkedHashMap<String, FileModel> getDBInfo(String resourceName)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data output
|
||||
|
@ -452,6 +462,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public List<FileModel> getDBSchema(LinkedHashMap<String, String> dataInput)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
|
@ -744,6 +758,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
//
|
||||
// previousSchema = currentSchema;
|
||||
// session.setAttribute("previousSchema", previousSchema);
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
List<Result> result = new ArrayList<>();
|
||||
|
||||
|
@ -814,6 +832,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
LinkedHashMap<String, String> dataDB, String query,
|
||||
boolean valueReadOnlyQuery, boolean smartCorrectionQuery,
|
||||
String language, String UID) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
logger.info("dbmanager-> Dialect used for smart correction: "
|
||||
+ language);
|
||||
|
@ -968,6 +990,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public SamplingResultWithFileFromServlet sample(
|
||||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// output sample result
|
||||
|
@ -1071,6 +1097,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public SamplingResultWithFileFromServlet smartSample(
|
||||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// output sample result
|
||||
|
@ -1174,6 +1204,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public SamplingResultWithFileFromServlet randomSample(
|
||||
LinkedHashMap<String, String> dataInput, String elementType)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
|
@ -1277,6 +1311,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public LinkedHashMap<String, FileModel> getTableDetails(
|
||||
LinkedHashMap<String, String> dataInput) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// data input
|
||||
List<Parameter> inputParameters = new ArrayList<Parameter>();
|
||||
// data ouptut
|
||||
|
@ -1343,6 +1382,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// parse result for Submit query
|
||||
public PagingLoadResult<Row> loadSubmitResult(PagingLoadConfig config,
|
||||
List<String> listAttributes, String UID) throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// System.out.println("Server - loadSubmitResultMethod");
|
||||
// data parsed
|
||||
List<Row> data = new ArrayList<Row>();
|
||||
|
@ -1420,6 +1464,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
@Override
|
||||
public List<Row> parseCVSString(List<Result> result, List<String> attrNames)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
List<Row> rows = new ArrayList<Row>();
|
||||
|
||||
|
@ -1915,6 +1963,11 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
// remove the computation
|
||||
public Boolean removeComputation(String uidSubmitQuery) throws Exception {
|
||||
// System.out.println("server UID: " + uidSubmitQuery);
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
String computationId = null;
|
||||
|
||||
if ((uidSubmitQuery != null) && (!(uidSubmitQuery.equals("")))) {
|
||||
|
@ -1960,7 +2013,12 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return (new Boolean(true));
|
||||
}
|
||||
|
||||
public void refreshDataOnServer(String submitQueryUID) {
|
||||
public void refreshDataOnServer(String submitQueryUID) throws Exception{
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
if ((submitQueryUID != null) && (!submitQueryUID.equals(""))) {
|
||||
removeResultParsed(submitQueryUID);
|
||||
removeResult(submitQueryUID);
|
||||
|
@ -1981,6 +2039,10 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
public GeneralOutputFromServlet refreshDataTree(String ElementType,
|
||||
LinkedHashMap<String, String> inputData, FileModel element)
|
||||
throws Exception {
|
||||
|
||||
//session check
|
||||
if(isSessionExpired())
|
||||
throw new SessionExpiredException();
|
||||
|
||||
// // call the method related to the element selected
|
||||
//
|
||||
|
@ -2134,4 +2196,9 @@ public class GWTdbManagerServiceImpl extends RemoteServiceServlet implements
|
|||
return fileName;
|
||||
|
||||
}
|
||||
|
||||
//to check if the session is expired
|
||||
private boolean isSessionExpired() throws Exception {
|
||||
return SessionUtil.isSessionExpired(this.getThreadLocalRequest().getSession());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.gcube.data.analysis.statisticalmanager.proxies.StatisticalManagerData
|
|||
import org.gcube.data.analysis.statisticalmanager.proxies.StatisticalManagerFactory;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
|
||||
|
||||
/**
|
||||
* @author "Angela Italiano angela.italiano@isti.cnr.it"
|
||||
*
|
||||
|
@ -19,6 +20,9 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|||
public class SessionUtil {
|
||||
|
||||
protected static Logger logger = Logger.getLogger(SessionUtil.class);
|
||||
public static final String TEST_USER = "test.user";
|
||||
public static final String USER = "database.manager";
|
||||
|
||||
|
||||
public static ASLSession getAslSession(HttpSession httpSession) {
|
||||
String sessionID = httpSession.getId();
|
||||
|
@ -28,7 +32,7 @@ public class SessionUtil {
|
|||
if (user == null) {
|
||||
|
||||
// user = "loredana.liccardo";
|
||||
user = "database.manager";
|
||||
user = USER;
|
||||
httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, user);
|
||||
ScopeProvider.instance.set("/gcube/devsec/devVRE");
|
||||
ASLSession session = SessionManager.getInstance().getASLSession(
|
||||
|
@ -46,6 +50,26 @@ public class SessionUtil {
|
|||
|
||||
return session;
|
||||
}
|
||||
|
||||
public static boolean isSessionExpired(HttpSession httpSession) throws Exception {
|
||||
logger.info("session validating...");
|
||||
//READING USERNAME FROM ASL SESSION
|
||||
String userUsername = getAslSession(httpSession).getUsername();
|
||||
|
||||
if(userUsername.compareToIgnoreCase(USER)==0){
|
||||
logger.error("session is expired! username is: "+SessionUtil.USER);
|
||||
return true; //is USER, session is expired
|
||||
}
|
||||
if(userUsername.compareToIgnoreCase(TEST_USER)==0){
|
||||
logger.error("session is expired! username is: "+SessionUtil.TEST_USER);
|
||||
return true; //is TEST_USER, session is expired
|
||||
}
|
||||
|
||||
logger.info("session is valid! current username is: "+userUsername);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static StatisticalManagerFactory getFactory(HttpSession httpSession) {
|
||||
ASLSession session = getAslSession(httpSession);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package org.gcube.portlets.user.databasesmanager.shared;
|
||||
|
||||
public class SessionExpiredException extends Exception{
|
||||
|
||||
public SessionExpiredException() {
|
||||
super("Session expired");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue