Exemple #1
0
  /**
   * Create an instance of the SecuredGraph
   *
   * @param securityEvaluator The security evaluator to use
   * @param graphIRI The IRI for the graph.
   * @param graph The graph that we are wrapping.
   * @return the secured graph
   */
  public static SecuredGraph getInstance(
      final SecurityEvaluator securityEvaluator, final String graphIRI, final Graph graph) {

    final ItemHolder<Graph, SecuredGraphImpl> holder =
        new ItemHolder<Graph, SecuredGraphImpl>(graph);
    final SecuredGraphImpl checker = new SecuredGraphImpl(securityEvaluator, graphIRI, holder) {};

    // If we going to create a duplicate proxy return this one.
    if (graph instanceof SecuredGraphImpl) {
      if (checker.isEquivalent((SecuredGraphImpl) graph)) {
        return (SecuredGraph) graph;
      }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(graph.getClass(), checker));
  }
Exemple #2
0
  /**
   * Create an instance of SecuredPrefixMapping
   *
   * @param graph The SecuredGraph that contains the prefixmapping.
   * @param prefixMapping The prefixmapping returned from the base graph.
   * @return The SecuredPrefixMapping.
   */
  static SecuredPrefixMapping getInstance(
      final SecuredGraphImpl graph, final PrefixMapping prefixMapping) {

    final ItemHolder<PrefixMapping, SecuredPrefixMapping> holder =
        new ItemHolder<PrefixMapping, SecuredPrefixMapping>(prefixMapping);
    final SecuredPrefixMappingImpl checker = new SecuredPrefixMappingImpl(graph, holder);
    // if we are going to create a duplicate proxy just return this one.
    if (prefixMapping instanceof SecuredPrefixMapping) {
      if (checker.isEquivalent((SecuredPrefixMapping) prefixMapping)) {
        return (SecuredPrefixMapping) prefixMapping;
      }
    }

    return holder.setSecuredItem(new SecuredItemInvoker(prefixMapping.getClass(), checker));
  }
Exemple #3
0
  /**
   * Create an instance of the SecuredBulkUpdateHandler
   *
   * @param graph The SecuredGraph that created the handler
   * @param handler The unsecured handler from the base graph.
   * @return SecuredBulkUpdateHandler.
   */
  static SecuredBulkUpdateHandler getInstance(
      final SecuredGraphImpl graph, final Graph baseGraph, final BulkUpdateHandler handler) {
    final ItemHolder<BulkUpdateHandler, SecuredBulkUpdateHandler> holder =
        new ItemHolder<BulkUpdateHandler, SecuredBulkUpdateHandler>(handler);

    final SecuredBulkUpdateHandlerImpl checker =
        new SecuredBulkUpdateHandlerImpl(graph, baseGraph, holder);

    // if we are going to create a duplicate proxy, just return this
    // one.
    if (handler instanceof SecuredBulkUpdateHandler) {
      if (checker.isEquivalent((SecuredBulkUpdateHandler) handler)) {
        return (SecuredBulkUpdateHandler) handler;
      }
    }

    return holder.setSecuredItem(new SecuredItemInvoker(handler.getClass(), checker));
  }
Exemple #4
0
  @Override
  public SecuredPrefixMapping withDefaultMappings(final PrefixMapping map) {
    // mapping only updates if there are map entries to add.  Since this gets called
    // when we are doing deep triple checks while writing we need to attempt the
    // update only if there are new updates to add.

    PrefixMapping m = holder.getBaseItem();
    PrefixMappingImpl pm = new PrefixMappingImpl();
    for (Entry<String, String> e : map.getNsPrefixMap().entrySet()) {
      if (m.getNsPrefixURI(e.getKey()) == null && m.getNsURIPrefix(e.getValue()) == null) {
        pm.setNsPrefix(e.getKey(), e.getValue());
      }
    }
    if (!pm.getNsPrefixMap().isEmpty()) {
      checkUpdate();
      holder.getBaseItem().withDefaultMappings(pm);
    }
    return holder.getSecuredItem();
  }
Exemple #5
0
 @Override
 public SecuredPrefixMapping setNsPrefix(final String prefix, final String uri) {
   checkUpdate();
   holder.getBaseItem().setNsPrefix(prefix, uri);
   return holder.getSecuredItem();
 }
Exemple #6
0
 @Override
 public boolean samePrefixMappingAs(final PrefixMapping other) {
   checkRead();
   return holder.getBaseItem().samePrefixMappingAs(other);
 }
Exemple #7
0
 @Override
 public SecuredPrefixMapping removeNsPrefix(final String prefix) {
   checkUpdate();
   holder.getBaseItem().removeNsPrefix(prefix);
   return holder.getSecuredItem();
 }
Exemple #8
0
 @Override
 public String qnameFor(final String uri) {
   checkRead();
   return holder.getBaseItem().qnameFor(uri);
 }
Exemple #9
0
 @Override
 public SecuredPrefixMapping lock() {
   checkUpdate();
   holder.getBaseItem().lock();
   return holder.getSecuredItem();
 }
Exemple #10
0
 @Override
 public String getNsURIPrefix(final String uri) {
   checkRead();
   return holder.getBaseItem().getNsURIPrefix(uri);
 }
Exemple #11
0
 @Override
 public String getNsPrefixURI(final String prefix) {
   checkRead();
   return holder.getBaseItem().getNsPrefixURI(prefix);
 }
Exemple #12
0
 @Override
 public Map<String, String> getNsPrefixMap() {
   checkRead();
   return holder.getBaseItem().getNsPrefixMap();
 }
Exemple #13
0
 @Override
 public String expandPrefix(final String prefixed) {
   checkRead();
   return holder.getBaseItem().expandPrefix(prefixed);
 }
Exemple #14
0
 @Override
 public String shortForm(final String uri) {
   checkRead();
   return holder.getBaseItem().shortForm(uri);
 }
Exemple #15
0
 @Override
 public SecuredPrefixMapping setNsPrefixes(final PrefixMapping other) {
   checkUpdate();
   holder.getBaseItem().setNsPrefixes(other);
   return holder.getSecuredItem();
 }
Exemple #16
0
 @Override
 public SecuredPrefixMapping setNsPrefixes(final Map<String, String> map) {
   checkUpdate();
   holder.getBaseItem().setNsPrefixes(map);
   return holder.getSecuredItem();
 }