Search in sources :

Example 1 with CryptoToken

use of org.mozilla.jss.crypto.CryptoToken in project OpenAM by OpenRock.

the class JSSEncryption method findToken.

private static CryptoToken findToken() throws CryptoManager.NotInitializedException {
    // This crypto token has to support encryption algorithm 
    // and all the key generation algorithms in KEYGEN_ALGS.
    // CryptoManager returns "Internal Key Storage Token" at least.
    CryptoToken token = null;
    CryptoManager cm = CryptoManager.getInstance();
    Enumeration e = cm.getTokensSupportingAlgorithm(getEncryptionAlg(DEFAULT_ENCYPTION_ALG));
    while (e.hasMoreElements()) {
        CryptoToken tok = (CryptoToken) e.nextElement();
        boolean foundToken = true;
        for (int i = 0; i < NUM_KEYGEN_ALG; i++) {
            if (!tok.doesAlgorithm(getKeyGenAlg(KEYGEN_ALGS[i]))) {
                foundToken = false;
                break;
            }
        }
        if (foundToken) {
            return tok;
        }
    }
    return null;
}
Also used : CryptoToken(org.mozilla.jss.crypto.CryptoToken) Enumeration(java.util.Enumeration) CryptoManager(org.mozilla.jss.CryptoManager)

Aggregations

Enumeration (java.util.Enumeration)1 CryptoManager (org.mozilla.jss.CryptoManager)1 CryptoToken (org.mozilla.jss.crypto.CryptoToken)1