made things a little null safer

closes #813 (really)
pull/820/merge
Justin Richer 2015-07-03 17:24:03 -04:00
parent 8086cc9153
commit aa96b1f1ed
2 changed files with 7 additions and 2 deletions

View File

@ -17,6 +17,7 @@
package org.mitre.uma.model; package org.mitre.uma.model;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet;
import java.util.Set; import java.util.Set;
import javax.persistence.Basic; import javax.persistence.Basic;
@ -53,13 +54,13 @@ public class ResourceSet {
private String name; private String name;
private String uri; private String uri;
private String type; private String type;
private Set<String> scopes; private Set<String> scopes = new HashSet<>();
private String iconUri; private String iconUri;
private String owner; // username of the person responsible for the registration (either directly or via OAuth token) private String owner; // username of the person responsible for the registration (either directly or via OAuth token)
private String clientId; // client id of the protected resource that registered this resource set via OAuth token private String clientId; // client id of the protected resource that registered this resource set via OAuth token
private Collection<Policy> policies; private Collection<Policy> policies = new HashSet<>();
/** /**
* @return the id * @return the id

View File

@ -103,6 +103,10 @@ public class DefaultResourceSetService implements ResourceSetService {
} }
private boolean checkScopeConsistency(ResourceSet rs) { private boolean checkScopeConsistency(ResourceSet rs) {
if (rs.getPolicies() == null) {
// nothing to check, no problem!
return true;
}
for (Policy policy : rs.getPolicies()) { for (Policy policy : rs.getPolicies()) {
if (!rs.getScopes().containsAll(policy.getScopes())) { if (!rs.getScopes().containsAll(policy.getScopes())) {
return false; return false;