git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/threadlocal-vars-cleaner@134209 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
dad4c8beb0
commit
7dca141d2f
|
@ -30,7 +30,7 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
public class SmartGearsPortalValve extends ValveBase {
|
||||
private static final Logger _log = LoggerFactory.getLogger(SmartGearsPortalValve.class);
|
||||
private final static String DEFAULT_ROLE = "OrganizationMember";
|
||||
|
||||
private final static String LIFERAY_POLLER_CONTEXT = "poller/receive";
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -41,19 +41,20 @@ public class SmartGearsPortalValve extends ValveBase {
|
|||
//_log.trace("SmartGearsPortalValve SecurityTokenProvider and AuthorizationProvider reset OK");
|
||||
if (req instanceof HttpServletRequest) {
|
||||
HttpServletRequest request = (HttpServletRequest) req;
|
||||
PortalContext context = PortalContext.getConfiguration();
|
||||
|
||||
String scope = context.getCurrentScope(request);
|
||||
String username = getCurrentUsername(request);
|
||||
if (scope != null && username != null) {
|
||||
try {
|
||||
String userToken = getAuthorizationToken(username, scope);
|
||||
SecurityTokenProvider.instance.set(userToken);
|
||||
} catch (Exception e) {
|
||||
_log.error("Something went wrong in generating token for " + username + " in scope " + scope);
|
||||
e.printStackTrace();
|
||||
if (!req.getRequestURL().toString().endsWith(LIFERAY_POLLER_CONTEXT)) { //avoid calling gCube auth service for liferay internal poller
|
||||
PortalContext context = PortalContext.getConfiguration();
|
||||
String scope = context.getCurrentScope(request);
|
||||
String username = getCurrentUsername(request);
|
||||
if (scope != null && username != null) {
|
||||
try {
|
||||
String userToken = getAuthorizationToken(username, scope);
|
||||
SecurityTokenProvider.instance.set(userToken);
|
||||
} catch (Exception e) {
|
||||
_log.error("Something went wrong in generating token for " + username + " in scope " + scope);
|
||||
e.printStackTrace();
|
||||
}
|
||||
//_log.trace("Security token set OK for " + username + " in scope " + scope);
|
||||
}
|
||||
//_log.trace("Security token set OK for " + username + " in scope " + scope);
|
||||
}
|
||||
}
|
||||
getNext().invoke(req, resp);
|
||||
|
@ -72,7 +73,7 @@ public class SmartGearsPortalValve extends ValveBase {
|
|||
String token = authorizationService().generateUserToken(new UserInfo(username, userRoles), scope);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param httpServletRequest the httpServletRequest object
|
||||
|
|
Loading…
Reference in New Issue