]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/acr/CmsContentRepository.java
Prepare next development cycle
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / acr / CmsContentRepository.java
index 3b47c1630aa4f63a41a30d0909d2ace7b13350de..15b893bb3d3ade0aab47e084fd0ace6316511910 100644 (file)
@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
 
+import javax.security.auth.Subject;
 import javax.security.auth.login.LoginContext;
 import javax.security.auth.login.LoginException;
 
@@ -42,8 +43,11 @@ public class CmsContentRepository extends AbstractContentRepository {
 
        @Override
        public ContentSession get(Locale locale) {
-               if (!CmsSession.hasCmsSession(CurrentSubject.current())) {
-                       if (DataAdminPrincipal.isDataAdmin(CurrentSubject.current())) {
+               Subject subject = CurrentSubject.current();
+               if (subject == null)
+                       throw new IllegalStateException("Caller must be authenticated");
+               if (!CmsSession.hasCmsSession(subject)) {
+                       if (DataAdminPrincipal.isDataAdmin(subject)) {
                                // TODO open multiple data admin sessions?
                                return getSystemSession();
                        }
@@ -53,7 +57,7 @@ public class CmsContentRepository extends AbstractContentRepository {
                CmsSession cmsSession = CurrentUser.getCmsSession();
                CmsContentSession contentSession = userSessions.get(cmsSession);
                if (contentSession == null) {
-                       final CmsContentSession newContentSession = new CmsContentSession(this, cmsSession.getUuid(),
+                       final CmsContentSession newContentSession = new CmsContentSession(this, cmsSession.uuid(),
                                        cmsSession.getSubject(), locale, uuidFactory);
                        cmsSession.addOnCloseCallback((c) -> {
                                newContentSession.close();