コード例 #1
0
  @Before
  public void setup() {
    // ACEs from groups contained in config

    aceBean1 = new AceBean();
    aceBean1.setPrincipal("group-A");
    aceBean1.setActions(null);
    aceBean1.setActionsStringFromConfig("");
    aceBean1.setPermission("deny");
    aceBean1.setJcrPath("/content");
    aceBean1.setPrivilegesString("jcr:read,crx:replicate");
    aceBean1.setRepGlob("");

    aceBean2 = new AceBean();
    aceBean2.setPrincipal("group-A");
    aceBean2.setActions(new String[] {"read", "replicate"});
    aceBean1.setPermission("deny");
    aceBean2.setJcrPath("/content");
    aceBean2.setPrivilegesString("");
    aceBean2.setRepGlob("");

    aceBean3 = new AceBean();
  }
コード例 #2
0
  public boolean validateActions(final AceBean tmpAclBean)
      throws InvalidActionException, TooManyActionsException, DoubledDefinedActionException {
    String principal = tmpAclBean.getPrincipalName();

    if (!StringUtils.isNotBlank(tmpAclBean.getActionsStringFromConfig())) {
      return false;
    }

    String[] actions = tmpAclBean.getActionsStringFromConfig().split(",");

    if (actions.length > CqActionsMapping.ACTIONS_MAP.size()) {
      String errorMessage =
          getBeanDescription(this.currentBeanCounter, principal) + " too many actions defined!";
      LOG.error(errorMessage);
      throw new TooManyActionsException(errorMessage);
    }
    Set<String> actionsSet = new HashSet<String>();
    for (int i = 0; i < actions.length; i++) {

      // remove leading and trailing blanks from action name
      actions[i] = StringUtils.strip(actions[i]);

      if (!Validators.isValidAction(actions[i])) {
        String errorMessage =
            getBeanDescription(this.currentBeanCounter, principal)
                + ", invalid action: "
                + actions[i];
        LOG.error(errorMessage);
        throw new InvalidActionException(errorMessage);
      }
      if (!actionsSet.add(actions[i])) {
        String errorMessage =
            getBeanDescription(this.currentBeanCounter, principal)
                + ", doubled defined action: "
                + actions[i];
        LOG.error(errorMessage);
        throw new DoubledDefinedActionException(errorMessage);
      }
    }
    tmpAclBean.setActions(actions);

    return true;
  }