Key key = findKey(cmd, cipherInformation);
boolean isEncrypt = (cipherInformation.getCipherOperationMode() ==
CipherOperationMode.ENCRYPT);
EncryptionProvider encryptionProvider = null;
DecryptionProvider decryptionProvider = null;
if (key != null) {
if (isEncrypt) {
encryptionProvider = CipherFactory.createCipher(cipherInformation, key);
} else {
decryptionProvider = CipherFactory.createCipher(cipherInformation, key);
}
} else {
boolean isTrusted = isArgumentPresent(cmd, TRUSTED);
KeyStoreWrapper keyStoreWrapper;
if (isTrusted) {
keyStoreWrapper = new TrustKeyStoreWrapper();
((TrustKeyStoreWrapper) keyStoreWrapper).init(getTrustKeyStoreInformation(cmd));
} else {
keyStoreWrapper = new IdentityKeyStoreWrapper();
//Password for access private key
String keyPass = getArgument(cmd, KEY_PASS, null);
assertEmpty(keyPass, KEY_PASS);
((IdentityKeyStoreWrapper) keyStoreWrapper).init(
getIdentityKeyStoreInformation(cmd), keyPass);
}
if (isEncrypt) {
encryptionProvider = CipherFactory.createCipher(cipherInformation,
keyStoreWrapper);
} else {
decryptionProvider = CipherFactory.createCipher(cipherInformation,
keyStoreWrapper);
}
}
PrintStream out = System.out;
if (isEncrypt) {
out.println("Output : " + new String(encryptionProvider.encrypt(source.getBytes())));
} else {
out.println("Output : " + new String(decryptionProvider.decrypt(source.getBytes())));
}
} catch (ParseException e) {