Hi. I am trying to consume my Passbolt API from a Java project. And I am not familiar with encryption algorithms. I am following the guide “Using Postman to get Familiar with Passbolt API” refered in How to complete initial API auth steps using Postman?. I followed it in Postman. Now, I am trying to do it in Java.
I could save the server’s public key returned by the API in a PGPPublicKey object. I use BouncyCastle library. This is the fragment code:
InputStream in = new ByteArrayInputStream(serverPublicKeyContent.getBytes());
in = PGPUtil.getDecoderStream(in);
JcaPGPPublicKeyRingCollection pgpPub = new JcaPGPPublicKeyRingCollection(in);
in.close();
Iterator<PGPPublicKeyRing> rIt = pgpPub.getKeyRings();
while (serverPublicKey == null && rIt.hasNext()) {
PGPPublicKeyRing kRing = rIt.next();
Iterator<PGPPublicKey> kIt = kRing.getPublicKeys();
while (serverPublicKey == null && kIt.hasNext()) {
PGPPublicKey k = kIt.next();
if (k.isEncryptionKey()) {
serverPublicKey = k;
}
}
}
Now, I am trying to send encrypted data to the server using this server’s public key. However, I don’t know how do it in Java.
An example of data to encrypt is:
gpgauthv1.3.0|36|de303d54-75b4-431b-adb2-eb6b9e546014|gpgauthv1.3.0
Could somebody help me, please? Thank you very much in advance.