try { Map<String, String> messages = new TreeMap<>(); for (String name : userSession.getAttributeNames()) { if (name.startsWith(MESSAGE_ATTR_PREFIX)) { Object message = userSession.getAttribute(name);
templateParams.put(sessionPrefix + "userId", userSession.getCurrentOrSubstitutedUser().getId()); templateParams.put(sessionPrefix + "userLogin", userSession.getCurrentOrSubstitutedUser().getLoginLowerCase()); for (String name : userSession.getAttributeNames()) { templateParams.put(sessionPrefix + name, userSession.getAttribute(name));
protected void compileSessionAttributes(UserSession session, Group group) { List<SessionAttribute> list = new ArrayList<>(group.getSessionAttributes()); EntityManager em = persistence.getEntityManager(); TypedQuery<SessionAttribute> q = em.createQuery("select a from sec$GroupHierarchy h join h.parent.sessionAttributes a " + "where h.group.id = ?1 order by h.level desc", SessionAttribute.class); q.setParameter(1, group.getId()); List<SessionAttribute> attributes = q.getResultList(); list.addAll(attributes); for (SessionAttribute attribute : list) { Datatype datatype = Datatypes.get(attribute.getDatatype()); try { if (session.getAttributeNames().contains(attribute.getName())) { log.warn("Duplicate definition of '{}' session attribute in the group hierarchy", attribute.getName()); } Serializable value = (Serializable) datatype.parse(attribute.getStringValue()); if (value != null) session.setAttribute(attribute.getName(), value); else session.removeAttribute(attribute.getName()); } catch (ParseException e) { throw new RuntimeException("Unable to set session attribute " + attribute.getName(), e); } } }