/** * Returns true if the role has the specified sub role name. * * @param roleName The name of the role to check for. */ @Override public boolean hasRole(String roleName) { boolean hasRole = false; if (this.roles != null) { // Lets check the "local" roles first. for (Role role : this.roles) { hasRole = role.getId().equals(roleName); if (hasRole) break; } // Then we check the sub roles if no match has been found. if (!hasRole) { for (Role role : this.roles) { hasRole = role.hasRole(roleName); if (hasRole) break; } } } return hasRole; }