Skip to content

Commit

Permalink
fix explain algorithm (#159)
Browse files Browse the repository at this point in the history
* fic explain and change format

* update path

* before changing references of modifiers to modification

* add explain to pdp

* move modifiers to base pap package

* add test if explain is false
  • Loading branch information
joshua-roberts authored Aug 30, 2024
1 parent 04fdd91 commit 4c423f6
Show file tree
Hide file tree
Showing 112 changed files with 1,280 additions and 872 deletions.
376 changes: 189 additions & 187 deletions src/main/java/gov/nist/csd/pm/impl/memory/pap/MemoryAccessQuerier.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.impl.memory.pap.store.MemoryPolicyStore;
import gov.nist.csd.pm.pap.PAP;
import gov.nist.csd.pm.pap.query.PolicyQuerier;
import gov.nist.csd.pm.pap.PolicyQuerier;

public class MemoryPAP extends PAP {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package gov.nist.csd.pm.impl.memory.pap;

import gov.nist.csd.pm.pap.query.*;
import gov.nist.csd.pm.pap.PolicyQuerier;
import gov.nist.csd.pm.pap.store.PolicyStore;

public class MemoryPolicyQuerier extends PolicyQuerier {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.query.AccessQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

public abstract class AccessQuerier extends Querier implements AccessQuery{
public abstract class AccessQuerier extends Querier implements AccessQuery {

public AccessQuerier(PolicyStore store) {
super(store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.graph.dag.TargetDagResult;
import gov.nist.csd.pm.pap.graph.dag.UserDagResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.graph.dag.Direction;
import gov.nist.csd.pm.pap.graph.node.Node;
import gov.nist.csd.pm.pap.graph.node.NodeType;
import gov.nist.csd.pm.pap.graph.relationship.Assignment;
import gov.nist.csd.pm.pap.graph.relationship.Association;
import gov.nist.csd.pm.pap.modification.GraphModification;
import gov.nist.csd.pm.pap.obligation.EventPattern;
import gov.nist.csd.pm.pap.obligation.Obligation;
import gov.nist.csd.pm.pap.obligation.Rule;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.graph.node.Node;
import gov.nist.csd.pm.pap.graph.node.NodeType;
import gov.nist.csd.pm.pap.graph.relationship.Association;
import gov.nist.csd.pm.pap.exception.NodeDoesNotExistException;
import gov.nist.csd.pm.pap.query.GraphQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

import java.util.Collection;
import java.util.Map;

public class GraphQuerier extends Querier implements GraphQuery{
public class GraphQuerier extends Querier implements GraphQuery {

public GraphQuerier(PolicyStore store) {
super(store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.tx.Transactional;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.modification.ObligationsModification;
import gov.nist.csd.pm.pap.obligation.EventPattern;
import gov.nist.csd.pm.pap.obligation.Rule;
import gov.nist.csd.pm.pap.pml.pattern.Pattern;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.obligation.Obligation;
import gov.nist.csd.pm.pap.exception.ObligationDoesNotExistException;
import gov.nist.csd.pm.pap.query.ObligationsQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ObligationsQuerier extends Querier implements ObligationsQuery{
public class ObligationsQuerier extends Querier implements ObligationsQuery {

public ObligationsQuerier(PolicyStore store) {
super(store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.graph.relationship.AccessRightSet;
import gov.nist.csd.pm.pap.exception.AdminAccessRightExistsException;
import gov.nist.csd.pm.pap.exception.OperationExistsException;
import gov.nist.csd.pm.pap.modification.OperationsModification;
import gov.nist.csd.pm.pap.op.AdminOperations;
import gov.nist.csd.pm.pap.op.Operation;
import gov.nist.csd.pm.pap.store.PolicyStore;

import static gov.nist.csd.pm.pap.op.AdminAccessRights.isAdminAccessRight;
import static gov.nist.csd.pm.pap.op.AdminAccessRights.isWildcardAccessRight;

public class OperationsModifier extends Modifier implements OperationsModification{
public class OperationsModifier extends Modifier implements OperationsModification {

public OperationsModifier(PolicyStore store) throws PMException {
super(store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.graph.relationship.AccessRightSet;
import gov.nist.csd.pm.pap.exception.OperationDoesNotExistException;
import gov.nist.csd.pm.pap.op.Operation;
import gov.nist.csd.pm.pap.query.OperationsQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

import java.util.*;

public class OperationsQuerier extends Querier implements OperationsQuery{
public class OperationsQuerier extends Querier implements OperationsQuery {

public OperationsQuerier(PolicyStore store) {
super(store);
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/gov/nist/csd/pm/pap/PAP.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
import gov.nist.csd.pm.pap.admin.AdminPolicy;
import gov.nist.csd.pm.pap.executable.AdminExecutable;
import gov.nist.csd.pm.pap.executable.AdminExecutor;
import gov.nist.csd.pm.pap.modification.PolicyModifier;
import gov.nist.csd.pm.pap.modification.PolicyModification;
import gov.nist.csd.pm.pap.pml.PMLCompiler;
import gov.nist.csd.pm.pap.pml.context.ExecutionContext;
import gov.nist.csd.pm.pap.pml.executable.operation.PMLOperation;
import gov.nist.csd.pm.pap.pml.executable.routine.PMLRoutine;
import gov.nist.csd.pm.pap.pml.statement.PMLStatement;
import gov.nist.csd.pm.pap.pml.value.Value;
import gov.nist.csd.pm.pap.query.PolicyQuerier;
import gov.nist.csd.pm.pap.query.PolicyQuery;
import gov.nist.csd.pm.pap.query.UserContext;
import gov.nist.csd.pm.pap.serialization.PolicyDeserializer;
import gov.nist.csd.pm.pap.serialization.PolicySerializer;
import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.query.UserContext;
import gov.nist.csd.pm.pap.store.PolicyStore;
import gov.nist.csd.pm.pap.tx.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract class PAP implements PolicyPoint, AdminExecutor {
public abstract class PAP implements AdminExecutor, Transactional {

protected final PolicyStore policyStore;
private final PolicyModifier modifier;
Expand All @@ -44,17 +45,16 @@ public PAP(PAP pap) throws PMException {
this(pap.policyStore);
}

public abstract PolicyQuerier query();

public PolicyModifier modify() {
return modifier;
public PolicyStore policyStore() {
return policyStore;
}

protected PolicyStore policyStore() {
return policyStore;
public abstract PolicyQuery query();

public PolicyModification modify() {
return modifier;
}

@Override
public void reset() throws PMException {
policyStore.reset();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.admin.AdminPolicy;
import gov.nist.csd.pm.pap.admin.AdminPolicyNode;
import gov.nist.csd.pm.pap.modification.PolicyModification;
import gov.nist.csd.pm.pap.store.PolicyStore;

import static gov.nist.csd.pm.pap.graph.node.NodeType.OA;
Expand All @@ -28,10 +29,6 @@ public PolicyModifier(PolicyStore store) throws PMException {
this.routinesModifier = new RoutinesModifier(store);
}

public PolicyModifier(PolicyModifier modifier) throws PMException {
this(modifier.store);
}

@Override
public GraphModifier graph() {
return graphModifier;
Expand Down
56 changes: 0 additions & 56 deletions src/main/java/gov/nist/csd/pm/pap/PolicyPoint.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.query.PolicyQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

public abstract class PolicyQuerier extends Querier implements PolicyQuery {
Expand All @@ -20,10 +21,6 @@ public PolicyQuerier(PolicyStore store) {
this.routinesQuerier = new RoutinesQuerier(store);
}

public PolicyQuerier(Querier querier) {
this(querier.store);
}

@Override
public abstract AccessQuerier access();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.modification.ProhibitionsModification;
import gov.nist.csd.pm.pap.prohibition.ContainerCondition;
import gov.nist.csd.pm.pap.prohibition.ProhibitionSubject;
import gov.nist.csd.pm.pap.exception.ProhibitionContainerDoesNotExistException;
Expand All @@ -12,7 +13,7 @@
import java.util.ArrayList;
import java.util.Collection;

import static gov.nist.csd.pm.pap.modification.GraphModifier.checkAccessRightsValid;
import static gov.nist.csd.pm.pap.GraphModifier.checkAccessRightsValid;

public class ProhibitionsModifier extends Modifier implements ProhibitionsModification {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.graph.dag.DepthFirstGraphWalker;
import gov.nist.csd.pm.pap.graph.dag.Direction;
import gov.nist.csd.pm.pap.prohibition.ContainerCondition;
import gov.nist.csd.pm.pap.prohibition.Prohibition;
import gov.nist.csd.pm.pap.exception.ProhibitionDoesNotExistException;
import gov.nist.csd.pm.pap.query.ProhibitionsQuery;
import gov.nist.csd.pm.pap.store.PolicyStore;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.store.PolicyStore;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package gov.nist.csd.pm.pap.modification;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.exception.RoutineExistsException;
import gov.nist.csd.pm.pap.modification.RoutinesModification;
import gov.nist.csd.pm.pap.routine.Routine;
import gov.nist.csd.pm.pap.store.PolicyStore;

public class RoutinesModifier extends Modifier implements RoutinesModification{
public class RoutinesModifier extends Modifier implements RoutinesModification {

public RoutinesModifier(PolicyStore store) {
super(store);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package gov.nist.csd.pm.pap.query;
package gov.nist.csd.pm.pap;

import gov.nist.csd.pm.pap.exception.PMException;
import gov.nist.csd.pm.pap.exception.RoutineDoesNotExistException;
import gov.nist.csd.pm.pap.query.RoutinesQuery;
import gov.nist.csd.pm.pap.routine.Routine;
import gov.nist.csd.pm.pap.store.PolicyStore;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.nist.csd.pm.pap.graph.dag;

import gov.nist.csd.pm.pap.exception.PMException;

public class AllPathsShortCircuit implements ShortCircuit{

private boolean s;
Expand All @@ -11,7 +13,7 @@ public AllPathsShortCircuit(ShortCircuit shortCircuit) {
}

@Override
public boolean evaluate(String node) {
public boolean evaluate(String node) throws PMException {
boolean e = this.shortCircuit.evaluate(node);
if (!s) {
s = e;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package gov.nist.csd.pm.pap.graph.dag;

import gov.nist.csd.pm.pap.exception.PMException;

public interface ShortCircuit {

boolean evaluate(String node);
boolean evaluate(String node) throws PMException;

}
Loading

0 comments on commit 4c423f6

Please sign in to comment.