|| resourceTypesToExclude.size() == 0) {
val = Boolean.TRUE;
break;
}
int rtn = rs.getInt("resource_type");
ResourceType rt = getResourceType(rtn);
if (rt == null) {
log
.warn("Failed to locate resource type with ID of "
+ rtn
+ ". Its possible this was created by a plugin which is no longer available.");
} else {
if (!resourceTypesToExclude.contains(rt)) {
val = Boolean.TRUE;
break;
}
}
} else {
break;
}
}
// If the principal is a user, the get their roles and check
// those as well
if (val == null && principal instanceof User) {
// Now try roles
Role[] r = ((User) principal).getRoles();
if (r != null) {
for (int i = 0; val == null && i < r.length; i++) {
if (r[i] == null) {
log.warn("NULL role in principal "
+ principal.getPrincipalName());
continue;
}
ps.reset();
if (resourceRequired == null) {
ps = db
.getStatement("isPrincipalGranted.selectAny");
ps.setString(1, r[i].getPrincipalName());
ps.setInt(2, Policy.PRINCIPAL_GROUP);
ps.setInt(3, principal.getRealm().getResourceId());
} else {
ps = db
.getStatement("isPrincipalGranted.selectType");
ps.setInt(1, resourceRequired
.getResourceTypeId());
ps.setString(2, r[i].getPrincipalName());
ps.setInt(3, Policy.PRINCIPAL_GROUP);
ps.setInt(4, resourceRequired
.getResourceTypeId());
ps.setInt(5, principal.getRealm().getResourceId());
}
try {
rs = ps.executeQuery();
while (true) {
if (rs.next()) {
if (resourceTypesToExclude == null
|| resourceTypesToExclude
.size() == 0) {
val = Boolean.TRUE;
break;
}
int rtn = rs.getInt("resource_type");
ResourceType rt = getResourceType(rtn);
if (rt == null) {
log
.warn("Failed to locate resource type with ID of "
+ rtn
+ ". Its possible this was created by a plugin which is no longer available.");