import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal;
-import org.argeo.api.NodeConstants;
+import org.argeo.api.cms.CmsConstants;
+import org.argeo.api.cms.CmsSession;
+import org.argeo.api.cms.CmsSessionId;
import org.argeo.cms.internal.auth.CmsSessionImpl;
import org.argeo.cms.internal.auth.ImpliedByPrincipal;
-import org.argeo.cms.internal.kernel.Activator;
+import org.argeo.cms.internal.runtime.CmsContextImpl;
import org.osgi.service.useradmin.Authorization;
/**
if (subject == null)
throw new IllegalArgumentException("Subject cannot be null");
if (subject.getPrincipals(X500Principal.class).size() != 1)
- return NodeConstants.ROLE_ANONYMOUS;
+ return CmsConstants.ROLE_ANONYMOUS;
Principal principal = subject.getPrincipals(X500Principal.class).iterator().next();
return principal.getName();
}
public final static Locale locale(Subject subject) {
Set<Locale> locales = subject.getPublicCredentials(Locale.class);
if (locales.isEmpty()) {
- Locale defaultLocale = Activator.getNodeState().getDefaultLocale();
+ Locale defaultLocale = CmsContextImpl.getCmsContext().getDefaultLocale();
return defaultLocale;
} else
return locales.iterator().next();
if (subject == null)
return true;
String username = getUsername(subject);
- return username == null || username.equalsIgnoreCase(NodeConstants.ROLE_ANONYMOUS);
+ return username == null || username.equalsIgnoreCase(CmsConstants.ROLE_ANONYMOUS);
}
- public CmsSession getCmsSession() {
+ public static CmsSession getCmsSession() {
Subject subject = currentSubject();
CmsSessionId cmsSessionId = subject.getPrivateCredentials(CmsSessionId.class).iterator().next();
return CmsSessionImpl.getByUuid(cmsSessionId.getUuid());
else
return false;
CmsSessionImpl cmsSession = CmsSessionImpl.getByUuid(nodeSessionId.toString());
- cmsSession.close();
+
+ // 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;