Search in sources :

Example 1 with ClientBasedSession

use of com.haulmont.cuba.security.global.ClientBasedSession in project cuba by cuba-platform.

the class CubaRemoteInvocationFactory method createRemoteInvocation.

@Override
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
    SecurityContext securityContext = AppContext.getSecurityContext();
    CubaRemoteInvocation remoteInvocation = new CubaRemoteInvocation(methodInvocation, securityContext == null ? null : securityContext.getSessionId());
    if (securityContext != null) {
        UserSession session = securityContext.getSession();
        if (session instanceof ClientBasedSession && ((ClientBasedSession) session).hasRequestScopedInfo()) {
            remoteInvocation.setLocale(session.getLocale() != null ? session.getLocale().toLanguageTag() : null);
            remoteInvocation.setTimeZone(session.getTimeZone());
            remoteInvocation.setAddress(session.getAddress());
            remoteInvocation.setClientInfo(session.getClientInfo());
        }
    }
    return remoteInvocation;
}
Also used : ClientBasedSession(com.haulmont.cuba.security.global.ClientBasedSession) UserSession(com.haulmont.cuba.security.global.UserSession) SecurityContext(com.haulmont.cuba.core.sys.SecurityContext)

Example 2 with ClientBasedSession

use of com.haulmont.cuba.security.global.ClientBasedSession in project cuba by cuba-platform.

the class StickySessionServerSelector method getSessionUrlsHolder.

@Nullable
protected SessionUrlsHolder getSessionUrlsHolder() {
    SecurityContext securityContext = AppContext.getSecurityContext();
    if (securityContext == null)
        return null;
    UserSession session = securityContext.getSession();
    if (session == null || session instanceof ClientBasedSession && ((ClientBasedSession) session).hasRequestScopedInfo())
        return anonymousSessionUrlsHolder;
    return new UserSessionUrlsHolder(session);
}
Also used : ClientBasedSession(com.haulmont.cuba.security.global.ClientBasedSession) UserSession(com.haulmont.cuba.security.global.UserSession) SecurityContext(com.haulmont.cuba.core.sys.SecurityContext) Nullable(javax.annotation.Nullable)

Aggregations

SecurityContext (com.haulmont.cuba.core.sys.SecurityContext)2 ClientBasedSession (com.haulmont.cuba.security.global.ClientBasedSession)2 UserSession (com.haulmont.cuba.security.global.UserSession)2 Nullable (javax.annotation.Nullable)1