PGP шифрование с несколькими ключами в муле - PullRequest
0 голосов
/ 25 сентября 2018

Учитывая, что PGP поддерживает шифрование с использованием нескольких открытых ключей, как этого можно добиться в mulesoft?

Добавление двух ключей в поле Имя файла с открытым ключом в окне конфигурации шифрования для вкладки шифратора pgp приводит к ошибке как org.mule.module.pgp.exception.MissingPGPKeyException: No key file found in: abc.gpg,test.pgp

Можно ли добавить несколько открытых ключей из этого модуля шифрования или как это сделать?время работы мула: 3.8.5

очень ценю любую помощь.Спасибо!

1 Ответ

0 голосов
/ 27 октября 2018

Я решил эту проблему с помощью терминала, запускающего компонент Java, и запустив команду gpg encrypt из среды исполнения Java.Я просто проверяю, чтобы ОС сначала создала командную строку для запуска соответствующего терминала

boolean isWindows = System.getProperty("os.name")
              .toLowerCase().startsWith("windows");

/*gpg command options may vary as per your requirement. multiple --recipient option here is the way to encrypt with multiple public keys.
Using StringBuilder helps to build this string from input/dynamic values.
*/

String command = "gpg --pgp6 --armor --batch --output encryptedHelloWorld.pgp --trust-model always --recipient "<part of UserID1 (either name or emailId)>" --recipient "<part of UserID2>" --encrypt helloWorld.txt" 

/*in case you need to change directory to where your file is to encrypt it from one command, you could append this
`"cd"+ <your path to file> "&" + command`  ----> for  windows
`"cd"+ <your path to file> ";" + command`  ----> for linux
*/

public int executeCommand(String command) throws IOException, InterruptedException {
    Process pr;
    if (isWindows) {
        String[] cmd = { "cmd.exe", "/c", command };
        pr = Runtime.getRuntime().exec(cmd);
    }
    else {
        String[] cmd = { "/bin/sh", "-c", command };
        pr = Runtime.getRuntime().exec(cmd);
    }           
    int exitStatus = pr.waitFor();  // this gives you value 0 if success or other than 0 which ties to error message
    errorInputStream = pr.getErrorStream(); //streaming error message

    return exitStatus;
}
...