+ public static boolean logoutCmsSession(Subject subject) {
+ UUID nodeSessionId;
+ if (subject.getPrivateCredentials(CmsSessionId.class).size() == 1)
+ nodeSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next().getUuid();
+ else
+ return false;
+ CmsSessionImpl cmsSession = CmsContextImpl.getCmsContext().getCmsSessionByUuid(nodeSessionId);
+
+ // FIXME logout all views
+ // TODO check why it is sometimes null
+ if (cmsSession != null)
+ cmsSession.close();
+ // if (log.isDebugEnabled())
+ // log.debug("Logged out CMS session " + cmsSession.getUuid());
+ return true;
+ }
+
+ /*
+ * PREPARE EVOLUTION OF JAVA APIs INTRODUCED IN JDK 18 The following static
+ * methods will be added to Subject
+ */
+ public Subject current() {
+ return currentSubject();
+ }
+
+ public static <T> T callAs(Subject subject, Callable<T> action) {
+ try {
+ return Subject.doAs(subject, new PrivilegedExceptionAction<T>() {
+
+ @Override
+ public T run() throws Exception {
+ return action.call();
+ }
+
+ });
+ } catch (PrivilegedActionException e) {
+ throw new CompletionException("Failed to execute action for " + subject, e.getCause());
+ }
+ }
+