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 {
|
public class SmartGearsPortalValve extends ValveBase {
|
||||||
private static final Logger _log = LoggerFactory.getLogger(SmartGearsPortalValve.class);
|
private static final Logger _log = LoggerFactory.getLogger(SmartGearsPortalValve.class);
|
||||||
private final static String DEFAULT_ROLE = "OrganizationMember";
|
private final static String DEFAULT_ROLE = "OrganizationMember";
|
||||||
|
private final static String LIFERAY_POLLER_CONTEXT = "poller/receive";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,19 +41,20 @@ public class SmartGearsPortalValve extends ValveBase {
|
||||||
//_log.trace("SmartGearsPortalValve SecurityTokenProvider and AuthorizationProvider reset OK");
|
//_log.trace("SmartGearsPortalValve SecurityTokenProvider and AuthorizationProvider reset OK");
|
||||||
if (req instanceof HttpServletRequest) {
|
if (req instanceof HttpServletRequest) {
|
||||||
HttpServletRequest request = (HttpServletRequest) req;
|
HttpServletRequest request = (HttpServletRequest) req;
|
||||||
PortalContext context = PortalContext.getConfiguration();
|
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 scope = context.getCurrentScope(request);
|
||||||
String username = getCurrentUsername(request);
|
String username = getCurrentUsername(request);
|
||||||
if (scope != null && username != null) {
|
if (scope != null && username != null) {
|
||||||
try {
|
try {
|
||||||
String userToken = getAuthorizationToken(username, scope);
|
String userToken = getAuthorizationToken(username, scope);
|
||||||
SecurityTokenProvider.instance.set(userToken);
|
SecurityTokenProvider.instance.set(userToken);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
_log.error("Something went wrong in generating token for " + username + " in scope " + scope);
|
_log.error("Something went wrong in generating token for " + username + " in scope " + scope);
|
||||||
e.printStackTrace();
|
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);
|
getNext().invoke(req, resp);
|
||||||
|
|
Loading…
Reference in New Issue