Example of system permissions for HSM users.
package doxy.examples;
import java.util.concurrent.TimeUnit;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class SystemPermission {
static String ip = "127.0.0.1";
static String operatorId = "master";
static String operatorPwd = "12345678";
static String userId = "user01";
static String userPwd = "12345678";
public static void main(String[] args) throws TacException, InterruptedException {
Dinamo opUserSession = new Dinamo();
int authMask = 0;
opUserSession.openSession(ip, operatorId, operatorPwd, TacNDJavaLib.DEFAULT_PORT, false, false, true);
opUserSession.createUser(userId, userPwd, authMask);
Dinamo userSession = new Dinamo();
userSession.openSession(ip,
userId,
userPwd,
TacNDJavaLib.DEFAULT_PORT,
false, false, true);
opUserSession.updateUserSysPermission(userId,
true,
true,
true,
true,
true);
System.out.println("System permissions: ");
int userSysPermissions = userSession.getUserACL(userId);
System.out.println("Create: " + (TacNDJavaLib.ACL_USR_CREATE == (userSysPermissions & TacNDJavaLib.ACL_USR_CREATE)));
System.out.println("List: " + (TacNDJavaLib.ACL_USR_LIST == (userSysPermissions & TacNDJavaLib.ACL_USR_LIST)));
System.out.println("Log: " + (TacNDJavaLib.ACL_USR_REMOTE_INFO == (userSysPermissions & TacNDJavaLib.ACL_USR_REMOTE_INFO)));
System.out.println("Backup: " + (TacNDJavaLib.ACL_SYS_BACKUP == (userSysPermissions & TacNDJavaLib.ACL_SYS_BACKUP)));
System.out.println("Firmware: " + (TacNDJavaLib.ACL_SYS_UDATE_HSM == (userSysPermissions & TacNDJavaLib.ACL_SYS_UDATE_HSM)));
opUserSession.updateUserSysPermission( userId,
false,
false,
false,
false,
false);
userSysPermissions = userSession.getUserACL(userId);
System.out.println("System permissions(remove): ");
System.out.println("Create: " + (TacNDJavaLib.ACL_USR_CREATE == (userSysPermissions & TacNDJavaLib.ACL_USR_CREATE)));
System.out.println("List: " + (TacNDJavaLib.ACL_USR_LIST == (userSysPermissions & TacNDJavaLib.ACL_USR_LIST)));
System.out.println("Log: " + (TacNDJavaLib.ACL_USR_REMOTE_INFO == (userSysPermissions & TacNDJavaLib.ACL_USR_REMOTE_INFO)));
System.out.println("Backup: " + (TacNDJavaLib.ACL_SYS_BACKUP == (userSysPermissions & TacNDJavaLib.ACL_SYS_BACKUP)));
System.out.println("Firmware: " + (TacNDJavaLib.ACL_SYS_UDATE_HSM == (userSysPermissions & TacNDJavaLib.ACL_SYS_UDATE_HSM)));
opUserSession.setUserOperator(userId);
userSysPermissions = userSession.getUserACL(userId);
System.out.println("System permissions(operator): ");
System.out.println("Operator: " + (TacNDJavaLib.ACL_SYS_OPERATOR == (userSysPermissions & TacNDJavaLib.ACL_SYS_OPERATOR)));
opUserSession.updateUserSysPermission( userId,
false,
false,
false,
false,
false);
userSysPermissions = userSession.getUserACL(userId);
System.out.println("System permissions(remove): ");
System.out.println("Create: " + (TacNDJavaLib.ACL_USR_CREATE == (userSysPermissions & TacNDJavaLib.ACL_USR_CREATE)));
System.out.println("List: " + (TacNDJavaLib.ACL_USR_LIST == (userSysPermissions & TacNDJavaLib.ACL_USR_LIST)));
System.out.println("Log: " + (TacNDJavaLib.ACL_USR_REMOTE_INFO == (userSysPermissions & TacNDJavaLib.ACL_USR_REMOTE_INFO)));
System.out.println("Backup: " + (TacNDJavaLib.ACL_SYS_BACKUP == (userSysPermissions & TacNDJavaLib.ACL_SYS_BACKUP)));
System.out.println("Firmware: " + (TacNDJavaLib.ACL_SYS_UDATE_HSM == (userSysPermissions & TacNDJavaLib.ACL_SYS_UDATE_HSM)));
userSession.closeSession(true);
TimeUnit.SECONDS.sleep(1);
opUserSession.deleteUser(userId);
opUserSession.closeSession();
}
}