diff --git a/pom.xml b/pom.xml index 0219f09..bd144c3 100644 --- a/pom.xml +++ b/pom.xml @@ -115,14 +115,24 @@ compile + + + + + - org.gcube.portal - custom-portal-handler + org.gcube.common.portal + portal-manager + provided - org.gcube.applicationsupportlayer - aslcore + org.gcube.dvos + usermanagement-core + provided + org.gcube.applicationsupportlayer accesslogger @@ -149,11 +159,7 @@ slf4j-log4j12 provided - - org.gcube.dvos - usermanagement-core - - + junit @@ -176,7 +182,7 @@ com.liferay.portal portal-service - provided + provided @@ -200,13 +206,15 @@ ${gwtVersion} + compile - test + diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManager.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManager.java index de41559..7de9bce 100644 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManager.java +++ b/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManager.java @@ -1,12 +1,8 @@ package org.gcube.portlets.admin.authportletmanager.client; -import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; - import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; -import com.google.gwt.user.client.Window.Location; -import com.google.gwt.user.client.rpc.AsyncCallback; /** * @@ -26,31 +22,13 @@ public class AuthManager implements EntryPoint { GWT.log("AuthManager - Start Portlet"); Scheduler.get().scheduleDeferred(new ScheduledCommand() { public void execute() { - loadScope(); + loadController(); } }); } - private void loadScope() { - ClientScopeHelper.getService().setScope(Location.getHref(), - new AsyncCallback() { - @Override - public void onSuccess(Boolean result) { - GWT.log("AuthManager - Scope Location set!"); - if (result) { - loadController(); - } else { - GWT.log("AuthManager - Attention ClientScopeHelper has returned a false value!"); - } - } - @Override - public void onFailure(Throwable caught) { - GWT.log("AuthManager - Error setting scope: " - + caught.getLocalizedMessage()); - caught.printStackTrace(); - } - }); - } + + protected void loadController() { rootPanel = new AuthManagerController(); diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManagerController.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManagerController.java index 38771a5..e022b2b 100644 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManagerController.java +++ b/src/main/java/org/gcube/portlets/admin/authportletmanager/client/AuthManagerController.java @@ -34,7 +34,6 @@ import org.gcube.portlets.admin.authportletmanager.shared.ConstantsSharing; import org.gcube.portlets.admin.authportletmanager.shared.PolicyAuth; import org.gcube.portlets.admin.authportletmanager.shared.Quote; import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ExpiredSessionServiceException; -import org.gcube.portlets.widgets.sessionchecker.client.CheckSession; import com.github.gwtbootstrap.client.ui.Container; import com.github.gwtbootstrap.client.ui.Tab; @@ -45,7 +44,6 @@ import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.shared.EventBus; import com.google.gwt.event.shared.SimpleEventBus; import com.google.gwt.user.client.Cookies; -import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.DockPanel; import com.google.gwt.user.client.ui.RootPanel; @@ -106,15 +104,6 @@ public class AuthManagerController { bindToEvents(); } - @SuppressWarnings("unused") - private void checkSession() { - // if you do not need to something when the session expire - CheckSession.getInstance().startPolling(); - } - - private void sessionExpiredShow() { - CheckSession.showLogoutDialog(); - } /** * @return the eventBus @@ -237,7 +226,7 @@ public class AuthManagerController { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -269,7 +258,7 @@ public class AuthManagerController { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); @@ -302,7 +291,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); @@ -332,7 +321,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -360,7 +349,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -395,7 +384,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -433,18 +422,7 @@ public class AuthManagerController { } - private void sessionExpiredShowDelayed() { - Timer timeoutTimer = new Timer() { - public void run() { - sessionExpiredShow(); - - } - }; - int TIMEOUT = 3; // 3 second timeout - - timeoutTimer.schedule(TIMEOUT * 1000); // timeout is in milliseconds - - } + protected void changeLanguage(String localeName) { Date now = new Date(); @@ -585,7 +563,7 @@ public class AuthManagerController { // TODO Auto-generated method stub if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -615,7 +593,7 @@ public class AuthManagerController { // TODO Auto-generated method stub if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -655,7 +633,7 @@ public class AuthManagerController { // TODO Auto-generated method stub if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); @@ -695,7 +673,7 @@ public class AuthManagerController { // TODO Auto-generated method stub if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -727,7 +705,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -758,7 +736,7 @@ public class AuthManagerController { public void onFailure(Throwable caught) { if (caught instanceof ExpiredSessionServiceException) { GWT.log("AuthManager - Alert Expired Session"); - sessionExpiredShowDelayed(); + //sessionExpiredShowDelayed(); } else { dialogLoader.stopLoader(); dialogError.showError(caught.getLocalizedMessage()); @@ -780,24 +758,4 @@ public class AuthManagerController { } - - - - - - - - - - - @SuppressWarnings("unused") - private void asyncCodeLoadingFailed(Throwable reason) { - //Log.error("Async code loading failed", reason); - /* - eventBus.fireEvent(new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); - */ - } - - } diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/AuthServiceImpl.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/AuthServiceImpl.java index 08de643..2a6e9ba 100644 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/AuthServiceImpl.java +++ b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/AuthServiceImpl.java @@ -14,9 +14,9 @@ import java.util.List; import java.util.Map; import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; -import org.gcube.application.framework.core.session.ASLSession; import org.gcube.common.authorization.client.exceptions.ObjectNotFound; import org.gcube.common.authorization.library.policies.Action; import org.gcube.common.authorization.library.policies.Policy; @@ -29,6 +29,7 @@ import org.gcube.common.authorization.library.policies.User2ServicePolicy; import org.gcube.common.authorization.library.policies.Users; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.provider.UserInfo; +import org.gcube.common.portal.PortalContext; import org.gcube.common.resources.gcore.GCoreEndpoint; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.portlets.admin.authportletmanager.client.rpc.AuthManagerService; @@ -66,9 +67,13 @@ import com.liferay.portal.kernel.log.LogFactoryUtil; * href="mailto:alessandro.pieve@isti.cnr.it">alessandro.pieve@isti.cnr.it * */ -@SuppressWarnings({ "serial", "deprecation" }) + public class AuthServiceImpl extends RemoteServiceServlet implements AuthManagerService { + /** + * + */ + private static final long serialVersionUID = -5302822657119071306L; private static final Log logger = LogFactoryUtil.getLog(AuthServiceImpl.class); /** @@ -90,33 +95,30 @@ implements AuthManagerService { @Override public ArrayList loadListPolicy(String context) throws ServiceException { try { - - HttpSession session = this.getThreadLocalRequest().getSession(); ArrayList policyList =new ArrayList(); - ASLSession aslSession = SessionUtil.getASLSession(session); - String username = aslSession.getUsername(); - //String scope=aslSession.getScope(); - //String token =aslSession.getSecurityToken(); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + String username = pContext.getCurrentUser(httpServletRequest).getUsername(); + if (context==null){ logger.debug("loadListPolicy found context:"+null); - context=aslSession.getScope(); + context = pContext.getCurrentScope(httpServletRequest); } String token; try{ - token= authorizationService().resolveTokenByUserAndContext(username, context); + token= authorizationService().resolveTokenByUserAndContext(username, context); }catch (ObjectNotFound e){ token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); } - if (ConstantsSharing.DEBUG_MODE) { token=ConstantsSharing.DEBUG_TOKEN; context="/gcube/devNext"; logger.debug("Debug load list policy in scope:"+context); } - aslSession.setSecurityToken(token); - aslSession.setScope(context); - logger.debug("load list policy in scope:"+context+"-token:"+token+"-username:"+username); + logger.debug("load list policy in scope:"+context+"-token:"+token+"-username:"+username); + ScopeProvider.instance.set(context); SecurityTokenProvider.instance.set(token); + List policies = authorizationService().getPolicies(context); if (policies!=null){ logger.debug("Load List Policy Find:"+policies.size()); @@ -196,26 +198,25 @@ implements AuthManagerService { @Override public ArrayList loadListCaller(String context) throws ServiceException { try { - HttpSession session = this.getThreadLocalRequest().getSession(); - @SuppressWarnings("unused") - ASLSession aslSession = SessionUtil.getASLSession(session); ArrayList callers =new ArrayList(); - String username = aslSession.getUsername(); - //String scope=aslSession.getScope(); - //String token =aslSession.getSecurityToken(); - if (context==null) - context=aslSession.getScope(); - + + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + String username = pContext.getCurrentUser(httpServletRequest).getUsername(); + if (context==null){ + context = pContext.getCurrentScope(httpServletRequest); + } + String token; try{ - token= authorizationService().resolveTokenByUserAndContext(username, context); + token= authorizationService().resolveTokenByUserAndContext(username, context); }catch (ObjectNotFound e){ token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); } - //String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); if (ConstantsSharing.DEBUG_MODE) { token=ConstantsSharing.DEBUG_TOKEN; } + ScopeProvider.instance.set(context); SecurityTokenProvider.instance.set(token); if (ConstantsSharing.MOCK_UP) { logger.debug("List Caller on debug mode"); @@ -272,12 +273,12 @@ implements AuthManagerService { public Map> loadListService(String context) throws ServiceException { try { logger.debug("loadListService init with context:"+context); - HttpSession session = this.getThreadLocalRequest().getSession(); - @SuppressWarnings("unused") - ASLSession aslSession = SessionUtil.getASLSession(session); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); if (context==null){ - context=aslSession.getScope(); + context = pContext.getCurrentScope(httpServletRequest); logger.debug("Context void,loadListService init with context:"+context); + } Map> services =new HashMap>(); if (ConstantsSharing.DEBUG_MODE) { @@ -290,17 +291,16 @@ implements AuthManagerService { services.put("DataAnalysis", Arrays.asList("StatisticalManager")); } else{ - //Get List service - String username = aslSession.getUsername(); + String username = pContext.getCurrentUser(httpServletRequest).getUsername(); String token; try{ - token= authorizationService().resolveTokenByUserAndContext(username, context); + token= authorizationService().resolveTokenByUserAndContext(username, context); }catch (ObjectNotFound e){ token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); } //String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); SecurityTokenProvider.instance.set(token); - + ScopeProvider.instance.set(context); SimpleQuery query = queryFor(GCoreEndpoint.class); query.setResult("{$resource/Profile/ServiceClass/text()}" + "{$resource/Profile/ServiceName/text()}"); @@ -331,22 +331,10 @@ implements AuthManagerService { @Override public ArrayList loadListAccess() throws ServiceException { try { - HttpSession session = this.getThreadLocalRequest().getSession(); - @SuppressWarnings("unused") - ASLSession aslSession = SessionUtil.getASLSession(session); - - if (ConstantsSharing.DEBUG_MODE) { - String token=ConstantsSharing.DEBUG_TOKEN; - SecurityTokenProvider.instance.set(token); - } ArrayList access =new ArrayList(); for( Access accessValue : Access.values() ) access.add(access.toString()); return access; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("loadListAccess error: " + e.getLocalizedMessage(), e); e.printStackTrace(); @@ -355,18 +343,18 @@ implements AuthManagerService { } - - + + public ArrayList loadRetrieveListContexts() throws ServiceException { try { - - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); - String token =aslSession.getSecurityToken(); - SecurityTokenProvider.instance.set(token); - ArrayList toReturn = new ArrayList(); - String currentContext = ScopeProvider.instance.get(); - + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + String token = pContext.getCurrentUserToken(httpServletRequest); + + SecurityTokenProvider.instance.set(token); + ArrayList toReturn = new ArrayList(); + String currentContext = ScopeProvider.instance.get(); + GroupManager gm = new LiferayGroupManager(); long currentGroupId = gm.getGroupIdFromInfrastructureScope(currentContext); GCubeGroup currentGroup = gm.getGroup(currentGroupId); @@ -385,7 +373,7 @@ implements AuthManagerService { List children = currentGroup.getChildren(); for (GCubeGroup gCubeGroup : children) { toReturn.add(gm.getInfrastructureScope(gCubeGroup.getGroupId())); - + // get the vo children List childrenVO = gCubeGroup.getChildren(); for (GCubeGroup voChildren : childrenVO) { @@ -398,18 +386,14 @@ implements AuthManagerService { // revert Collections.reverse(toReturn); return toReturn; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("loadRetrieveListContexts error: " + e.getLocalizedMessage(), e); e.printStackTrace(); throw new ServiceException(e.getLocalizedMessage()); } - + } - + /** * Insert a new List Policy * @return @@ -418,28 +402,28 @@ implements AuthManagerService { @Override public void addPolicies(String context,List policiesAuth) throws ServiceException { try { - //Long identifier; - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); - if (context==null) - context=aslSession.getScope(); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + if (context==null){ + //context=aslSession.getScope(); + context = pContext.getCurrentScope(httpServletRequest); + logger.debug("Context void,addPolicies init with context:"+context); + + } List policies = new ArrayList(); - //String token =aslSession.getSecurityToken(); - String username = aslSession.getUsername(); + String username = pContext.getCurrentUser(httpServletRequest).getUsername(); String token; try{ - token= authorizationService().resolveTokenByUserAndContext(username, context); + token= authorizationService().resolveTokenByUserAndContext(username, context); }catch (ObjectNotFound e){ token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); } - //String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); - - if (ConstantsSharing.DEBUG_MODE) { + if (ConstantsSharing.DEBUG_MODE) { token=ConstantsSharing.DEBUG_TOKEN; } + ScopeProvider.instance.set(context); SecurityTokenProvider.instance.set(token); - //String scope=SessionUtil.getASLSession(session).getScope(); for (PolicyAuth policy: policiesAuth){ ServiceAccess service=new ServiceAccess(policy.getService().getServiceName(), policy.getService().getServiceClass(), policy.getService().getServiceId()); Action access =Action.valueOf(policy.getAccessString()); @@ -505,31 +489,29 @@ implements AuthManagerService { @Override public void updatePolicy(String context,PolicyAuth policy) throws ServiceException{ try { - - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); - if (context==null) - context=aslSession.getScope(); - String username = aslSession.getUsername(); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + if (context==null){ + //context=aslSession.getScope(); + context = pContext.getCurrentScope(httpServletRequest); + logger.debug("Context void,addPolicies init with context:"+context); + } + String username = pContext.getCurrentUser(httpServletRequest).getUsername(); String token; try{ - token= authorizationService().resolveTokenByUserAndContext(username, context); + token= authorizationService().resolveTokenByUserAndContext(username, context); }catch (ObjectNotFound e){ token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); } - //String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList()), context); - - - //String token =aslSession.getSecurityToken(); if (ConstantsSharing.DEBUG_MODE) { token=ConstantsSharing.DEBUG_TOKEN; } SecurityTokenProvider.instance.set(token); + ScopeProvider.instance.set(context); //remove old policy authorizationService().removePolicies(policy.getIdpolicy()); //add a new policy List policies = new ArrayList(); - //String scope=SessionUtil.getASLSession(session).getScope(); ServiceAccess service=new ServiceAccess(policy.getService().getServiceName(), policy.getService().getServiceClass(), policy.getService().getServiceId()); logger.info("updatePolicy -policy.getCallerAsString()"+policy.getCallerAsString()); Action access =Action.valueOf(policy.getAccessString()); @@ -552,13 +534,18 @@ implements AuthManagerService { @Override public List deletePolicies(List identifiers)throws ServiceException { try { - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + ArrayList policy =new ArrayList(); - String token =aslSession.getSecurityToken(); + String token = pContext.getCurrentUserToken(httpServletRequest); + if (ConstantsSharing.DEBUG_MODE) { token=ConstantsSharing.DEBUG_TOKEN; } + String context = pContext.getCurrentScope(httpServletRequest); + ScopeProvider.instance.set(context); + SecurityTokenProvider.instance.set(token); for (Long identifier:identifiers){ logger.info("Remove policy idpolicy "+identifier); @@ -584,8 +571,9 @@ implements AuthManagerService { @Override public ArrayList loadListQuota() throws ServiceException { try { - HttpSession session = this.getThreadLocalRequest().getSession(); - SessionUtil.getASLSession(session); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); + ArrayList quote =new ArrayList(); if (ConstantsSharing.MOCK_UP) { logger.info("loadListQuota"); @@ -601,10 +589,6 @@ implements AuthManagerService { } } return quote; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("loadListQuota error: " + e.getLocalizedMessage(), e); e.printStackTrace(); @@ -616,9 +600,9 @@ implements AuthManagerService { @Override public List deleteQuote(List identifiers)throws ServiceException { try { - - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); + + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); if (ConstantsSharing.MOCK_UP) { for (Long identifier:identifiers){ logger.info("Remove quote idquote "+identifier); @@ -633,10 +617,6 @@ implements AuthManagerService { } return identifiers; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("deleteQuote error: " + e.getLocalizedMessage(), e); e.printStackTrace(); @@ -648,8 +628,8 @@ implements AuthManagerService { public List addQuote(List quote) throws ServiceException { try { Long identifier; - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); if (ConstantsSharing.MOCK_UP) { for (Quote quota: quote){ identifier =(long)(Math.random()*1000000000); @@ -673,10 +653,6 @@ implements AuthManagerService { } } return quote; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("addQuote error: " + e.getLocalizedMessage(), e); e.printStackTrace(); @@ -691,10 +667,8 @@ implements AuthManagerService { @Override public Quote updateQuote(Quote quote) throws ServiceException{ try { - - HttpSession session = this.getThreadLocalRequest().getSession(); - ASLSession aslSession = SessionUtil.getASLSession(session); - + HttpServletRequest httpServletRequest=this.getThreadLocalRequest(); + PortalContext pContext = PortalContext.getConfiguration(); if (ConstantsSharing.MOCK_UP) { //TableUtils.SERVICES. TableUtils.SERVICESQUOTE.remove(quote.getIdQuote()); @@ -716,10 +690,6 @@ implements AuthManagerService { } return quote; - } catch (ServiceException e) { - logger.error(e.getLocalizedMessage()); - e.printStackTrace(); - throw e; } catch (Throwable e) { logger.error("updateQuote error: " + e.getLocalizedMessage(), e); e.printStackTrace(); diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/ExpiredSessionServiceException.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/ExpiredSessionServiceException.java deleted file mode 100644 index f215b46..0000000 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/ExpiredSessionServiceException.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.gcube.portlets.admin.authportletmanager.server; - -public class ExpiredSessionServiceException extends Exception { - -} diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/SessionUtil.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/SessionUtil.java deleted file mode 100644 index 92efcff..0000000 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/SessionUtil.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - */ -package org.gcube.portlets.admin.authportletmanager.server; - -import javax.servlet.http.HttpSession; - -import org.gcube.application.framework.core.session.ASLSession; -import org.gcube.application.framework.core.session.SessionManager; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; -import org.gcube.portlets.admin.authportletmanager.shared.ConstantsSharing; -import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ExpiredSessionServiceException; -import org.gcube.portlets.admin.authportletmanager.shared.exceptions.ServiceException; - -import com.liferay.portal.kernel.log.Log; -import com.liferay.portal.kernel.log.LogFactoryUtil; - - -/** - * - * @author "Alessandro Pieve " alessandro.pieve@isti.cnr.it - * - */ -public class SessionUtil { - - private static final Log logger = LogFactoryUtil.getLog(AuthServiceImpl.class); - - public static ASLSession getASLSession(HttpSession httpSession) - throws ServiceException { - String username = (String) httpSession - .getAttribute(ScopeHelper.USERNAME_ATTRIBUTE); - ASLSession aslSession; - if (username == null) { - if (ConstantsSharing.DEBUG_MODE) { - logger.info("no user found in session, use test user"); - username = ConstantsSharing.DEFAULT_USER; - String scope = ConstantsSharing.DEFAULT_SCOPE; - httpSession.setAttribute(ScopeHelper.USERNAME_ATTRIBUTE, - username); - aslSession = SessionManager.getInstance().getASLSession( - httpSession.getId(), username); - aslSession.setScope(scope); - } else { - logger.info("no user found in session!"); - throw new ExpiredSessionServiceException("Session Expired!"); - - } - } else { - aslSession = SessionManager.getInstance().getASLSession( - httpSession.getId(), username); - - } - - logger.info("SessionUtil: aslSession " + aslSession.getUsername() + " " - + aslSession.getScope()); - - return aslSession; - } -} diff --git a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/portlet/AccountingManagerPortlet.java b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/portlet/AccountingManagerPortlet.java index 73e93e0..c12ecd0 100644 --- a/src/main/java/org/gcube/portlets/admin/authportletmanager/server/portlet/AccountingManagerPortlet.java +++ b/src/main/java/org/gcube/portlets/admin/authportletmanager/server/portlet/AccountingManagerPortlet.java @@ -11,8 +11,6 @@ import javax.portlet.PortletRequestDispatcher; import javax.portlet.RenderRequest; import javax.portlet.RenderResponse; -import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; - /** * * @author "Alessandro Pieve " jUnitHostImpl com.google.gwt.junit.server.JUnitHostImpl - - checkServlet - org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl - - - scopeService - org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl - authService org.gcube.portlets.admin.authportletmanager.server.AuthServiceImpl @@ -20,14 +12,6 @@ jUnitHostImpl /authman/junithost/* - - checkServlet - /authman/checksession - - - scopeService - /authman/scopeService - authService /authman/authm