if (subject == null) {
// Set principals = Collections.EMPTY_SET;
} else if (realm != null) {
Set principals = subject.getPrincipals(RealmPrincipal.class);
for (Iterator iter = principals.iterator(); iter.hasNext();) {
RealmPrincipal p = (RealmPrincipal) iter.next();
if (p.getRealm().equals(realm) && p.getLoginDomain().equals(domain) && p.getPrincipal().getClass().equals(principalClass)) {
principalName = p.getPrincipal().getName();
if (p instanceof PrimaryRealmPrincipal) break;
}
}
} else if (domain != null) {
Set principals = subject.getPrincipals(DomainPrincipal.class);
for (Iterator iter = principals.iterator(); iter.hasNext();) {
DomainPrincipal p = (DomainPrincipal) iter.next();
if (p.getDomain().equals(domain) && p.getPrincipal().getClass().equals(principalClass)) {
principalName = p.getPrincipal().getName();
if (p instanceof PrimaryDomainPrincipal) break;
}
}
} else {
Set principals = subject.getPrincipals(principalClass);