in hawtio-system/src/main/java/io/hawt/system/Authenticator.java [251:283]
private boolean checkIfSubjectHasRequiredRole(Subject subject,
String role, String rolePrincipalClasses) {
String[] roleArray = role.split(",");
String[] rolePrincipalClazzes = rolePrincipalClasses.split(",");
boolean found = false;
for (String clazz : rolePrincipalClazzes) {
LOG.debug("Looking for rolePrincipalClass: {}", clazz);
for (Principal p : subject.getPrincipals()) {
LOG.debug("Checking principal, classname: {} toString: {}", p.getClass().getName(), p);
if (!p.getClass().getName().equals(clazz.trim())) {
LOG.debug("principal class {} doesn't match {}, continuing", p.getClass().getName(), clazz.trim());
continue;
}
for (String r : roleArray) {
if (r == null || !p.getName().equals(r.trim())) {
LOG.debug("role {} doesn't match {}, continuing", p.getName(), r);
continue;
}
LOG.debug("Matched role and role principal class");
found = true;
break;
}
if (found) {
break;
}
}
if (found) {
break;
}
}
return found;
}