@Test public void testHasPrincipal() { final Principal principal = mock(Principal.class); final Subject subject = new Subject(); subject.getPrincipals().add(principal); assertThat(Subject.doAs(subject, new PrivilegedAction<Boolean>() { @Override public Boolean run() { return JaasUtils.hasPrincipal(principal.getClass()); } })).isTrue(); assertThat(Subject.doAs(subject, new PrivilegedAction<Boolean>() { @Override public Boolean run() { return JaasUtils.hasPrincipal(MillenniumDomainPrincipal.class); } })).isFalse(); }
public static boolean hasPrincipal(final Class<? extends Principal> principalClass) { if (principalClass == null) throw new IllegalArgumentException("Principal class cannot be null."); return !getCurrentSubject().getPrincipals(principalClass).isEmpty(); }
JaasUtils { public static boolean hasPrincipal(final Class<? extends Principal> principalClass) { if (principalClass == null) throw new IllegalArgumentException("Principal class cannot be null."); return !getCurrentSubject().getPrincipals(principalClass).isEmpty(); } }
JaasUtils { public static boolean hasPrincipal(final Class<? extends Principal> principalClass) { if (principalClass == null) throw new IllegalArgumentException("Principal class cannot be null."); return !getCurrentSubject().getPrincipals(principalClass).isEmpty(); }  }
JaasUtils { public static boolean hasPrincipal(final Class<? extends Principal> principalClass) { if (principalClass == null) throw new IllegalArgumentException("Principal class cannot be null."); return !getCurrentSubject().getPrincipals(principalClass).isEmpty(); }  static Subject getCurrentSubject(); static P getPrincipal(final Class<P> principalClass); static T getPrivateCredential(final Class<T> credentialClass); static boolean hasPrincipal(final Class<? extends Principal> principalClass); }
JaasUtils { public static boolean hasPrincipal(final Class<? extends Principal> principalClass) { if (principalClass == null) throw new IllegalArgumentException("Principal class cannot be null."); return !getCurrentSubject().getPrincipals(principalClass).isEmpty(); }  static Subject getCurrentSubject(); static P getPrincipal(final Class<P> principalClass); static T getPrivateCredential(final Class<T> credentialClass); static boolean hasPrincipal(final Class<? extends Principal> principalClass);  }