protected boolean matchGroupPrincipal(List<Principal> groupPrincipals, String userRole) {
    boolean res = false;

    {
      if (groupPrincipals != null) {
        if (userRole != null) {
          for (Principal groupPrincipal : groupPrincipals) {
            if (groupPrincipal instanceof DistinguishedNamePrincipal) {
              DistinguishedNamePrincipal p = (DistinguishedNamePrincipal) groupPrincipal;

              res = matchGroupPrincipal(p, userRole);
            } else {
              if (groupPrincipal instanceof CommonNamePrincipal) {
                CommonNamePrincipal p = (CommonNamePrincipal) groupPrincipal;

                res = matchGroupPrincipal(p, userRole);
              } else {
                String name = groupPrincipal.getName();
                if (name.equals(userRole)) {
                  res = true;
                }
              }
            }

            if (res) // if a match has been found...
            {
              break; // stop loop
            }
          }
        }
      }
    }

    return res;
  }
Exemple #2
0
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj instanceof MockX509Certificate)
     return subject.equals(((MockX509Certificate) obj).subject)
         && issuer.equals(((MockX509Certificate) obj).issuer);
   return false;
 }
Exemple #3
0
 public String toString() {
   return subject.toString();
 }
Exemple #4
0
 public int hashCode() {
   return subject.hashCode() + issuer.hashCode();
 }