Java API
HSM Dinamo
Loading...
Looking for...
No entries found
UserNamespacePermission.java

Example of namespace object permissions for an HSM user.

See Note on examples.
package doxy.examples;
import java.util.concurrent.TimeUnit;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class UserNamespacePermission {
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 {
/*
* Creates an ordinary user using an operator user.
*
* */
Dinamo opUserSession = new Dinamo();
int authMask = 0;
opUserSession.openSession(ip, operatorId, operatorPwd, TacNDJavaLib.DEFAULT_PORT, false, false, true);
opUserSession.createUser(userId, userPwd, authMask);
/*
* Connects to the created user and gives permission to the user
* operator.
*
* */
Dinamo userSession = new Dinamo();
String strKeyName = "key";
userSession.openSession(ip,
userId,
userPwd,
TacNDJavaLib.DEFAULT_PORT,
false, false, true);
userSession.createKey( strKeyName,
TacNDJavaLib.ALG_3DES_168,
true);
userSession.updateUserObjPermission(operatorId,
true,
true,
true,
true);
/*
* Tests access to the common user's key using the master user.
* */
opUserSession.getUserKey(userId+"/"+strKeyName);
/*
* Remove permissions.
* */
userSession.updateUserObjPermission(operatorId,
false,
false,
false,
false);
userSession.closeSession(true);
/*
* Wait a while for the session to close completely.
*/
TimeUnit.SECONDS.sleep(1);
/*
* Remove test user.
* */
opUserSession.deleteUser(userId);
opUserSession.closeSession();
}
}