Search in sources :

Example 1 with Authorizations

use of org.vertexium.security.Authorizations in project vertexium by visallo.

the class VisibilityUtils method canRead.

public static boolean canRead(String visibility, String[] authorizations) {
    VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(new Authorizations(authorizations));
    ColumnVisibility columnVisibility = new ColumnVisibility(visibility);
    try {
        return visibilityEvaluator.evaluate(columnVisibility);
    } catch (VisibilityParseException ex) {
        throw new RuntimeException("could not evaluate visibility " + visibility, ex);
    }
}
Also used : Authorizations(org.vertexium.security.Authorizations) VisibilityEvaluator(org.vertexium.security.VisibilityEvaluator) ColumnVisibility(org.vertexium.security.ColumnVisibility) VisibilityParseException(org.vertexium.security.VisibilityParseException)

Example 2 with Authorizations

use of org.vertexium.security.Authorizations in project vertexium by visallo.

the class InMemoryAuthorizations method canRead.

@Override
public boolean canRead(Visibility visibility) {
    Preconditions.checkNotNull(visibility, "visibility is required");
    // this is just a shortcut so that we don't need to construct evaluators and visibility objects to check for an empty string.
    if (visibility.getVisibilityString().length() == 0) {
        return true;
    }
    VisibilityEvaluator visibilityEvaluator = new VisibilityEvaluator(new Authorizations(this.getAuthorizations()));
    ColumnVisibility columnVisibility = new ColumnVisibility(visibility.getVisibilityString());
    try {
        return visibilityEvaluator.evaluate(columnVisibility);
    } catch (VisibilityParseException e) {
        throw new VertexiumException("could not evaluate visibility " + visibility.getVisibilityString(), e);
    }
}
Also used : Authorizations(org.vertexium.security.Authorizations) VisibilityEvaluator(org.vertexium.security.VisibilityEvaluator) ColumnVisibility(org.vertexium.security.ColumnVisibility) VisibilityParseException(org.vertexium.security.VisibilityParseException) VertexiumException(org.vertexium.VertexiumException)

Aggregations

Authorizations (org.vertexium.security.Authorizations)2 ColumnVisibility (org.vertexium.security.ColumnVisibility)2 VisibilityEvaluator (org.vertexium.security.VisibilityEvaluator)2 VisibilityParseException (org.vertexium.security.VisibilityParseException)2 VertexiumException (org.vertexium.VertexiumException)1