+ public UserAdmin getUserAdmin() {
+ return userAdmin;
+ }
+
+ /*
+ * CMS Sessions
+ */
+
+ @Override
+ public 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 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 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());
+ }
+
+ /**
+ * The {@link CmsSession} related to this UUID, or <code>null</null> if not
+ * registered.
+ */
+ public CmsSessionImpl getCmsSessionByUuid(UUID uuid) {
+ return cmsSessionsByUuid.get(uuid);
+ }
+
+ /**
+ * The {@link CmsSession} related to this local id, or <code>null</null> if not
+ * registered.
+ */
+ public CmsSessionImpl getCmsSessionByLocalId(String localId) {
+ return cmsSessionsByLocalId.get(localId);
+ }
+