コード例 #1
0
  @Override
  public boolean canRead(Path itemPath, ItemId itemId) throws RepositoryException {

    if ((itemId != null && "cafebabe-cafe-babe-cafe-babecafebabe".equals(itemId.toString()))
        || (itemPath != null && "/".equals(itemPath.toString()))) {
      // quick check - allow access to root to all like in old mgnl security
      return true;
    }

    if (itemPath == null) {

      // we deal only with permissions on nodes
      if (!itemId.denotesNode()) {
        itemId = ((PropertyId) itemId).getParentId();
      }

      synchronized (monitor) {
        if (readCache.containsKey(itemId)) {
          return readCache.get(itemId);
        }

        itemPath = session.getHierarchyManager().getPath(itemId);
        boolean canRead = canRead(itemPath, itemId);
        readCache.put(itemId, canRead);
        return canRead;
      }
    }

    String path = pathResolver.getJCRPath(itemPath);
    log.debug("Read request for " + path + " :: " + itemId);
    return ami.isGranted(path, Permission.READ);
  }
コード例 #2
0
ファイル: ParsedFacet.java プロジェクト: srajeev/hippo
 public static final ParsedFacet getInstance(
     String facetNameConfig, String facetNodeName, HippoVirtualProvider provider)
     throws Exception {
   String cacheKey = facetNameConfig + '\uFFFF' + facetNodeName;
   ParsedFacet pf = sharedCache.get(cacheKey);
   if (pf == null) {
     pf = new ParsedFacet(facetNameConfig, facetNodeName, provider);
     sharedCache.put(cacheKey, pf);
   } else {
     // we need to check if the namespace did not bump or change. IF so, we evict this item from
     // cache.
     Path currentQName = provider.resolvePath(pf.jcrPropertyName);
     // if the currentQName is equal to pf.namespacedProperty , there was no namespace bumb and we
     // can return pf
     if (!currentQName.toString().equals(pf.namespacedProperty)) {
       pf = new ParsedFacet(facetNameConfig, facetNodeName, provider);
       sharedCache.put(cacheKey, pf);
     }
   }
   return pf;
 }
コード例 #3
0
ファイル: ParsedFacet.java プロジェクト: srajeev/hippo
 public ParsedFacet(String facetNameConfig, String facetNodeName, HippoVirtualProvider provider)
     throws Exception {
   displayFacetName = facetNameConfig;
   boolean mapped = false;
   // jcrPropertyName is format: prefix:localname
   jcrPropertyName = facetNameConfig;
   if (facetNodeName != null && !"".equals(facetNodeName)) {
     displayFacetName = facetNodeName;
     mapped = true;
   }
   if (facetNameConfig.indexOf("$[") > -1) {
     try {
       rangeConfig = facetNameConfig.substring(facetNameConfig.indexOf("$[") + 1);
       JSONArray jsonArray = JSONArray.fromObject(rangeConfig);
       facetRanges = (List<FacetRange>) JSONArray.toCollection(jsonArray, FacetRange.class);
       jcrPropertyName = facetNameConfig.substring(0, facetNameConfig.indexOf("$["));
       if (!mapped) {
         displayFacetName = jcrPropertyName;
       }
       validate(facetRanges);
     } catch (IllegalArgumentException e) {
       throw (e);
     } catch (Exception e) {
       throw new Exception(
           "Malformed facet range configuration '"
               + facetNameConfig
               + "'. Valid format is for example '"
               + VALID_RANGE_EXAMPLE
               + "'",
           e);
     }
   }
   Path qName = provider.resolvePath(jcrPropertyName);
   this.namespacedProperty = qName.toString();
   if (facetRanges != null) {
     for (FacetRange range : facetRanges) {
       range.setNamespacedProperty(namespacedProperty);
     }
   }
 }