@Override
 public SecuredPrefixMapping removeNsPrefix(final String prefix)
     throws UpdateDeniedException, AuthenticationRequiredException {
   checkUpdate();
   holder.getBaseItem().removeNsPrefix(prefix);
   return holder.getSecuredItem();
 }
 @Override
 public SecuredPrefixMapping setNsPrefixes(final PrefixMapping other)
     throws UpdateDeniedException, AuthenticationRequiredException {
   checkUpdate();
   holder.getBaseItem().setNsPrefixes(other);
   return holder.getSecuredItem();
 }
Example #3
0
 @Override
 public SecuredSeq getSeq(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Seq retval = holder.getBaseItem().getSeq(index);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), retval.asNode()));
   return SecuredSeqImpl.getInstance(getModel(), retval);
 }
Example #4
0
 @Override
 public String getLanguage(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Literal literal = holder.getBaseItem().getLiteral(index);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), literal.asNode()));
   return literal.getLanguage();
 }
Example #5
0
 @Override
 public SecuredBag getBag(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Bag b = holder.getBaseItem().getBag(index);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), b.asNode()));
   return SecuredBagImpl.getInstance(getModel(), b);
 }
Example #6
0
 @Override
 @Deprecated
 public SecuredResource getResource(final int index, final ResourceF f)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final Resource retval = holder.getBaseItem().getResource(index, f);
   checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), retval.asNode()));
   return SecuredResourceImpl.getInstance(getModel(), retval);
 }
Example #7
0
 @Override
 public long getLong(final int index) throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final long retval = holder.getBaseItem().getLong(index);
   checkRead(
       new Triple(
           holder.getBaseItem().asNode(), RDF.li(index).asNode(), asObject(retval).asNode()));
   return retval;
 }
Example #8
0
 @Override
 public SecuredSeq add(final int index, final RDFNode o)
     throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
   checkUpdate();
   final Literal l = holder.getBaseItem().getModel().createTypedLiteral(o);
   checkCreate(index, l);
   holder.getBaseItem().add(index, o);
   return holder.getSecuredItem();
 }
Example #9
0
 @Override
 public SecuredSeq remove(final int index)
     throws UpdateDeniedException, DeleteDeniedException, AuthenticationRequiredException {
   checkUpdate();
   final RDFNode rdfNode = holder.getBaseItem().getObject(index);
   if (rdfNode != null) {
     checkDelete(
         new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), rdfNode.asNode()));
     holder.getBaseItem().remove(index);
   }
   return holder.getSecuredItem();
 }
Example #10
0
 @Override
 public String getString(final int index)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   final String retval = holder.getBaseItem().getString(index);
   checkRead(
       new Triple(
           holder.getBaseItem().asNode(),
           RDF.li(index).asNode(),
           ResourceFactory.createTypedLiteral(retval).asNode()));
   return retval;
 }
Example #11
0
 @Override
 public SecuredSeq set(final int index, final RDFNode o)
     throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
   checkUpdate();
   final Triple t2 = new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), o.asNode());
   final RDFNode rdfNode = holder.getBaseItem().getObject(index);
   if (rdfNode != null) {
     final Triple t1 =
         new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), rdfNode.asNode());
     checkUpdate(t1, t2);
   } else {
     checkCreate(t2);
   }
   holder.getBaseItem().set(index, o);
   return holder.getSecuredItem();
 }
Example #12
0
 /**
  * get a SecuredSeq.
  *
  * @param securedModel The secured model that provides the security context
  * @param seq The Seq to secure.
  * @return the SecuredSeq
  */
 public static SecuredSeq getInstance(final SecuredModel securedModel, final Seq seq) {
   if (securedModel == null) {
     throw new IllegalArgumentException("Secured securedModel may not be null");
   }
   if (seq == null) {
     throw new IllegalArgumentException("Seq may not be null");
   }
   final ItemHolder<Seq, SecuredSeq> holder = new ItemHolder<Seq, SecuredSeq>(seq);
   final SecuredSeqImpl checker = new SecuredSeqImpl(securedModel, holder);
   // if we are going to create a duplicate proxy, just return this
   // one.
   if (seq instanceof SecuredSeq) {
     if (checker.isEquivalent((SecuredSeq) seq)) {
       return (SecuredSeq) seq;
     }
   }
   return holder.setSecuredItem(new SecuredItemInvoker(seq.getClass(), checker));
 }
  @Override
  public SecuredPrefixMapping withDefaultMappings(final PrefixMapping map)
      throws UpdateDeniedException, AuthenticationRequiredException {
    // 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();
  }
 @Override
 public boolean samePrefixMappingAs(final PrefixMapping other)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   return holder.getBaseItem().samePrefixMappingAs(other);
 }
Example #15
0
 private void checkCreate(final int index, final Literal l) {
   checkCreate(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), l.asNode()));
 }
 @Override
 public String qnameFor(final String uri)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   return holder.getBaseItem().qnameFor(uri);
 }
 @Override
 public SecuredPrefixMapping lock() throws UpdateDeniedException, AuthenticationRequiredException {
   checkUpdate();
   holder.getBaseItem().lock();
   return holder.getSecuredItem();
 }
 @Override
 public String getNsURIPrefix(final String uri)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   return holder.getBaseItem().getNsURIPrefix(uri);
 }
 @Override
 public Map<String, String> getNsPrefixMap()
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   return holder.getBaseItem().getNsPrefixMap();
 }
 @Override
 public String expandPrefix(final String prefixed)
     throws ReadDeniedException, AuthenticationRequiredException {
   checkRead();
   return holder.getBaseItem().expandPrefix(prefixed);
 }
Example #21
0
 @Override
 public SecuredSeq add(final int index, final String o, final String l)
     throws UpdateDeniedException, AddDeniedException, AuthenticationRequiredException {
   return add(index, holder.getBaseItem().getModel().createLiteral(o, l));
 }