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;
}
Aggregations