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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations