Search in sources :

Example 6 with AdminCommand

use of com.aerospike.client.admin.AdminCommand in project aerospike-client-java by aerospike.

the class AerospikeClient method createRole.

/**
 * Create user defined role with optional privileges, whitelist and read/write quotas.
 * Quotas require server security configuration "enable-quotas" to be set to true.
 *
 * @param policy				admin configuration parameters, pass in null for defaults
 * @param roleName				role name
 * @param privileges			optional list of privileges assigned to role.
 * @param whitelist				optional list of allowable IP addresses assigned to role.
 * 								IP addresses can contain wildcards (ie. 10.1.2.0/24).
 * @param readQuota				optional maximum reads per second limit, pass in zero for no limit.
 * @param writeQuota			optional maximum writes per second limit, pass in zero for no limit.
 * @throws AerospikeException	if command fails
 */
public final void createRole(AdminPolicy policy, String roleName, List<Privilege> privileges, List<String> whitelist, int readQuota, int writeQuota) throws AerospikeException {
    AdminCommand command = new AdminCommand();
    command.createRole(cluster, policy, roleName, privileges, whitelist, readQuota, writeQuota);
}
Also used : AdminCommand(com.aerospike.client.admin.AdminCommand)

Example 7 with AdminCommand

use of com.aerospike.client.admin.AdminCommand in project aerospike-client-java by aerospike.

the class AerospikeClient method changePassword.

/**
 * Change user's password.
 *
 * @param policy				admin configuration parameters, pass in null for defaults
 * @param user					user name
 * @param password				user password in clear-text format
 * @throws AerospikeException	if command fails
 */
public final void changePassword(AdminPolicy policy, String user, String password) throws AerospikeException {
    if (cluster.getUser() == null) {
        throw new AerospikeException("Invalid user");
    }
    byte[] userBytes = Buffer.stringToUtf8(user);
    byte[] passwordBytes = Buffer.stringToUtf8(password);
    String hash = AdminCommand.hashPassword(password);
    byte[] hashBytes = Buffer.stringToUtf8(hash);
    AdminCommand command = new AdminCommand();
    if (Arrays.equals(userBytes, cluster.getUser())) {
        // Change own password.
        command.changePassword(cluster, policy, userBytes, hash);
    } else {
        // Change other user's password by user admin.
        command.setPassword(cluster, policy, userBytes, hash);
    }
    cluster.changePassword(userBytes, passwordBytes, hashBytes);
}
Also used : AdminCommand(com.aerospike.client.admin.AdminCommand)

Example 8 with AdminCommand

use of com.aerospike.client.admin.AdminCommand in project aerospike-client-java by aerospike.

the class AerospikeClient method grantPrivileges.

/**
 * Grant privileges to an user defined role.
 *
 * @param policy				admin configuration parameters, pass in null for defaults
 * @param roleName				role name
 * @param privileges			privileges assigned to the role.
 * @throws AerospikeException	if command fails
 */
public final void grantPrivileges(AdminPolicy policy, String roleName, List<Privilege> privileges) throws AerospikeException {
    AdminCommand command = new AdminCommand();
    command.grantPrivileges(cluster, policy, roleName, privileges);
}
Also used : AdminCommand(com.aerospike.client.admin.AdminCommand)

Example 9 with AdminCommand

use of com.aerospike.client.admin.AdminCommand in project aerospike-client-java by aerospike.

the class AerospikeClient method dropUser.

/**
 * Remove user from cluster.
 *
 * @param policy				admin configuration parameters, pass in null for defaults
 * @param user					user name
 * @throws AerospikeException	if command fails
 */
public final void dropUser(AdminPolicy policy, String user) throws AerospikeException {
    AdminCommand command = new AdminCommand();
    command.dropUser(cluster, policy, user);
}
Also used : AdminCommand(com.aerospike.client.admin.AdminCommand)

Example 10 with AdminCommand

use of com.aerospike.client.admin.AdminCommand in project aerospike-client-java by aerospike.

the class AerospikeClient method revokeRoles.

/**
 * Remove roles from user's list of roles.
 *
 * @param policy				admin configuration parameters, pass in null for defaults
 * @param user					user name
 * @param roles					role names.  Predefined roles are listed in {@link com.aerospike.client.admin.Role}
 * @throws AerospikeException	if command fails
 */
public final void revokeRoles(AdminPolicy policy, String user, List<String> roles) throws AerospikeException {
    AdminCommand command = new AdminCommand();
    command.revokeRoles(cluster, policy, user, roles);
}
Also used : AdminCommand(com.aerospike.client.admin.AdminCommand)

Aggregations

AdminCommand (com.aerospike.client.admin.AdminCommand)22 AerospikeException (com.aerospike.client.AerospikeException)2 ByteBuf (io.netty.buffer.ByteBuf)2 ChannelFuture (io.netty.channel.ChannelFuture)2 ChannelFutureListener (io.netty.channel.ChannelFutureListener)2 AsyncConnection (com.aerospike.client.async.AsyncConnection)1 InetSocketAddress (java.net.InetSocketAddress)1 UnknownHostException (java.net.UnknownHostException)1