package org.argeo.cms.e4.parts;
-import java.security.AccessController;
import java.time.ZonedDateTime;
import javax.annotation.PostConstruct;
-import javax.security.auth.Subject;
import org.argeo.api.cms.CmsSession;
import org.argeo.cms.auth.CurrentUser;
-import org.argeo.cms.osgi.CmsOsgiUtils;
import org.argeo.cms.swt.CmsSwtUtils;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
/** A canonical view of the logged in user. */
public class EgoDashboard {
- private BundleContext bc = FrameworkUtil.getBundle(EgoDashboard.class).getBundleContext();
+// private BundleContext bc = FrameworkUtil.getBundle(EgoDashboard.class).getBundleContext();
@PostConstruct
public void createPartControl(Composite p) {
CmsSwtUtils.txt(p, role);
}
- Subject subject = Subject.getSubject(AccessController.getContext());
- if (subject != null) {
- CmsSession cmsSession = CmsOsgiUtils.getCmsSession(bc, subject);
- ZonedDateTime loggedIndSince = cmsSession.getCreationTime();
- CmsSwtUtils.lbl(p, "Session:");
- CmsSwtUtils.txt(p, cmsSession.getUuid().toString());
- CmsSwtUtils.lbl(p, "Logged in since:");
- CmsSwtUtils.txt(p, loggedIndSince.toString());
- }
+// Subject subject = Subject.getSubject(AccessController.getContext());
+// if (subject != null) {
+ CmsSession cmsSession = CurrentUser.getCmsSession();
+ ZonedDateTime loggedIndSince = cmsSession.getCreationTime();
+ CmsSwtUtils.lbl(p, "Session:");
+ CmsSwtUtils.txt(p, cmsSession.getUuid().toString());
+ CmsSwtUtils.lbl(p, "Logged in since:");
+ CmsSwtUtils.txt(p, loggedIndSince.toString());
+// }
}
}
import org.eclipse.swt.widgets.Composite;
public class CmsUserApp extends AbstractCmsApp {
- private CmsContext cmsContext;
private ContentRepository contentRepository;
@Override
CmsSwtUi cmsUi = new CmsSwtUi(parent, SWT.NONE);
if ("login".equals(uiName)) {
CmsView cmsView = CmsSwtUtils.getCmsView(cmsUi);
- CmsLogin cmsLogin = new CmsLogin(cmsView, cmsContext);
+ CmsLogin cmsLogin = new CmsLogin(cmsView, getCmsContext());
cmsLogin.createUi(cmsUi);
} else if ("data".equals(uiName)) {
this.contentRepository = contentRepository;
}
- public void setCmsContext(CmsContext cmsContext) {
- this.cmsContext = cmsContext;
- }
-
}
\ No newline at end of file
void addCmsAppListener(CmsAppListener listener);
void removeCmsAppListener(CmsAppListener listener);
+
+ CmsContext getCmsContext();
}
import java.util.List;
import java.util.Locale;
+import javax.security.auth.Subject;
+
/**
* A logical view on this CMS instance, independently of a particular launch or
* deployment.
Long getAvailableSince();
-
/** Mark this group as a workgroup */
void createWorkgroup(String groupDn);
+
+ /** Get the CMS session of this subject. */
+ CmsSession getCmsSession(Subject subject);
}
import org.argeo.api.cms.CmsApp;
import org.argeo.api.cms.CmsAppListener;
+import org.argeo.api.cms.CmsContext;
import org.argeo.api.cms.CmsTheme;
/** Base class for {@link CmsApp}s. */
public abstract class AbstractCmsApp implements CmsApp {
+ private CmsContext cmsContext;
+
private Map<String, CmsTheme> themes = Collections.synchronizedMap(new HashMap<>());
private List<CmsAppListener> cmsAppListeners = new ArrayList<>();
cmsAppListeners.remove(listener);
}
+ @Override
+ public CmsContext getCmsContext() {
+ return cmsContext;
+ }
+
+ public void setCmsContext(CmsContext cmsContext) {
+ this.cmsContext = cmsContext;
+ }
+
+
+
}
import org.argeo.cms.internal.auth.CmsSessionImpl;
import org.argeo.cms.internal.auth.ImpliedByPrincipal;
import org.argeo.cms.internal.http.WebCmsSessionImpl;
+import org.argeo.cms.internal.runtime.CmsContextImpl;
import org.argeo.cms.security.NodeSecurityUtils;
import org.argeo.osgi.useradmin.AuthenticatingUser;
import org.osgi.framework.BundleContext;
request.setAttribute(HttpContext.AUTHORIZATION, authorization);
CmsSessionImpl cmsSession;
- CmsSessionImpl currentLocalSession = CmsSessionImpl.getByLocalId(httpSessId);
+ CmsSessionImpl currentLocalSession = CmsContextImpl.getCmsContext().getCmsSessionByLocalId(httpSessId);
if (currentLocalSession != null) {
boolean currentLocalSessionAnonymous = currentLocalSession.getAuthorization().getName() == null;
if (!anonymous) {
} else {
// new CMS session
cmsSession = new WebCmsSessionImpl(subject, authorization, locale, request);
+ CmsContextImpl.getCmsContext().registerCmsSession(cmsSession);
}
if (cmsSession == null)// should be dead code (cf. SuppressWarning of the method)
}
} else {
CmsSessionImpl cmsSession = new CmsSessionImpl(subject, authorization, locale, "desktop");
+ CmsContextImpl.getCmsContext().registerCmsSession(cmsSession);
CmsSessionId nodeSessionId = new CmsSessionId(cmsSession.getUuid());
subject.getPrivateCredentials().add(nodeSessionId);
}
}
- public static CmsSessionImpl cmsSessionFromHttpSession(BundleContext bc, String httpSessionId) {
- Authorization authorization = null;
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class,
- "(" + CmsSession.SESSION_LOCAL_ID + "=" + httpSessionId + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for id " + httpSessionId, e);
- }
- CmsSessionImpl cmsSession;
- if (sr.size() == 1) {
- cmsSession = (CmsSessionImpl) bc.getService(sr.iterator().next());
-// locale = cmsSession.getLocale();
- authorization = cmsSession.getAuthorization();
- if (authorization.getName() == null)
- return null;// anonymous is not sufficient
- } else if (sr.size() == 0)
- return null;
- else
- throw new IllegalStateException(sr.size() + ">1 web sessions detected for http session " + httpSessionId);
- return cmsSession;
- }
+// public static CmsSessionImpl cmsSessionFromHttpSession(BundleContext bc, String httpSessionId) {
+// Authorization authorization = null;
+// Collection<ServiceReference<CmsSession>> sr;
+// try {
+// sr = bc.getServiceReferences(CmsSession.class,
+// "(" + CmsSession.SESSION_LOCAL_ID + "=" + httpSessionId + ")");
+// } catch (InvalidSyntaxException e) {
+// throw new IllegalArgumentException("Cannot get CMS session for id " + httpSessionId, e);
+// }
+// CmsSessionImpl cmsSession;
+// if (sr.size() == 1) {
+// cmsSession = (CmsSessionImpl) bc.getService(sr.iterator().next());
+//// locale = cmsSession.getLocale();
+// authorization = cmsSession.getAuthorization();
+// if (authorization.getName() == null)
+// return null;// anonymous is not sufficient
+// } else if (sr.size() == 0)
+// return null;
+// else
+// throw new IllegalStateException(sr.size() + ">1 web sessions detected for http session " + httpSessionId);
+// return cmsSession;
+// }
public static <T extends Principal> T getSinglePrincipal(Subject subject, Class<T> clss) {
Set<T> principals = subject.getPrincipals(clss);
public static CmsSession getCmsSession() {
Subject subject = currentSubject();
CmsSessionId cmsSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next();
- return CmsSessionImpl.getByUuid(cmsSessionId.getUuid());
+ return CmsContextImpl.getCmsContext().getCmsSessionByUuid(cmsSessionId.getUuid());
}
/*
nodeSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next().getUuid();
else
return false;
- CmsSessionImpl cmsSession = CmsSessionImpl.getByUuid(nodeSessionId.toString());
+ CmsSessionImpl cmsSession = CmsContextImpl.getCmsContext().getCmsSessionByUuid(nodeSessionId);
// FIXME logout all views
// TODO check why it is sometimes null
import javax.security.auth.Subject;
import org.argeo.api.cms.CmsSession;
-import org.argeo.cms.osgi.CmsOsgiUtils;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
+import org.argeo.cms.internal.runtime.CmsContextImpl;
/** Remote authentication utilities. */
public class RemoteAuthUtils {
static final String REMOTE_USER = "org.osgi.service.http.authentication.remote.user";
- private static BundleContext bundleContext = FrameworkUtil.getBundle(RemoteAuthUtils.class).getBundleContext();
+// private static BundleContext bundleContext = FrameworkUtil.getBundle(RemoteAuthUtils.class).getBundleContext();
/**
* Execute this supplier, using the CMS class loader as context classloader.
public static CmsSession getCmsSession(RemoteAuthRequest req) {
Subject subject = Subject
.getSubject((AccessControlContext) req.getAttribute(AccessControlContext.class.getName()));
- CmsSession cmsSession = CmsOsgiUtils.getCmsSession(bundleContext, subject);
+ CmsSession cmsSession = CmsContextImpl.getCmsContext().getCmsSession(subject);
return cmsSession;
}
}
import org.argeo.api.cms.CmsConstants;
import org.argeo.api.cms.CmsLog;
import org.argeo.cms.internal.auth.CmsSessionImpl;
+import org.argeo.cms.internal.runtime.CmsContextImpl;
import org.argeo.cms.internal.runtime.KernelUtils;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
import org.osgi.service.http.HttpContext;
import org.osgi.service.useradmin.Authorization;
private RemoteAuthRequest request = null;
private RemoteAuthResponse response = null;
- private BundleContext bc;
+// private BundleContext bc;
private Authorization authorization;
private Locale locale;
@Override
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
Map<String, ?> options) {
- bc = FrameworkUtil.getBundle(RemoteSessionLoginModule.class).getBundleContext();
- assert bc != null;
+// bc = FrameworkUtil.getBundle(RemoteSessionLoginModule.class).getBundleContext();
+// assert bc != null;
this.subject = subject;
this.callbackHandler = callbackHandler;
this.sharedState = (Map<String, Object>) sharedState;
String httpSessionId = httpSession.getId();
// if (log.isTraceEnabled())
// log.trace("HTTP login: " + request.getPathInfo() + " #" + httpSessionId);
- CmsSessionImpl cmsSession = CmsAuthUtils.cmsSessionFromHttpSession(bc, httpSessionId);
- if (cmsSession != null) {
+ CmsSessionImpl cmsSession = CmsContextImpl.getCmsContext().getCmsSessionByLocalId(httpSessionId);
+ if (cmsSession != null && !cmsSession.isAnonymous()) {
authorization = cmsSession.getAuthorization();
locale = cmsSession.getLocale();
if (log.isTraceEnabled())
String httpSessionId = httpSession.getId();
// if (log.isTraceEnabled())
// log.trace("HTTP login: " + request.getPathInfo() + " #" + httpSessionId);
- CmsSessionImpl cmsSession = CmsAuthUtils.cmsSessionFromHttpSession(bc, httpSessionId);
- if (cmsSession != null) {
+ CmsSessionImpl cmsSession = CmsContextImpl.getCmsContext().getCmsSessionByLocalId(httpSessionId);
+ if (cmsSession != null && !cmsSession.isAnonymous()) {
authorization = cmsSession.getAuthorization();
locale = cmsSession.getLocale();
if (log.isTraceEnabled())
@Override
public boolean login() throws LoginException {
- UserAdmin userAdmin = CmsContextImpl.getUserAdmin();
+ UserAdmin userAdmin = CmsContextImpl.getCmsContext().getUserAdmin();
final String username;
final char[] password;
Object certificateChain = null;
// if (singleUser) {
// OsUserUtils.loginAsSystemUser(subject);
// }
- UserAdmin userAdmin = CmsContextImpl.getUserAdmin();
+ UserAdmin userAdmin = CmsContextImpl.getCmsContext().getUserAdmin();
Authorization authorization;
if (callbackHandler == null) {// anonymous
authorization = userAdmin.getAuthorization(null);
import org.argeo.api.cms.CmsAuth;
import org.argeo.api.cms.CmsLog;
import org.argeo.api.cms.CmsSession;
+import org.argeo.cms.internal.runtime.CmsContextImpl;
import org.argeo.cms.security.NodeSecurityUtils;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
/** Default CMS session implementation. */
public class CmsSessionImpl implements CmsSession, Serializable {
private static final long serialVersionUID = 1867719354246307225L;
- private final static BundleContext bc = FrameworkUtil.getBundle(CmsSessionImpl.class).getBundleContext();
+// private final static BundleContext bc = FrameworkUtil.getBundle(CmsSessionImpl.class).getBundleContext();
private final static CmsLog log = CmsLog.getLog(CmsSessionImpl.class);
// private final Subject initialSubject;
this.userDn = NodeSecurityUtils.ROLE_ANONYMOUS_NAME;
this.anonymous = true;
}
+ // TODO use time-based UUID?
this.uuid = UUID.randomUUID();
// register as service
- Hashtable<String, String> props = new Hashtable<>();
- props.put(CmsSession.USER_DN, userDn.toString());
- props.put(CmsSession.SESSION_UUID, uuid.toString());
- props.put(CmsSession.SESSION_LOCAL_ID, localSessionId);
- serviceRegistration = bc.registerService(CmsSession.class, this, props);
+// Hashtable<String, String> props = new Hashtable<>();
+// props.put(CmsSession.USER_DN, userDn.toString());
+// props.put(CmsSession.SESSION_UUID, uuid.toString());
+// props.put(CmsSession.SESSION_LOCAL_ID, localSessionId);
+// serviceRegistration = bc.registerService(CmsSession.class, this, props);
}
public void close() {
end = ZonedDateTime.now();
- serviceRegistration.unregister();
+ CmsContextImpl.getCmsContext().unregisterCmsSession(this);
+// serviceRegistration.unregister();
for (Consumer<CmsSession> onClose : onCloseCallbacks) {
onClose.accept(this);
}
public String toString() {
- return "CMS Session " + userDn + " local=" + localSessionId + ", uuid=" + uuid;
+ return "CMS Session " + userDn + " localId=" + localSessionId + ", uuid=" + uuid;
}
- public static CmsSessionImpl getByLocalId(String localId) {
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_LOCAL_ID + "=" + localId + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for id " + localId, e);
- }
- ServiceReference<CmsSession> cmsSessionRef;
- if (sr.size() == 1) {
- cmsSessionRef = sr.iterator().next();
- return (CmsSessionImpl) bc.getService(cmsSessionRef);
- } else if (sr.size() == 0) {
- return null;
- } else
- throw new IllegalStateException(sr.size() + " CMS sessions registered for " + localId);
-
- }
-
- public static CmsSessionImpl getByUuid(Object uuid) {
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for uuid " + uuid, e);
- }
- ServiceReference<CmsSession> cmsSessionRef;
- if (sr.size() == 1) {
- cmsSessionRef = sr.iterator().next();
- return (CmsSessionImpl) bc.getService(cmsSessionRef);
- } else if (sr.size() == 0) {
- return null;
- } else
- throw new IllegalStateException(sr.size() + " CMS sessions registered for " + uuid);
-
- }
-
- public static void closeInvalidSessions() {
- Collection<ServiceReference<CmsSession>> srs;
- try {
- srs = bc.getServiceReferences(CmsSession.class, null);
- for (ServiceReference<CmsSession> sr : srs) {
- CmsSession cmsSession = bc.getService(sr);
- if (!cmsSession.isValid()) {
- ((CmsSessionImpl) cmsSession).close();
- if (log.isDebugEnabled())
- log.debug("Closed expired CMS session " + cmsSession);
- }
- }
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS sessions", e);
- }
- }
+// public static CmsSessionImpl getByLocalId(String localId) {
+// Collection<ServiceReference<CmsSession>> sr;
+// try {
+// sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_LOCAL_ID + "=" + localId + ")");
+// } catch (InvalidSyntaxException e) {
+// throw new IllegalArgumentException("Cannot get CMS session for id " + localId, e);
+// }
+// ServiceReference<CmsSession> cmsSessionRef;
+// if (sr.size() == 1) {
+// cmsSessionRef = sr.iterator().next();
+// return (CmsSessionImpl) bc.getService(cmsSessionRef);
+// } else if (sr.size() == 0) {
+// return null;
+// } else
+// throw new IllegalStateException(sr.size() + " CMS sessions registered for " + localId);
+//
+// }
+//
+// public static CmsSessionImpl getByUuid(Object uuid) {
+// Collection<ServiceReference<CmsSession>> sr;
+// try {
+// sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")");
+// } catch (InvalidSyntaxException e) {
+// throw new IllegalArgumentException("Cannot get CMS session for uuid " + uuid, e);
+// }
+// ServiceReference<CmsSession> cmsSessionRef;
+// if (sr.size() == 1) {
+// cmsSessionRef = sr.iterator().next();
+// return (CmsSessionImpl) bc.getService(cmsSessionRef);
+// } else if (sr.size() == 0) {
+// return null;
+// } else
+// throw new IllegalStateException(sr.size() + " CMS sessions registered for " + uuid);
+//
+// }
+//
+// public static void closeInvalidSessions() {
+// Collection<ServiceReference<CmsSession>> srs;
+// try {
+// srs = bc.getServiceReferences(CmsSession.class, null);
+// for (ServiceReference<CmsSession> sr : srs) {
+// CmsSession cmsSession = bc.getService(sr);
+// if (!cmsSession.isValid()) {
+// ((CmsSessionImpl) cmsSession).close();
+// if (log.isDebugEnabled())
+// log.debug("Closed expired CMS session " + cmsSession);
+// }
+// }
+// } catch (InvalidSyntaxException e) {
+// throw new IllegalArgumentException("Cannot get CMS sessions", e);
+// }
+// }
}
return httpSession.isValid();
}
- public static CmsSessionImpl getCmsSession(RemoteAuthRequest request) {
- return CmsSessionImpl.getByLocalId(request.getSession().getId());
- }
+// public static CmsSessionImpl getCmsSession(RemoteAuthRequest request) {
+// return CmsSessionImpl.getByLocalId(request.getSession().getId());
+// }
}
import static java.util.Locale.ENGLISH;
import java.lang.management.ManagementFactory;
+import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
+import javax.security.auth.Subject;
+
import org.argeo.api.cms.CmsConstants;
import org.argeo.api.cms.CmsContext;
import org.argeo.api.cms.CmsDeployment;
import org.argeo.api.cms.CmsLog;
+import org.argeo.api.cms.CmsSession;
+import org.argeo.api.cms.CmsSessionId;
import org.argeo.api.cms.CmsState;
import org.argeo.cms.LocaleUtils;
-import org.argeo.cms.internal.osgi.NodeUserAdmin;
+import org.argeo.cms.internal.auth.CmsSessionImpl;
import org.ietf.jgss.GSSCredential;
import org.osgi.service.useradmin.UserAdmin;
private Long availableSince;
+ // CMS sessions
+ private Map<UUID, CmsSessionImpl> cmsSessionsByUuid = new HashMap<>();
+ private Map<String, CmsSessionImpl> cmsSessionsByLocalId = new HashMap<>();
+
// public CmsContextImpl() {
// initTrackers();
// }
* STATIC
*/
- public synchronized static CmsContext getCmsContext() {
+ public synchronized static CmsContextImpl getCmsContext() {
return getInstance();
}
- /** Required by USER login module. */
- public synchronized static UserAdmin getUserAdmin() {
- return getInstance().userAdmin;
- }
+// /** Required by USER login module. */
+// public synchronized static UserAdmin getUserAdmin() {
+// return getInstance().userAdmin;
+// }
/** Required by SPNEGO login module. */
@Deprecated
public synchronized static GSSCredential getAcceptorCredentials() {
// FIXME find a cleaner way
- return ((NodeUserAdmin) getInstance().userAdmin).getAcceptorCredentials();
+ return ((CmsUserAdmin) getInstance().userAdmin).getAcceptorCredentials();
}
private synchronized static void setInstance(CmsContextImpl cmsContextImpl) {
}
}
+ public UserAdmin getUserAdmin() {
+ return userAdmin;
+ }
+
+ /*
+ * CMS Sessions
+ */
+
+ @Override
+ public synchronized CmsSession getCmsSession(Subject subject) {
+ if (subject.getPrivateCredentials(CmsSessionId.class).isEmpty())
+ return null;
+ CmsSessionId cmsSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next();
+ return getCmsSessionByUuid(cmsSessionId.getUuid());
+ }
+
+ public synchronized void registerCmsSession(CmsSessionImpl cmsSession) {
+ if (cmsSessionsByUuid.containsKey(cmsSession.getUuid())
+ || cmsSessionsByLocalId.containsKey(cmsSession.getLocalId()))
+ throw new IllegalStateException("CMS session " + cmsSession + " is already registered.");
+ cmsSessionsByUuid.put(cmsSession.getUuid(), cmsSession);
+ cmsSessionsByLocalId.put(cmsSession.getLocalId(), cmsSession);
+ }
+
+ public synchronized void unregisterCmsSession(CmsSessionImpl cmsSession) {
+ if (!cmsSessionsByUuid.containsKey(cmsSession.getUuid())
+ || !cmsSessionsByLocalId.containsKey(cmsSession.getLocalId()))
+ throw new IllegalStateException("CMS session " + cmsSession + " is not registered.");
+ CmsSession removed = cmsSessionsByUuid.remove(cmsSession.getUuid());
+ assert removed == cmsSession;
+ cmsSessionsByLocalId.remove(cmsSession.getLocalId());
+ }
+
+ public synchronized CmsSessionImpl getCmsSessionByUuid(UUID uuid) {
+ return cmsSessionsByUuid.get(uuid);
+ }
+
+ public synchronized CmsSessionImpl getCmsSessionByLocalId(String localId) {
+ return cmsSessionsByLocalId.get(localId);
+ }
+
}
+++ /dev/null
-package org.argeo.cms.osgi;
-
-import java.util.Collection;
-
-import javax.security.auth.Subject;
-
-import org.argeo.api.cms.CmsSession;
-import org.argeo.api.cms.CmsSessionId;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-
-public class CmsOsgiUtils {
-
- /** @return The {@link CmsSession} for this {@link Subject} or null. */
- public static CmsSession getCmsSession(BundleContext bc, Subject subject) {
- if (subject.getPrivateCredentials(CmsSessionId.class).isEmpty())
- return null;
- CmsSessionId cmsSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next();
- String uuid = cmsSessionId.getUuid().toString();
- Collection<ServiceReference<CmsSession>> sr;
- try {
- sr = bc.getServiceReferences(CmsSession.class, "(" + CmsSession.SESSION_UUID + "=" + uuid + ")");
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException("Cannot get CMS session for uuid " + uuid, e);
- }
- ServiceReference<CmsSession> cmsSessionRef;
- if (sr.size() == 1) {
- cmsSessionRef = sr.iterator().next();
- return bc.getService(cmsSessionRef);
- } else if (sr.size() == 0) {
- return null;
- } else
- throw new IllegalStateException(sr.size() + " CMS sessions registered for " + uuid);
- }
-
- /** Singleton.*/
- private CmsOsgiUtils() {
- }
-}
import org.argeo.api.cms.CmsApp;
import org.argeo.api.cms.CmsAuth;
import org.argeo.api.cms.CmsImageManager;
+import org.argeo.api.cms.CmsLog;
import org.argeo.api.cms.CmsSession;
import org.argeo.api.cms.CmsUi;
import org.argeo.api.cms.CmsView;
-import org.argeo.api.cms.CmsLog;
import org.argeo.api.cms.UxContext;
import org.argeo.cms.LocaleUtils;
import org.argeo.cms.auth.CurrentUser;
import org.argeo.cms.auth.RemoteAuthCallbackHandler;
-import org.argeo.cms.osgi.CmsOsgiUtils;
import org.argeo.cms.servlet.ServletHttpRequest;
import org.argeo.cms.servlet.ServletHttpResponse;
import org.argeo.cms.swt.CmsSwtUtils;
@Override
public CmsSession getCmsSession() {
- CmsSession cmsSession = CmsOsgiUtils.getCmsSession(cmsWebApp.getBundleContext(), getSubject());
+ CmsSession cmsSession = cmsWebApp.getCmsApp().getCmsContext().getCmsSession(getSubject());
return cmsSession;
}
import org.argeo.api.cms.CmsUi;
import org.argeo.api.cms.CmsView;
import org.argeo.api.cms.UxContext;
-import org.argeo.cms.osgi.CmsOsgiUtils;
import org.argeo.cms.swt.CmsSwtUtils;
import org.eclipse.e4.ui.css.core.engine.CSSEngine;
import org.eclipse.e4.ui.css.core.engine.CSSErrorHandler;
@Override
public CmsSession getCmsSession() {
- CmsSession cmsSession = CmsOsgiUtils.getCmsSession(bundleContext, getSubject());
+ CmsSession cmsSession = cmsApp.getCmsContext().getCmsSession(getSubject());
return cmsSession;
}