NIHVIVO-3523 Protect against null arguments.
This commit is contained in:
parent
a75b15d940
commit
9d74b4e41a
1 changed files with 13 additions and 2 deletions
|
@ -19,14 +19,25 @@ public class PermissionsPolicy implements PolicyIface {
|
||||||
@Override
|
@Override
|
||||||
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
public PolicyDecision isAuthorized(IdentifierBundle whoToAuth,
|
||||||
RequestedAction whatToAuth) {
|
RequestedAction whatToAuth) {
|
||||||
|
if (whoToAuth == null) {
|
||||||
|
return defaultDecision("whomToAuth was null");
|
||||||
|
}
|
||||||
|
if (whatToAuth == null) {
|
||||||
|
return defaultDecision("whatToAuth was null");
|
||||||
|
}
|
||||||
|
|
||||||
for (Permission p : HasPermission.getPermissions(whoToAuth)) {
|
for (Permission p : HasPermission.getPermissions(whoToAuth)) {
|
||||||
if (p.isAuthorized(whatToAuth)) {
|
if (p.isAuthorized(whatToAuth)) {
|
||||||
return new BasicPolicyDecision(Authorization.AUTHORIZED,
|
return new BasicPolicyDecision(Authorization.AUTHORIZED,
|
||||||
"PermissionsPolicy: approved by " + p);
|
"PermissionsPolicy: approved by " + p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new BasicPolicyDecision(Authorization.INCONCLUSIVE,
|
return defaultDecision("no permission will approve " + whatToAuth);
|
||||||
"no permission will approve " + whatToAuth);
|
}
|
||||||
|
|
||||||
|
/** If the user isn't explicitly authorized, return this. */
|
||||||
|
private PolicyDecision defaultDecision(String message) {
|
||||||
|
return new BasicPolicyDecision(Authorization.INCONCLUSIVE, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue