+ private static void checkSubjectEmpty(Subject subject) {
+ if (!subject.getPrincipals(AnonymousPrincipal.class).isEmpty())
+ throw new IllegalStateException("Already logged in as anonymous: " + subject);
+ if (!subject.getPrincipals(X500Principal.class).isEmpty())
+ throw new IllegalStateException("Already logged in as user: " + subject);
+ if (!subject.getPrincipals(DataAdminPrincipal.class).isEmpty())
+ throw new IllegalStateException("Already logged in as data admin: " + subject);
+ if (!subject.getPrincipals(ImpliedByPrincipal.class).isEmpty())
+ throw new IllegalStateException("Already authorized: " + subject);
+ }
+