return getDisplayName(currentSubject());
}
+ public static boolean isAnonymous() {
+ return isAnonymous(currentSubject());
+ }
+
+ public static boolean isAnonymous(Subject subject) {
+ String username = getUsername(subject);
+ return username == null
+ || username.equalsIgnoreCase(AuthConstants.ROLE_ANONYMOUS);
+ }
+
private static Subject currentSubject() {
+ CmsView cmsView = CmsUtils.getCmsView();
+ if (cmsView != null)
+ return cmsView.getSubject();
Subject subject = Subject.getSubject(AccessController.getContext());
if (subject != null)
return subject;
- if (subject == null) {
- CmsView cmsView = CmsUtils.getCmsView();
- if (cmsView != null)
- return cmsView.getSubject();
- }
throw new CmsException("Cannot find related subject");
}