com.arangodb.entity.Permissions Java Examples

The following examples show how to use com.arangodb.entity.Permissions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UserAuthTest.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void readDocumentByAql() {
    try {
        arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).insertDocument(new BaseDocument("123"));
        if ((Permissions.RW.equals(param.dbPermission) || Permissions.RO.equals(param.dbPermission))
                && (Permissions.RW.equals(param.colPermission) || Permissions.RO.equals(param.colPermission))) {
            assertThat(details,
                    arangoDB.db(DB_NAME).query("FOR i IN @@col RETURN i",
                            new MapBuilder().put("@col", COLLECTION_NAME).get(), new AqlQueryOptions(), BaseDocument.class)
                            .asListRemaining().size(),
                    is(1));
        } else {
            assertThat(details,
                    arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class),
                    is(nullValue()));
        }
    } finally {
        try {
            arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).deleteDocument("123");
        } catch (final ArangoDBException e) {
        }
    }
}
 
Example #2
Source File: UserAuthTest.java    From arangodb-java-driver with Apache License 2.0 6 votes vote down vote up
@Test
public void readDocumentByKey() {
    try {
        arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).insertDocument(new BaseDocument("123"));
        if ((Permissions.RW.equals(param.dbPermission) || Permissions.RO.equals(param.dbPermission))
                && (Permissions.RW.equals(param.colPermission) || Permissions.RO.equals(param.colPermission))) {
            assertThat(details,
                    arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class),
                    is(notNullValue()));
        } else {
            assertThat(details,
                    arangoDB.db(DB_NAME).collection(COLLECTION_NAME).getDocument("123", BaseDocument.class),
                    is(nullValue()));
        }
    } finally {
        try {
            arangoDBRoot.db(DB_NAME).collection(COLLECTION_NAME).deleteDocument("123");
        } catch (final ArangoDBException e) {
        }
    }
}
 
Example #3
Source File: DefaultCollectionOperations.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public void grantAccess(final String username, final Permissions permissions) {
	try {
		collection.grantAccess(username, permissions);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #4
Source File: UserAuthTest.java    From arangodb-java-driver with Apache License 2.0 5 votes vote down vote up
UserAuthParam(final Protocol protocol, final Permissions systemPermission,
              final Permissions dbPermission, final Permissions colPermission) {
    super();
    this.protocol = protocol;
    this.systemPermission = systemPermission;
    this.dbPermission = dbPermission;
    this.colPermission = colPermission;
}
 
Example #5
Source File: DefaultCollectionOperations.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public Permissions getPermissions(final String username) throws DataAccessException {
	try {
		return collection.getPermissions(username);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #6
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public Permissions getDatabasePermissions() throws DataAccessException {
	try {
		return db.getPermissions(username);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #7
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public void grantDefaultCollectionAccess(final Permissions permissions) throws DataAccessException {
	try {
		db.grantDefaultCollectionAccess(username, permissions);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #8
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public void grantDatabaseAccess(final Permissions permissions) throws DataAccessException {
	try {
		db.grantAccess(username, permissions);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #9
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 5 votes vote down vote up
@Override
public void grantDefaultDatabaseAccess(final Permissions permissions) throws DataAccessException {
	try {
		db.arango().grantDefaultDatabaseAccess(username, permissions);
	} catch (final ArangoDBException e) {
		throw translateExceptionIfPossible(e);
	}
}
 
Example #10
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public void grantCollectionAccess(final String name, final Permissions permissions) throws DataAccessException {
	collectionCallback.collection(name).grantAccess(username, permissions);
}
 
Example #11
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public void grantCollectionAccess(final Class<?> type, final Permissions permissions) throws DataAccessException {
	collectionCallback.collection(type).grantAccess(username, permissions);
}
 
Example #12
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public Permissions getCollectionPermissions(final Class<?> type) throws DataAccessException {
	return collectionCallback.collection(type).getPermissions(username);
}
 
Example #13
Source File: DefaultUserOperation.java    From spring-data with Apache License 2.0 4 votes vote down vote up
@Override
public Permissions getCollectionPermissions(final String name) throws DataAccessException {
	return collectionCallback.collection(name).getPermissions(name);
}
 
Example #14
Source File: InternalArangoDB.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
protected Request updateUserDefaultCollectionAccessRequest(final String user, final Permissions permissions) {
    return request(ArangoRequestParam.SYSTEM, RequestType.PUT, PATH_API_USER, user, ArangoRequestParam.DATABASE,
            "*", "*").setBody(util().serialize(OptionsBuilder.build(new UserAccessOptions(), permissions)));
}
 
Example #15
Source File: InternalArangoDB.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
protected Request updateUserDefaultDatabaseAccessRequest(final String user, final Permissions permissions) {
    return request(ArangoRequestParam.SYSTEM, RequestType.PUT, PATH_API_USER, user, ArangoRequestParam.DATABASE,
            "*").setBody(util().serialize(OptionsBuilder.build(new UserAccessOptions(), permissions)));
}
 
Example #16
Source File: OptionsBuilder.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
public static UserAccessOptions build(final UserAccessOptions options, final Permissions grant) {
    return options.grant(grant);
}
 
Example #17
Source File: UserAccessOptions.java    From arangodb-java-driver with Apache License 2.0 4 votes vote down vote up
protected Permissions getGrant() {
    return grant;
}
 
Example #18
Source File: ArangoDBAsyncImpl.java    From arangodb-java-driver-async with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Void> grantDefaultCollectionAccess(final String user, final Permissions permissions) {
	return executor.execute(updateUserDefaultCollectionAccessRequest(user, permissions), Void.class);
}
 
Example #19
Source File: ArangoDBAsyncImpl.java    From arangodb-java-driver-async with Apache License 2.0 4 votes vote down vote up
@Override
public CompletableFuture<Void> grantDefaultDatabaseAccess(final String user, final Permissions permissions) {
	return executor.execute(updateUserDefaultDatabaseAccessRequest(user, permissions), Void.class);
}
 
Example #20
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Grants or revoke access to the collection for user. You need permission to the _system database in order to
 * execute this call.
 *
 * @param entityClass
 *            The entity type representing the collection
 * @param permissions
 *            The permissions the user grant
 * @throws DataAccessException
 */
void grantCollectionAccess(Class<?> entityClass, Permissions permissions) throws DataAccessException;
 
Example #21
Source File: ArangoDBAsync.java    From arangodb-java-driver-async with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the default access level for collections for the user <code>user</code>. You need permission to the _system
 * database in order to execute this call.
 * 
 * @param user
 *            The name of the user
 * @param permissions
 *            The permissions the user grant
 * @since ArangoDB 3.2.0
 * @return void
 */
CompletableFuture<Void> grantDefaultCollectionAccess(final String user, final Permissions permissions);
 
Example #22
Source File: ArangoDBAsync.java    From arangodb-java-driver-async with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the default access level for databases for the user <code>user</code>. You need permission to the _system
 * database in order to execute this call.
 * 
 * @param user
 *            The name of the user
 * @param permissions
 *            The permissions the user grant
 * @since ArangoDB 3.2.0
 * @return void
 */
CompletableFuture<Void> grantDefaultDatabaseAccess(final String user, final Permissions permissions);
 
Example #23
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Get the collection access level
 *
 * @param name
 *            The name of the collection
 * @return permissions of the user
 * @since ArangoDB 3.2.0
 * @throws DataAccessException
 */
Permissions getCollectionPermissions(String name) throws DataAccessException;
 
Example #24
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Get the collection access level
 *
 * @param entityClass
 *            The entity type representing the collection
 * @return permissions of the user
 * @since ArangoDB 3.2.0
 * @throws DataAccessException
 */
Permissions getCollectionPermissions(Class<?> entityClass) throws DataAccessException;
 
Example #25
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Get specific database access level
 *
 * @return permissions of the user
 * @since ArangoDB 3.2.0
 * @throws DataAccessException
 */
Permissions getDatabasePermissions() throws DataAccessException;
 
Example #26
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Grants or revoke access to the collection for user. You need permission to the _system database in order to
 * execute this call.
 *
 * @param name
 *            The name of the collection
 * @param permissions
 *            The permissions the user grant
 * @throws DataAccessException
 */
void grantCollectionAccess(String name, Permissions permissions) throws DataAccessException;
 
Example #27
Source File: CollectionOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Grants or revoke access to the collection for user user. You need permission to the _system database in order to
 * execute this call.
 *
 * @param username
 *            The name of the user
 * @param permissions
 *            The permissions the user grant
 * @throws DataAccessException
 */
void grantAccess(String username, Permissions permissions) throws DataAccessException;
 
Example #28
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the default access level for collections for the user. You need permission to the _system database in order
 * to execute this call.
 *
 * @param permissions
 *            The permissions the user grant
 * @since ArangoDB 3.2.0
 * @throws DataAccessException
 */
void grantDefaultCollectionAccess(Permissions permissions) throws DataAccessException;
 
Example #29
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Grants or revoke access to the database for the user. You need permission to the _system database in order to
 * execute this call.
 *
 * @param permissions
 *            The permissions the user grant
 * @throws DataAccessException
 */
void grantDatabaseAccess(Permissions permissions) throws DataAccessException;
 
Example #30
Source File: UserOperations.java    From spring-data with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the default access level for databases for the user. You need permission to the _system database in order to
 * execute this call.
 *
 * @param permissions
 *            The permissions the user grant
 * @since ArangoDB 3.2.0
 * @throws DataAccessException
 */
void grantDefaultDatabaseAccess(Permissions permissions) throws DataAccessException;