Examples of Restriction


Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction

    /**
     * @since OAK 1.0: support for multi-value restrictions
     */
    @Test
    public void testGetNonExistingRestrictions() throws Exception {
        Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
        ACE ace = createEntry(ImmutableSet.of(nameRestr));
        assertNull(ace.getRestrictions(AccessControlConstants.REP_GLOB));
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction

     * @since OAK 1.0: support for multi-value restrictions
     */
    @Test
    public void testGetRestrictionsForSingleValue() throws Exception {
        // single valued restriction
        Restriction globRestr = createRestriction(AccessControlConstants.REP_GLOB, globValue);
        ACE ace = createEntry(ImmutableSet.of(globRestr));
        Value[] vs = ace.getRestrictions(AccessControlConstants.REP_GLOB);
        assertNotNull(vs);
        assertArrayEquals(new Value[] {globValue}, vs);
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction

     * @since OAK 1.0: support for multi-value restrictions
     */
    @Test
    public void testGetRestrictionsForMultiValued() throws Exception {
        // multivalued restriction
        Restriction nameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, nameValues);
        ACE ace = createEntry(ImmutableSet.of(nameRestr));
        Value[] vs = ace.getRestrictions(AccessControlConstants.REP_NT_NAMES);
        assertEquals(2, vs.length);
        assertArrayEquals(nameValues, vs);
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction

     * @since OAK 1.0: support for multi-value restrictions
     */
    @Test
    public void testGetRestrictionsForMultiValued2() throws Exception {
        // single value restriction stored in multi-value property
        Restriction singleNameRestr = createRestriction(AccessControlConstants.REP_NT_NAMES, new Value[] {nameValue});
        ACE ace = createEntry(ImmutableSet.of(singleNameRestr));
        Value[] vs = ace.getRestrictions(AccessControlConstants.REP_NT_NAMES);
        assertEquals(1, vs.length);
        assertEquals(nameValue, vs[0]);
    }
View Full Code Here

Examples of org.apache.jackrabbit.oak.spi.security.authorization.restriction.Restriction

    @Override
    public void writeRestrictions(String oakPath, Tree aceTree, Set<Restriction> restrictions) throws AccessControlException {
        Iterator<Restriction> it = Sets.newHashSet(restrictions).iterator();
        while (it.hasNext()) {
            Restriction r = it.next();
            if (REP_NODE_PATH.equals(r.getName())) {
                it.remove();
            }
        }
        base.writeRestrictions(oakPath, aceTree, restrictions);
    }
View Full Code Here

Examples of org.apache.maven.artifact.versioning.Restriction

        if ( recommendedVersion == null )
        {

            for ( Iterator i = allowedRange.getRestrictions().iterator(); i.hasNext() && !matched; )
            {
                Restriction restriction = (Restriction) i.next();
                if ( restriction.containsVersion( theVersion ) )
                {
                    matched = true;
                }
            }
        }
View Full Code Here

Examples of org.beangle.ems.security.restrict.Restriction

    RestrictionHolder<?> userHolder = user;
    restrictions.addAll(userHolder.getRestrictions());
    // 实体过滤
    return (List<Restriction>) CollectionUtils.select(restrictions, new Predicate() {
      public boolean evaluate(Object obj) {
        Restriction restriciton = (Restriction) obj;
        if (restriciton.isEnabled() && entities.contains(restriciton.getPattern().getEntity())) return true;
        else return false;
      }
    });
  }
View Full Code Here

Examples of org.beangle.ems.security.restrict.Restriction

  /**
   * 删除数据限制权限
   */
  public String remove() {
    Restriction restriction = getRestriction();
    RestrictionHolder<Restriction> holer = new RestrictionHelper(entityDao).getHolder();
    holer.getRestrictions().remove(restriction);
    entityDao.remove(restriction);
    entityDao.saveOrUpdate(holer);
    return redirect("info", "info.remove.success");
View Full Code Here

Examples of org.beangle.ems.security.restrict.Restriction

    helper.populateInfo(helper.getHolder());
    return forward();
  }

  public String save() {
    Restriction restriction = getRestriction();
    RestrictionHolder<Restriction> holder = new RestrictionHelper(entityDao).getHolder();
    List<Restriction> myRestrictions = getMyRestrictions(restriction.getPattern(), holder);
    Set<RestrictField> ignoreFields = getIgnoreFields(myRestrictions);
    boolean isAdmin = isAdmin();
    for (final RestrictField field : restriction.getPattern().getEntity().getFields()) {
      String[] values = (String[]) getAll(field.getName());
      if ((ignoreFields.contains(field) || isAdmin) && getBool("ignoreField" + field.getId())) {
        restriction.setItem(field, "*");
      } else {
        if (null == values || values.length == 0) {
          restriction.getItems().remove(field.getId());
        } else {
          String storedValue = null;
          if (null != field.getKeyName()) {
            final Set<String> keys = CollectUtils.newHashSet(values);
            Collection<?> allValues = restrictionService.getFieldValues(field.getName());
            allValues = CollectionUtils.select(allValues, new Predicate() {
              public boolean evaluate(Object arg0) {
                try {
                  String keyValue = String.valueOf(PropertyUtils.getProperty(arg0,
                      field.getKeyName()));
                  return keys.contains(keyValue);
                } catch (Exception e) {
                  e.printStackTrace();
                }
                return false;
              }
            });
            storedValue = idDataResolver.marshal(field, allValues);
          } else {
            storedValue = StrUtils.join(values);
          }
          restriction.setItem(field, storedValue);
        }
      }
    }
    if (restriction.getItems().isEmpty()) {
      holder.getRestrictions().remove(restriction);
      if (restriction.isPersisted()) entityDao.remove(restriction);
      entityDao.saveOrUpdate(holder);
      return redirect("info", "info.save.success");
    } else {
      if (!restriction.isPersisted()) {
        holder.getRestrictions().add(restriction);
        entityDao.saveOrUpdate(holder);
      } else {
        entityDao.saveOrUpdate(
            (String) RestrictionHelper.restrictionTypeMap.get(get("restrictionType")),
View Full Code Here

Examples of org.beangle.ems.security.restrict.Restriction

  /**
   * 编辑权限<br>
   */
  public String edit() {
    // 取得各参数的值
    Restriction restriction = getRestriction();
    boolean isAdmin = isAdmin();
    Map<String, Object> mngFields = CollectUtils.newHashMap();
    Map<String, Object> aoFields = CollectUtils.newHashMap();
    List<Restriction> myRestricitons = getMyRestrictions(restriction.getPattern(),
        restriction.getHolder());
    Set<RestrictField> ignores = getIgnoreFields(myRestricitons);
    put("ignoreFields", ignores);
    Set<RestrictField> holderIgnoreFields = CollectUtils.newHashSet();
    put("holderIgnoreFields", holderIgnoreFields);
    for (RestrictField field : restriction.getPattern().getEntity().getFields()) {
      List<?> mngField = restrictionService.getFieldValues(field.getName());
      if (!isAdmin) {
        mngField.retainAll(getMyRestrictionValues(myRestricitons, field.getName()));
      } else {
        ignores.add(field);
      }
      String fieldValue = restriction.getItem(field);
      if ("*".equals(fieldValue)) {
        holderIgnoreFields.add(field);
      }
      mngFields.put(field.getName(), mngField);
      if (null == field.getSource()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.