public static boolean isLoggedInWithExternalAuth(UserSession userSession) { return userSession.getAttribute(EXTERNAL_AUTH_USER_SESSION_ATTRIBUTE) != null; }
for (String name : userSession.getAttributeNames()) { if (name.startsWith(MESSAGE_ATTR_PREFIX)) { Object message = userSession.getAttribute(name); if (message instanceof String) messages.put(name, (String) message);
@Override public void pingUserSession(UserSession session) { String idpSessionId = session.getAttribute(IdpService.IDP_USER_SESSION_ATTRIBUTE); if (idpSessionId != null) { pingIdpSessionServer(idpSessionId); } }
templateParams.put(sessionPrefix + "userLogin", userSession.getCurrentOrSubstitutedUser().getLoginLowerCase()); for (String name : userSession.getAttributeNames()) { templateParams.put(sessionPrefix + name, userSession.getAttribute(name));
protected void incrementQueryKey() { queryKey = userSession.getAttribute("_queryKey"); if (queryKey == null) queryKey = 1; else queryKey++; userSession.setAttribute("_queryKey", queryKey); }
@Override public List<UUID> findUserSessionsByAttribute(String attributeName, Object attributeValue) { Preconditions.checkNotNullArgument(attributeName); //noinspection UnnecessaryLocalVariable List<UUID> sessionIds = getSessionInfoStream() .filter(usInfo -> Objects.equals(usInfo.session.getAttribute(attributeName), attributeValue)) .map(userSessionInfo -> userSessionInfo.session.getId()) .collect(Collectors.toList()); return sessionIds; }
protected int getNextQueryKey() { UserSession userSession = userSessionSource.getUserSession(); Integer queryKey = userSession.getAttribute("_queryKey"); if (queryKey == null) queryKey = 1; else queryKey++; userSession.setAttribute("_queryKey", queryKey); return queryKey; } }
/** * Returns the tenant ID of a logged in user. * @return tenant ID of a logged in user, null if the user doesn't have a tenant ID * @throws IllegalStateException if there is no active user session */ public String getCurrentUserTenantId() { return uss.getUserSession().getAttribute(tenantConfig.getTenantIdName()); } }
protected boolean resultsAlreadySaved(Integer queryKey, LoadContext.Query query) { LinkedHashMap<Integer, QueryHolder> recentQueries = userSessionSource.getUserSession().getAttribute("_recentQueries"); if (recentQueries == null) { recentQueries = new LinkedHashMap<Integer, QueryHolder>() { private static final long serialVersionUID = -901296839279897248L; @Override protected boolean removeEldestEntry(Map.Entry<Integer, QueryHolder> eldest) { return size() > 10; } }; } QueryHolder queryHolder = new QueryHolder(query); QueryHolder oldQueryHolder = recentQueries.put(queryKey, queryHolder); // do not set to session attribute recentQueries directly, it contains reference to QueryResultsManager class // copy data to new LinkedHashMap userSessionSource.getUserSession().setAttribute("_recentQueries", new LinkedHashMap<>(recentQueries)); return queryHolder.equals(oldQueryHolder); }
value = userSession.getAttribute(path); if (value instanceof String && info.isCaseInsensitive()) { value = makeCaseInsensitive((String) value);
@Override public void setQueryParam(Query query, String paramName) { if (paramName.startsWith(CONSTRAINT_PARAM_SESSION_ATTR)) { UserSession userSession = userSessionSource.getUserSession(); String attrName = paramName.substring(CONSTRAINT_PARAM_SESSION_ATTR.length()); if (CONSTRAINT_PARAM_USER_LOGIN.equals(attrName)) { String userLogin = userSession.getSubstitutedUser() != null ? userSession.getSubstitutedUser().getLogin() : userSession.getUser().getLogin(); query.setParameter(paramName, userLogin); } else if (CONSTRAINT_PARAM_USER_ID.equals(attrName)) { UUID userId = userSession.getSubstitutedUser() != null ? userSession.getSubstitutedUser().getId() : userSession.getUser().getId(); query.setParameter(paramName, userId); } else if (CONSTRAINT_PARAM_USER_GROUP_ID.equals(attrName)) { Object groupId = userSession.getSubstitutedUser() == null ? userSession.getUser().getGroup().getId() : userSession.getSubstitutedUser().getGroup().getId(); query.setParameter(paramName, groupId); } else { Serializable value = userSession.getAttribute(attrName); query.setParameter(paramName, value); } } }