Alessandro Pieve 2016-11-16 13:50:37 +00:00
parent d6f4bf8aec
commit 32c7ea5ac6
9 changed files with 129 additions and 304 deletions

30
pom.xml
View File

@ -115,14 +115,24 @@
<!-- <version>[1.0.2-SNAPSHOT,2.0.0-SNAPSHOT)</version> -->
<scope>compile</scope>
</dependency>
<!-- 1.1 remove aslcore -->
<!-- <dependency> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId> </dependency> <dependency> <groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId> </dependency> -->
<!-- asl core replace with -->
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<!--end asl core replace with -->
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>accesslogger</artifactId>
@ -149,11 +159,7 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<!-- <version>2.0.0-SNAPSHOT</version> -->
</dependency>
<!-- JUnit TEST -->
<dependency>
<groupId>junit</groupId>
@ -176,7 +182,7 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<scope>provided</scope>
<scope>provided</scope>
</dependency>
</dependencies>
@ -200,13 +206,15 @@
<version>${gwtVersion}</version>
<executions>
<execution>
<!--
<configuration>
<extraJvmArgs>-Xmx1024M -Xss1024k -Dgwt.compiler.localWorkers=1</extraJvmArgs>
<superDevMode>false</superDevMode>
</configuration>
-->
<goals>
<goal>compile</goal>
<goal>test</goal>
<!-- <goal>test</goal> -->
</goals>
</execution>
</executions>

View File

@ -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<Boolean>() {
@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();

View File

@ -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));
*/
}
}

View File

@ -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</a>
*
*/
@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<PolicyAuth> loadListPolicy(String context) throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ArrayList<PolicyAuth> policyList =new ArrayList<PolicyAuth>();
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<String>()), 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<Policy> policies = authorizationService().getPolicies(context);
if (policies!=null){
logger.debug("Load List Policy Find:"+policies.size());
@ -196,26 +198,25 @@ implements AuthManagerService {
@Override
public ArrayList<Caller> loadListCaller(String context) throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
@SuppressWarnings("unused")
ASLSession aslSession = SessionUtil.getASLSession(session);
ArrayList<Caller> callers =new ArrayList<Caller>();
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<String>()), context);
}
//String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), 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<String, List<String>> 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<String, List<String>> services =new HashMap<String, List<String>>();
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<String>()), context);
}
//String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), context);
SecurityTokenProvider.instance.set(token);
ScopeProvider.instance.set(context);
SimpleQuery query = queryFor(GCoreEndpoint.class);
query.setResult("<Service><ServiceClass>{$resource/Profile/ServiceClass/text()}</ServiceClass>" +
"<ServiceName>{$resource/Profile/ServiceName/text()}</ServiceName></Service>");
@ -331,22 +331,10 @@ implements AuthManagerService {
@Override
public ArrayList<String> 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<String> access =new ArrayList<String>();
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<String> loadRetrieveListContexts() throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
String token =aslSession.getSecurityToken();
SecurityTokenProvider.instance.set(token);
ArrayList<String> toReturn = new ArrayList<String>();
String currentContext = ScopeProvider.instance.get();
HttpServletRequest httpServletRequest=this.getThreadLocalRequest();
PortalContext pContext = PortalContext.getConfiguration();
String token = pContext.getCurrentUserToken(httpServletRequest);
SecurityTokenProvider.instance.set(token);
ArrayList<String> toReturn = new ArrayList<String>();
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<GCubeGroup> children = currentGroup.getChildren();
for (GCubeGroup gCubeGroup : children) {
toReturn.add(gm.getInfrastructureScope(gCubeGroup.getGroupId()));
// get the vo children
List<GCubeGroup> 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<PolicyAuth> 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<Policy> policies = new ArrayList<Policy>();
//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<String>()), context);
}
//String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), 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<String>()), context);
}
//String token = authorizationService().generateUserToken(new UserInfo(username, new ArrayList<String>()), 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<Policy> policies = new ArrayList<Policy>();
//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<Long> deletePolicies(List<Long> identifiers)throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
ASLSession aslSession = SessionUtil.getASLSession(session);
HttpServletRequest httpServletRequest=this.getThreadLocalRequest();
PortalContext pContext = PortalContext.getConfiguration();
ArrayList<PolicyAuth> policy =new ArrayList<PolicyAuth>();
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<Quote> loadListQuota() throws ServiceException {
try {
HttpSession session = this.getThreadLocalRequest().getSession();
SessionUtil.getASLSession(session);
HttpServletRequest httpServletRequest=this.getThreadLocalRequest();
PortalContext pContext = PortalContext.getConfiguration();
ArrayList<Quote> quote =new ArrayList<Quote>();
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<Long> deleteQuote(List<Long> 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<Quote> addQuote(List<Quote> 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();

View File

@ -1,5 +0,0 @@
package org.gcube.portlets.admin.authportletmanager.server;
public class ExpiredSessionServiceException extends Exception {
}

View File

@ -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 " <a
* href="mailto:alessandro.pieve@isti.cnr.it">alessandro.pieve@isti.cnr.it</a>
*
*/
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;
}
}

View File

@ -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 " <a
@ -37,9 +35,10 @@ public class AccountingManagerPortlet extends GenericPortlet {
* @throws IOException .
* @throws PortletException .
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
ScopeHelper.setContext(request);
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
rd.include(request,response);
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(VIEW_JSP);
dispatcher.include(request, response);
}
}

View File

@ -11,7 +11,6 @@ import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.admin.authportletmanager.server.AuthServiceImpl;
import com.liferay.portal.kernel.log.Log;
@ -41,15 +40,9 @@ public class AuthManagerPortlet extends GenericPortlet {
* @throws IOException .
* @throws PortletException .
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
logger.trace("AuthPortletManager loading from JSP: "+VIEW_JSP);
logger.trace("setting context using ScopeHelper");
ScopeHelper.setContext(request);
logger.trace("passing to the render");
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(VIEW_JSP);
rd.include(request,response);
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher(VIEW_JSP);
dispatcher.include(request, response);
}
}

View File

@ -4,14 +4,6 @@
<servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>checkServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.sessionchecker.server.SessionCheckerServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>scopeService</servlet-name>
<servlet-class>org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>authService</servlet-name>
<servlet-class>org.gcube.portlets.admin.authportletmanager.server.AuthServiceImpl</servlet-class>
@ -20,14 +12,6 @@
<servlet-name>jUnitHostImpl</servlet-name>
<url-pattern>/authman/junithost/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>checkServlet</servlet-name>
<url-pattern>/authman/checksession</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>scopeService</servlet-name>
<url-pattern>/authman/scopeService</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>authService</servlet-name>
<url-pattern>/authman/authm</url-pattern>