Add server context to getPermissionValue calls.

This commit is contained in:
bloodshot 2020-01-01 16:34:01 -05:00
parent 1ac3ad932e
commit cccb3c79d5
2 changed files with 18 additions and 4 deletions

View File

@ -567,7 +567,9 @@ public Set<Context> getGPContexts(ContextSet contextSet) {
}
public Tristate getPermissionValue(GDPermissionHolder holder, String permission) {
ImmutableContextSet set = ImmutableContextSet.empty();
final Set<Context> contexts = new HashSet<>();
this.checkServerContext(contexts);
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, set);
}
@ -578,13 +580,16 @@ public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, Str
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, claim);
return this.getPermissionValue(holder, permission, contexts);
this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet);
}
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts, boolean checkTransient) {
final Set<Context> activeContexts = new HashSet<>();
this.addActiveContexts(activeContexts, holder, null, claim);
contexts.addAll(activeContexts);
this.checkServerContext(contexts);
final int contextHash = Objects.hash(claim, holder, permission, contexts);
final Cache<Integer, Tristate> cache = PermissionHolderCache.getInstance().getOrCreatePermissionCache(holder);
Tristate result = cache.getIfPresent(contextHash);
@ -687,6 +692,8 @@ public Tristate getPermissionValueWithRequiredContexts(GDClaim claim, GDPermissi
}
public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, null);
this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet);
}

View File

@ -563,7 +563,9 @@ public Set<Context> getGPContexts(ContextSet contextSet) {
}
public Tristate getPermissionValue(GDPermissionHolder holder, String permission) {
ImmutableContextSet set = ImmutableContextSet.empty();
final Set<Context> contexts = new HashSet<>();
this.checkServerContext(contexts);
ImmutableContextSet set = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, set);
}
@ -574,13 +576,16 @@ public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, Str
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, claim);
return this.getPermissionValue(holder, permission, contexts);
this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet);
}
public Tristate getPermissionValue(GDClaim claim, GDPermissionHolder holder, String permission, Set<Context> contexts, boolean checkTransient) {
final Set<Context> activeContexts = new HashSet<>();
this.addActiveContexts(activeContexts, holder, null, claim);
contexts.addAll(activeContexts);
this.checkServerContext(contexts);
final int contextHash = Objects.hash(claim, holder, permission, contexts);
final Cache<Integer, Tristate> cache = PermissionHolderCache.getInstance().getOrCreatePermissionCache(holder);
Tristate result = cache.getIfPresent(contextHash);
@ -683,6 +688,8 @@ public Tristate getPermissionValueWithRequiredContexts(GDClaim claim, GDPermissi
}
public Tristate getPermissionValue(GDPermissionHolder holder, String permission, Set<Context> contexts) {
this.addActiveContexts(contexts, holder, null, null);
this.checkServerContext(contexts);
ImmutableContextSet contextSet = this.getLPContexts(contexts).immutableCopy();
return this.getPermissionValue(holder, permission, contextSet);
}