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

Example of locking, unlocking, recovering a user's lock status.

See Note on examples.
package doxy.examples;
import com.dinamonetworks.Dinamo;
import br.com.trueaccess.TacException;
import br.com.trueaccess.TacNDJavaLib;
public class BlockUnblockUser {
public static void main(String[] args) throws TacException {
/*
* Cria usuário comum utilizando um usuário operador.
*
* */
Dinamo opUserSession = new Dinamo();
String hsmIP = "127.0.0.1";
String operatorId = "master";
String userId = "user01";
String password = "12345678";
int authMask = 0;
opUserSession.openSession(hsmIP, operatorId, password, TacNDJavaLib.DEFAULT_PORT, false, false, true);
opUserSession.createUser(userId, password, authMask);
/*
* Testa bloqueio e desbloqueio do usuário.
*
* */
System.out.println("Is user " + userId + " blocked: " +
opUserSession.isUserBlocked(userId));
opUserSession.blockUser(userId);
System.out.println("Is user " + userId + " blocked: " +
opUserSession.isUserBlocked(userId));
opUserSession.unblockUser(userId);
System.out.println("Is user " + userId + " blocked: " +
opUserSession.isUserBlocked(userId));
/*
* Remove usuário de teste.
* */
opUserSession.deleteUser(userId);
opUserSession.closeSession();
}
}