]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.cms/src/org/argeo/cms/auth/CmsAuthUtils.java
Improve certificate auth
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / auth / CmsAuthUtils.java
index aa313ee0a954e6b2b1fa088f9c1881d9e093de72..dde2d73f50efffa23f6267d454e9b9c24f75de76 100644 (file)
@@ -145,7 +145,8 @@ class CmsAuthUtils {
                                                                + " for existing CMS session " + cmsSession);
                                        }
                                        // keyring
-                                       subject.getPrivateCredentials().addAll(cmsSession.getSecretKeys());
+                                       if (cmsSession != null)
+                                               subject.getPrivateCredentials().addAll(cmsSession.getSecretKeys());
                                } else {// anonymous
                                        if (cmsSession.getAuthorization().getName() != null) {
                                                cmsSession.close();
@@ -157,18 +158,19 @@ class CmsAuthUtils {
                                cmsSession = new WebCmsSessionImpl(subject, authorization, locale, request);
                        }
                        // request.setAttribute(CmsSession.class.getName(), cmsSession);
-                       CmsSessionId nodeSessionId = new CmsSessionId(cmsSession.getUuid());
-                       if (subject.getPrivateCredentials(CmsSessionId.class).size() == 0)
-                               subject.getPrivateCredentials().add(nodeSessionId);
-                       else {
-                               UUID storedSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next().getUuid();
-                               // if (storedSessionId.equals(httpSessionId.getValue()))
-                               throw new CmsException(
-                                               "Subject already logged with session " + storedSessionId + " (not " + nodeSessionId + ")");
+                       if (cmsSession != null) {
+                               CmsSessionId nodeSessionId = new CmsSessionId(cmsSession.getUuid());
+                               if (subject.getPrivateCredentials(CmsSessionId.class).size() == 0)
+                                       subject.getPrivateCredentials().add(nodeSessionId);
+                               else {
+                                       UUID storedSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next()
+                                                       .getUuid();
+                                       // if (storedSessionId.equals(httpSessionId.getValue()))
+                                       throw new CmsException(
+                                                       "Subject already logged with session " + storedSessionId + " (not " + nodeSessionId + ")");
+                               }
                        }
-               } else
-
-               {
+               } else {
                        // TODO desktop, CLI
                }
        }