diff --git a/modules/core/src/com/haulmont/cuba/core/SecurityProvider.java b/modules/core/src/com/haulmont/cuba/core/SecurityProvider.java index cadbddd556..a0b5962567 100644 --- a/modules/core/src/com/haulmont/cuba/core/SecurityProvider.java +++ b/modules/core/src/com/haulmont/cuba/core/SecurityProvider.java @@ -16,6 +16,7 @@ import com.haulmont.cuba.core.global.QueryTransformerFactory; import java.util.Arrays; import java.util.List; +import java.io.Serializable; public abstract class SecurityProvider { @@ -23,6 +24,10 @@ public abstract class SecurityProvider private static final String DEFAULT_IMPL = "com.haulmont.cuba.core.sys.SecurityProviderImpl"; + public static final String CONSTRAINT_PARAM_USER_LOGIN = "currentUserLogin"; + public static final String CONSTRAINT_PARAM_USER_ID = "currentUserId"; + public static final String CONSTRAINT_PARAM_SESSION_ATTR = "session_"; + private static SecurityProvider instance; private static SecurityProvider getInstance() { @@ -81,11 +86,16 @@ public abstract class SecurityProvider } protected void setQueryParam(Query query, String paramName) { - if ("currentUserLogin".equals(paramName)) { - query.setParameter("currentUserLogin", __currentUserSession().getLogin()); + if (CONSTRAINT_PARAM_USER_LOGIN.equals(paramName)) { + query.setParameter(paramName, __currentUserSession().getLogin()); } - else if ("currentUserId".equals(paramName)) { - query.setParameter("currentUserId", __currentUserSession().getUserId()); + else if (CONSTRAINT_PARAM_USER_ID.equals(paramName)) { + query.setParameter(paramName, __currentUserSession().getUserId()); + } + else if (paramName.startsWith(CONSTRAINT_PARAM_SESSION_ATTR)) { + String attrName = paramName.substring(CONSTRAINT_PARAM_SESSION_ATTR.length()); + Serializable value = __currentUserSession().getAttribute(attrName); + query.setParameter(paramName, value); } } }