Package com.getperka.flatpack.policy.pst

Examples of com.getperka.flatpack.policy.pst.ActionDefinition


    return;
  }

  void resolveSecurityAction(Ident<SecurityAction> x) {
    // Are we declaring a verb?
    ActionDefinition currentVerb = currentLocation(ActionDefinition.class);
    if (currentVerb != null) {
      SecurityAction a = SecurityAction.of(
          currentVerb.getName().getSimpleName(), x.getSimpleName());
      x.setReferent(a);
      return;
    }

    // Otherwise, it must be a verb reference
    if (x.isCompound()) {
      // *.*, Foo.*, or Foo.bar
      Ident<ActionDefinition> verbIdent = x.getCompoundName().get(0).cast(ActionDefinition.class);

      if (verbIdent.isWildcard()) {
        // Parser shouldn't allow *.foo, so we can ignore the second part
        x.setReferent(SecurityAction.all());
        return;
      }

      ActionDefinition verb = scope().get(verbIdent);
      if (verb == null) {
        error("Unknown verb: " + verbIdent.getSimpleName());
        return;
      }
      verbIdent.setReferent(verb);

      Ident<SecurityAction> actionIdent = x.getCompoundName().get(1).cast(SecurityAction.class);
      if (actionIdent.isWildcard()) {
        // Foo.*
        SecurityAction action = SecurityAction.of(verbIdent.getSimpleName(), "*");
        actionIdent.setReferent(action);
        x.setReferent(action);
      } else {
        // Find matching verb declaration, e.g. Foo.bar
        for (Ident<SecurityAction> action : verb.getActions()) {
          if (action.equals(x.getCompoundName().get(1))) {
            actionIdent.setReferent(action.getReferent());
            x.setReferent(action.getReferent());
            return;
          }
View Full Code Here


  private static class Cloner extends PolicyVisitor {
    private final Deque<Object> stack = new ArrayDeque<Object>();

    @Override
    public boolean visit(ActionDefinition x) {
      ActionDefinition n = new ActionDefinition();
      n.setActions(clone(x.getActions()));
      n.setName(clone(x.getName()));
      stack.push(n);
      return false;
    }
View Full Code Here

   * <pre>
   * verb name = action, anotherAction, ...;
   * </pre>
   */
  Rule ActionDef() {
    final Var<ActionDefinition> var = new Var<ActionDefinition>(new ActionDefinition());
    return Sequence(
        "action",
        NodeName(ActionDefinition.class, var),
        "=",
        OneOrListOf(Ident(SecurityAction.class), Ident.class, ","),
        ";",
        new Action<Object>() {
          @Override
          public boolean run(Context<Object> ctx) {
            ActionDefinition x = var.get();
            x.setActions(popIdentList(SecurityAction.class));
            push(x);
            return true;
          }
        });
  }
View Full Code Here

TOP

Related Classes of com.getperka.flatpack.policy.pst.ActionDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.