CryptoToken - dogtagpki/jss GitHub Wiki

Getting All Tokens

CryptoManager manager = CryptoManager.getInstance();
Enumeration<CryptoToken> tokens = manager.getAllTokens();

whlie (tokens.hasMoreElements()) {
    CryptoToken token = tokens.nextElement();
    ...
}

Getting a Token

CryptoManager manager = CryptoManager.getInstance();

CryptoToken token;

if (...) {
    token = manager.getInternalKeyStorageToken();
} else {
    token = manager.getTokenByName(tokenName);
}

manager.setThreadToken(token);

Authentication

To authenticate with PasswordCallback:

public interface PasswordCallback {
    public Password getPasswordFirstAttempt(PasswordCallbackInfo info) throws GiveUpException;
    public Password getPasswordAgain(PasswordCallbackInfo info) throws GiveUpException;
}
PasswordCallback pc = ...;
manager.setPasswordCallback(pc);

To authenticate with password:

Password password = new Password(chars);
token.login(password);
password.clear();
⚠️ **GitHub.com Fallback** ⚠️