Search in sources :

Example 1 with SecuredSeq

use of org.apache.jena.permissions.model.SecuredSeq in project jena by apache.

the class SecuredSeqImpl method getSeq.

/**
 * @sec.graph Read if {@link SecurityEvaluator#isHardReadError()} is true and
 *            the user does not have read access then SeqIndexBoundsException is
 *            thrown
 * @sec.triple Read SecTriple( this, RDF.li(1), o )
 * @throws ReadDeniedException
 * @throws AuthenticationRequiredException if user is not authenticated and is
 *                                         required to be.
 */
@Override
public SecuredSeq getSeq(final int index) throws ReadDeniedException, AuthenticationRequiredException {
    if (checkSoftRead()) {
        final Seq retval = holder.getBaseItem().getSeq(index);
        checkRead(new Triple(holder.getBaseItem().asNode(), RDF.li(index).asNode(), retval.asNode()));
        return SecuredSeqImpl.getInstance(getModel(), retval);
    }
    throw new SeqIndexBoundsException(index, 0);
}
Also used : Triple(org.apache.jena.graph.Triple) SeqIndexBoundsException(org.apache.jena.rdf.model.SeqIndexBoundsException) SecuredSeq(org.apache.jena.permissions.model.SecuredSeq) Seq(org.apache.jena.rdf.model.Seq)

Example 2 with SecuredSeq

use of org.apache.jena.permissions.model.SecuredSeq in project jena by apache.

the class SecuredSeqImpl method getInstance.

/**
 * 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);
    final SecuredSeqImpl checker = new SecuredSeqImpl(securedModel, holder);
    // one.
    if (seq instanceof SecuredSeq) {
        if (checker.isEquivalent((SecuredSeq) seq)) {
            return (SecuredSeq) seq;
        }
    }
    return holder.setSecuredItem(new SecuredItemInvoker(seq.getClass(), checker));
}
Also used : SecuredSeq(org.apache.jena.permissions.model.SecuredSeq) ItemHolder(org.apache.jena.permissions.impl.ItemHolder) SecuredItemInvoker(org.apache.jena.permissions.impl.SecuredItemInvoker) SecuredSeq(org.apache.jena.permissions.model.SecuredSeq) Seq(org.apache.jena.rdf.model.Seq)

Aggregations

SecuredSeq (org.apache.jena.permissions.model.SecuredSeq)2 Seq (org.apache.jena.rdf.model.Seq)2 Triple (org.apache.jena.graph.Triple)1 ItemHolder (org.apache.jena.permissions.impl.ItemHolder)1 SecuredItemInvoker (org.apache.jena.permissions.impl.SecuredItemInvoker)1 SeqIndexBoundsException (org.apache.jena.rdf.model.SeqIndexBoundsException)1