mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-12-06 02:51:11 +01:00
Bump PGPainless to 0.2.0
This commit is contained in:
parent
4f2d8e8d4c
commit
340ef42736
24 changed files with 228 additions and 472 deletions
|
|
@ -16,12 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
|
@ -35,7 +34,6 @@ import org.jivesoftware.smack.test.util.SmackTestSuite;
|
|||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.ox.element.CryptElement;
|
||||
import org.jivesoftware.smackx.ox.element.OpenPgpElement;
|
||||
import org.jivesoftware.smackx.ox.element.SignElement;
|
||||
|
|
@ -180,7 +178,7 @@ public class OpenPgpElementTest extends SmackTestSuite {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void openPgpContentElementProvider_invalidElementTest() throws IOException, XmlPullParserException {
|
||||
public void openPgpContentElementProvider_invalidElementTest() {
|
||||
String invalidElementXML = "<payload>" +
|
||||
"<body xmlns='jabber:client' xml:lang='en'>This is a secret message.</body>" +
|
||||
"</payload>";
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import org.jivesoftware.smackx.ox.util.SecretKeyBackupHelper;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -36,7 +37,6 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.ox.callback.SecretKeyPassphraseCallback;
|
||||
import org.jivesoftware.smackx.ox.exception.MissingUserIdOnKeyException;
|
||||
import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
|
||||
|
|
@ -56,8 +56,8 @@ import org.junit.runners.Parameterized;
|
|||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.collection.PGPKeyRing;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
import org.pgpainless.util.Passphrase;
|
||||
|
||||
@RunWith(Parameterized.class)
|
||||
|
|
@ -128,15 +128,16 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
assertNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
assertNull(openPgpStoreInstance1.getPublicKeysOf(alice));
|
||||
|
||||
PGPKeyRing keys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
openPgpStoreInstance1.importSecretKey(alice, keys.getSecretKeys());
|
||||
openPgpStoreInstance1.importPublicKey(alice, keys.getPublicKeys());
|
||||
PGPSecretKeyRing keys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(keys);
|
||||
openPgpStoreInstance1.importSecretKey(alice, keys);
|
||||
openPgpStoreInstance1.importPublicKey(alice, KeyRingUtils.publicKeyRingFrom(keys));
|
||||
|
||||
assertNotNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
assertNotNull(openPgpStoreInstance1.getPublicKeysOf(alice));
|
||||
|
||||
openPgpStoreInstance1.deleteSecretKeyRing(alice, new OpenPgpV4Fingerprint(keys.getSecretKeys()));
|
||||
openPgpStoreInstance1.deletePublicKeyRing(alice, new OpenPgpV4Fingerprint(keys.getSecretKeys()));
|
||||
openPgpStoreInstance1.deleteSecretKeyRing(alice, fingerprint);
|
||||
openPgpStoreInstance1.deletePublicKeyRing(alice, fingerprint);
|
||||
|
||||
assertNull(openPgpStoreInstance1.getPublicKeysOf(alice));
|
||||
assertNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
|
|
@ -154,24 +155,23 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
public void t02_key_importKeysTest() throws IOException, PGPException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException, MissingUserIdOnKeyException {
|
||||
// Test for nullity of all possible values.
|
||||
|
||||
PGPKeyRing keys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
|
||||
PGPSecretKeyRing secretKeys = keys.getSecretKeys();
|
||||
PGPPublicKeyRing publicKeys = keys.getPublicKeys();
|
||||
PGPSecretKeyRing secretKeys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys);
|
||||
assertNotNull(secretKeys);
|
||||
assertNotNull(publicKeys);
|
||||
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(secretKeys);
|
||||
|
||||
OpenPgpContact cAlice = openPgpStoreInstance1.getOpenPgpContact(alice);
|
||||
assertNull(cAlice.getAnyPublicKeys());
|
||||
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(publicKeys);
|
||||
assertEquals(fingerprint, new OpenPgpV4Fingerprint(secretKeys));
|
||||
|
||||
assertNull(openPgpStoreInstance1.getPublicKeysOf(alice));
|
||||
assertNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
|
||||
openPgpStoreInstance1.importPublicKey(alice, publicKeys);
|
||||
assertTrue(Arrays.equals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeysOf(alice).getEncoded()));
|
||||
assertArrayEquals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeysOf(alice).getEncoded());
|
||||
assertNotNull(openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint));
|
||||
assertNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
|
||||
|
|
@ -180,17 +180,17 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
|
||||
// Import keys a second time -> No change expected.
|
||||
openPgpStoreInstance1.importPublicKey(alice, publicKeys);
|
||||
assertTrue(Arrays.equals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeysOf(alice).getEncoded()));
|
||||
assertArrayEquals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeysOf(alice).getEncoded());
|
||||
openPgpStoreInstance1.importSecretKey(alice, secretKeys);
|
||||
assertTrue(Arrays.equals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getEncoded()));
|
||||
assertArrayEquals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getEncoded());
|
||||
|
||||
openPgpStoreInstance1.importSecretKey(alice, secretKeys);
|
||||
assertNotNull(openPgpStoreInstance1.getSecretKeysOf(alice));
|
||||
assertTrue(Arrays.equals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getEncoded()));
|
||||
assertArrayEquals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getEncoded());
|
||||
assertNotNull(openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint));
|
||||
|
||||
assertTrue(Arrays.equals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint).getEncoded()));
|
||||
assertTrue(Arrays.equals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint).getEncoded()));
|
||||
assertArrayEquals(secretKeys.getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint).getEncoded());
|
||||
assertArrayEquals(publicKeys.getEncoded(), openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint).getEncoded());
|
||||
|
||||
// Clean up
|
||||
openPgpStoreInstance1.deletePublicKeyRing(alice, fingerprint);
|
||||
|
|
@ -198,27 +198,27 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void t04_key_wrongBareJidOnSecretKeyImportTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, IOException, MissingUserIdOnKeyException {
|
||||
PGPSecretKeyRing secretKeys = openPgpStoreInstance1.generateKeyRing(alice).getSecretKeys();
|
||||
public void t04_key_wrongBareJidOnSecretKeyImportTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
|
||||
PGPSecretKeyRing secretKeys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
|
||||
assertThrows(MissingUserIdOnKeyException.class, () ->
|
||||
openPgpStoreInstance1.importSecretKey(bob, secretKeys));
|
||||
openPgpStoreInstance1.importSecretKey(bob, secretKeys));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void t05_key_wrongBareJidOnPublicKeyImportTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, IOException, MissingUserIdOnKeyException {
|
||||
PGPPublicKeyRing publicKeys = openPgpStoreInstance1.generateKeyRing(alice).getPublicKeys();
|
||||
public void t05_key_wrongBareJidOnPublicKeyImportTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException {
|
||||
PGPSecretKeyRing secretKeys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys);
|
||||
|
||||
assertThrows(MissingUserIdOnKeyException.class, () ->
|
||||
openPgpStoreInstance1.importPublicKey(bob, publicKeys));
|
||||
openPgpStoreInstance1.importPublicKey(bob, publicKeys));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void t06_key_keyReloadTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, IOException, MissingUserIdOnKeyException {
|
||||
PGPKeyRing keys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPSecretKeyRing secretKeys = keys.getSecretKeys();
|
||||
PGPSecretKeyRing secretKeys = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint(secretKeys);
|
||||
PGPPublicKeyRing publicKeys = keys.getPublicKeys();
|
||||
PGPPublicKeyRing publicKeys = KeyRingUtils.publicKeyRingFrom(secretKeys);
|
||||
|
||||
openPgpStoreInstance1.importSecretKey(alice, secretKeys);
|
||||
openPgpStoreInstance1.importPublicKey(alice, publicKeys);
|
||||
|
|
@ -235,24 +235,23 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
|
||||
@Test
|
||||
public void t07_multipleKeysTest() throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException, IOException, MissingUserIdOnKeyException {
|
||||
PGPKeyRing one = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPKeyRing two = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPSecretKeyRing one = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
PGPSecretKeyRing two = openPgpStoreInstance1.generateKeyRing(alice);
|
||||
|
||||
OpenPgpV4Fingerprint fingerprint1 = new OpenPgpV4Fingerprint(one.getSecretKeys());
|
||||
OpenPgpV4Fingerprint fingerprint2 = new OpenPgpV4Fingerprint(two.getSecretKeys());
|
||||
OpenPgpV4Fingerprint fingerprint1 = new OpenPgpV4Fingerprint(one);
|
||||
OpenPgpV4Fingerprint fingerprint2 = new OpenPgpV4Fingerprint(two);
|
||||
|
||||
openPgpStoreInstance1.importSecretKey(alice, one.getSecretKeys());
|
||||
openPgpStoreInstance1.importSecretKey(alice, two.getSecretKeys());
|
||||
openPgpStoreInstance1.importPublicKey(alice, one.getPublicKeys());
|
||||
openPgpStoreInstance1.importPublicKey(alice, two.getPublicKeys());
|
||||
openPgpStoreInstance1.importSecretKey(alice, one);
|
||||
openPgpStoreInstance1.importSecretKey(alice, two);
|
||||
openPgpStoreInstance1.importPublicKey(alice, KeyRingUtils.publicKeyRingFrom(one));
|
||||
openPgpStoreInstance1.importPublicKey(alice, KeyRingUtils.publicKeyRingFrom(two));
|
||||
|
||||
assertTrue(Arrays.equals(one.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint1).getEncoded()));
|
||||
assertTrue(Arrays.equals(two.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint2).getEncoded()));
|
||||
assertArrayEquals(one.getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint1).getEncoded());
|
||||
assertArrayEquals(two.getEncoded(), openPgpStoreInstance1.getSecretKeyRing(alice, fingerprint2).getEncoded());
|
||||
|
||||
assertTrue(Arrays.equals(one.getSecretKeys().getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getSecretKeyRing(fingerprint1.getKeyId()).getEncoded()));
|
||||
assertArrayEquals(one.getEncoded(), openPgpStoreInstance1.getSecretKeysOf(alice).getSecretKeyRing(fingerprint1.getKeyId()).getEncoded());
|
||||
|
||||
assertTrue(Arrays.equals(one.getPublicKeys().getEncoded(),
|
||||
openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint1).getEncoded()));
|
||||
assertArrayEquals(KeyRingUtils.publicKeyRingFrom(one).getEncoded(), openPgpStoreInstance1.getPublicKeyRing(alice, fingerprint1).getEncoded());
|
||||
|
||||
// Cleanup
|
||||
openPgpStoreInstance1.deletePublicKeyRing(alice, fingerprint1);
|
||||
|
|
@ -320,8 +319,8 @@ public class OpenPgpStoreTest extends SmackTestSuite {
|
|||
assertFalse(openPgpStoreInstance2.getAnnouncedFingerprintsOf(alice).isEmpty());
|
||||
assertEquals(map, openPgpStoreInstance2.getAnnouncedFingerprintsOf(alice));
|
||||
|
||||
openPgpStoreInstance1.setAnnouncedFingerprintsOf(alice, Collections.<OpenPgpV4Fingerprint, Date>emptyMap());
|
||||
openPgpStoreInstance2.setAnnouncedFingerprintsOf(alice, Collections.<OpenPgpV4Fingerprint, Date>emptyMap());
|
||||
openPgpStoreInstance1.setAnnouncedFingerprintsOf(alice, Collections.emptyMap());
|
||||
openPgpStoreInstance2.setAnnouncedFingerprintsOf(alice, Collections.emptyMap());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -16,9 +16,9 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -35,7 +35,6 @@ import org.jivesoftware.smack.packet.ExtensionElement;
|
|||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.ox.crypto.OpenPgpElementAndMetadata;
|
||||
import org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider;
|
||||
import org.jivesoftware.smackx.ox.element.CryptElement;
|
||||
|
|
@ -46,6 +45,8 @@ import org.jivesoftware.smackx.ox.store.definition.OpenPgpStore;
|
|||
import org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
@ -53,8 +54,8 @@ import org.jxmpp.jid.BareJid;
|
|||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.collection.PGPKeyRing;
|
||||
import org.pgpainless.key.protection.UnprotectedKeysProtector;
|
||||
import org.pgpainless.key.util.KeyRingUtils;
|
||||
|
||||
public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
||||
|
||||
|
|
@ -88,17 +89,19 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
PainlessOpenPgpProvider aliceProvider = new PainlessOpenPgpProvider(aliceStore);
|
||||
PainlessOpenPgpProvider bobProvider = new PainlessOpenPgpProvider(bobStore);
|
||||
|
||||
PGPKeyRing aliceKeys = aliceStore.generateKeyRing(alice);
|
||||
PGPKeyRing bobKeys = bobStore.generateKeyRing(bob);
|
||||
PGPSecretKeyRing aliceKeys = aliceStore.generateKeyRing(alice);
|
||||
PGPSecretKeyRing bobKeys = bobStore.generateKeyRing(bob);
|
||||
PGPPublicKeyRing alicePubKeys = KeyRingUtils.publicKeyRingFrom(aliceKeys);
|
||||
PGPPublicKeyRing bobPubKeys = KeyRingUtils.publicKeyRingFrom(bobKeys);
|
||||
|
||||
OpenPgpV4Fingerprint aliceFingerprint = new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys());
|
||||
OpenPgpV4Fingerprint bobFingerprint = new OpenPgpV4Fingerprint(bobKeys.getPublicKeys());
|
||||
OpenPgpV4Fingerprint aliceFingerprint = new OpenPgpV4Fingerprint(aliceKeys);
|
||||
OpenPgpV4Fingerprint bobFingerprint = new OpenPgpV4Fingerprint(bobKeys);
|
||||
|
||||
aliceStore.importSecretKey(alice, aliceKeys.getSecretKeys());
|
||||
bobStore.importSecretKey(bob, bobKeys.getSecretKeys());
|
||||
aliceStore.importSecretKey(alice, aliceKeys);
|
||||
bobStore.importSecretKey(bob, bobKeys);
|
||||
|
||||
aliceStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys()), new Date()));
|
||||
bobStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(new OpenPgpV4Fingerprint(bobKeys.getPublicKeys()), new Date()));
|
||||
aliceStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(aliceFingerprint, new Date()));
|
||||
bobStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(bobFingerprint, new Date()));
|
||||
|
||||
OpenPgpSelf aliceSelf = new OpenPgpSelf(alice, aliceStore);
|
||||
aliceSelf.trust(aliceFingerprint);
|
||||
|
|
@ -107,11 +110,11 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
|
||||
// Exchange keys
|
||||
|
||||
aliceStore.importPublicKey(bob, bobKeys.getPublicKeys());
|
||||
bobStore.importPublicKey(alice, aliceKeys.getPublicKeys());
|
||||
aliceStore.importPublicKey(bob, bobPubKeys);
|
||||
bobStore.importPublicKey(alice, alicePubKeys);
|
||||
|
||||
aliceStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(new OpenPgpV4Fingerprint(bobKeys.getPublicKeys()), new Date()));
|
||||
bobStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(new OpenPgpV4Fingerprint(aliceKeys.getPublicKeys()), new Date()));
|
||||
aliceStore.setAnnouncedFingerprintsOf(bob, Collections.singletonMap(bobFingerprint, new Date()));
|
||||
bobStore.setAnnouncedFingerprintsOf(alice, Collections.singletonMap(aliceFingerprint, new Date()));
|
||||
|
||||
OpenPgpContact aliceForBob = new OpenPgpContact(alice, bobStore);
|
||||
aliceForBob.trust(aliceFingerprint);
|
||||
|
|
@ -121,7 +124,7 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
// Prepare message
|
||||
|
||||
Message.Body body = new Message.Body(null, "Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
|
||||
List<ExtensionElement> payload = Collections.<ExtensionElement>singletonList(body);
|
||||
List<ExtensionElement> payload = Collections.singletonList(body);
|
||||
|
||||
|
||||
OpenPgpElementAndMetadata encrypted;
|
||||
|
|
@ -141,7 +144,7 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
|
||||
OpenPgpV4Fingerprint decryptionFingerprint = decrypted.getMetadata().getDecryptionFingerprint();
|
||||
assertTrue(bobSelf.getSecretKeys().contains(decryptionFingerprint.getKeyId()));
|
||||
assertTrue(decrypted.getMetadata().getVerifiedSignatureKeyFingerprints().contains(aliceFingerprint));
|
||||
assertTrue(decrypted.getMetadata().containsVerifiedSignatureFrom(alicePubKeys));
|
||||
|
||||
assertEquals(OpenPgpMessage.State.signcrypt, decrypted.getState());
|
||||
SigncryptElement decryptedSignCrypt = (SigncryptElement) decrypted.getOpenPgpContentElement();
|
||||
|
|
@ -172,7 +175,7 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
test sign
|
||||
*/
|
||||
|
||||
SignElement signElement = new SignElement(Collections.<Jid>singleton(bob), new Date(), payload);
|
||||
SignElement signElement = new SignElement(Collections.singleton(bob), new Date(), payload);
|
||||
|
||||
// Sign
|
||||
encrypted = aliceProvider.sign(signElement, aliceSelf);
|
||||
|
|
@ -180,7 +183,7 @@ public class PainlessOpenPgpProviderTest extends SmackTestSuite {
|
|||
decrypted = bobProvider.decryptAndOrVerify(bobConnection, encrypted.getElement(), bobSelf, aliceForBob);
|
||||
|
||||
assertNull(decrypted.getMetadata().getDecryptionFingerprint());
|
||||
assertTrue(decrypted.getMetadata().getVerifiedSignatureKeyFingerprints().contains(aliceFingerprint));
|
||||
assertTrue(decrypted.getMetadata().containsVerifiedSignatureFrom(alicePubKeys));
|
||||
|
||||
assertEquals(OpenPgpMessage.State.sign, decrypted.getState());
|
||||
SignElement decryptedSign = (SignElement) decrypted.getOpenPgpContentElement();
|
||||
|
|
|
|||
|
|
@ -16,20 +16,18 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
||||
import org.jivesoftware.smackx.ox.util.OpenPgpPubSubUtil;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
|
||||
public class PubSubDelegateTest extends SmackTestSuite {
|
||||
|
||||
@Test
|
||||
public void pubkeyNodeNameTest() throws PGPException {
|
||||
public void pubkeyNodeNameTest() {
|
||||
OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint("486f7065207520646f6e2068617665204f43640a");
|
||||
assertEquals("urn:xmpp:openpgp:0:public-keys:486F7065207520646F6E2068617665204F43640A",
|
||||
OpenPgpPubSubUtil.PEP_NODE_PUBLIC_KEY(fingerprint));
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
|
|
|||
|
|
@ -16,19 +16,17 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.ox.element.PublicKeysListElement;
|
||||
import org.jivesoftware.smackx.ox.provider.PublicKeysListElementProvider;
|
||||
|
||||
import org.bouncycastle.openpgp.PGPException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.util.XmppDateTime;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
|
|
@ -72,7 +70,7 @@ public class PublicKeysListElementTest extends SmackTestSuite {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void listBuilderRefusesDuplicatesTest() throws PGPException {
|
||||
public void listBuilderRefusesDuplicatesTest() {
|
||||
PublicKeysListElement.Builder builder = PublicKeysListElement.builder();
|
||||
String fp40 = "49545320414c4c2041424f555420444120484558";
|
||||
Date oneDate = new Date(12337883234L);
|
||||
|
|
|
|||
|
|
@ -16,15 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
|
|
@ -40,12 +38,12 @@ import org.bouncycastle.openpgp.PGPException;
|
|||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.pgpainless.PGPainless;
|
||||
import org.pgpainless.key.OpenPgpV4Fingerprint;
|
||||
import org.pgpainless.key.collection.PGPKeyRing;
|
||||
|
||||
public class SecretKeyBackupHelperTest extends SmackTestSuite {
|
||||
|
||||
|
|
@ -72,7 +70,7 @@ public class SecretKeyBackupHelperTest extends SmackTestSuite {
|
|||
|
||||
@Test
|
||||
public void createAndDecryptSecretKeyElementTest()
|
||||
throws PGPException, NoSuchAlgorithmException, NoSuchProviderException, InvalidAlgorithmParameterException,
|
||||
throws PGPException, NoSuchAlgorithmException, InvalidAlgorithmParameterException,
|
||||
IOException, MissingUserIdOnKeyException, MissingOpenPgpKeyException, InvalidBackupCodeException {
|
||||
|
||||
// Prepare store and provider and so on...
|
||||
|
|
@ -80,18 +78,18 @@ public class SecretKeyBackupHelperTest extends SmackTestSuite {
|
|||
PainlessOpenPgpProvider provider = new PainlessOpenPgpProvider(store);
|
||||
|
||||
// Generate and import key
|
||||
PGPKeyRing keyRing = PGPainless.generateKeyRing().simpleEcKeyRing("xmpp:alice@wonderland.lit");
|
||||
PGPSecretKeyRing secretKeys = PGPainless.generateKeyRing().simpleEcKeyRing("xmpp:alice@wonderland.lit");
|
||||
BareJid jid = JidCreate.bareFrom("alice@wonderland.lit");
|
||||
provider.getStore().importSecretKey(jid, keyRing.getSecretKeys());
|
||||
provider.getStore().importSecretKey(jid, secretKeys);
|
||||
|
||||
// Create encrypted backup
|
||||
OpenPgpSecretKeyBackupPassphrase backupCode = SecretKeyBackupHelper.generateBackupPassword();
|
||||
SecretkeyElement element = SecretKeyBackupHelper.createSecretkeyElement(provider, jid,
|
||||
Collections.singleton(new OpenPgpV4Fingerprint(keyRing.getSecretKeys())), backupCode);
|
||||
Collections.singleton(new OpenPgpV4Fingerprint(secretKeys)), backupCode);
|
||||
|
||||
// Decrypt backup and compare
|
||||
PGPSecretKeyRing secretKeyRing = SecretKeyBackupHelper.restoreSecretKeyBackup(element, backupCode);
|
||||
assertArrayEquals(keyRing.getSecretKeys().getEncoded(), secretKeyRing.getEncoded());
|
||||
Assertions.assertArrayEquals(secretKeys.getEncoded(), secretKeyRing.getEncoded());
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
|||
|
|
@ -16,16 +16,14 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.jivesoftware.smack.test.util.XmlAssertUtil.assertXmlSimilar;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParser;
|
||||
|
||||
import org.jivesoftware.smackx.ox.element.SecretkeyElement;
|
||||
import org.jivesoftware.smackx.ox.provider.SecretkeyElementProvider;
|
||||
|
||||
|
|
@ -48,6 +46,6 @@ public class SecretkeyElementTest extends SmackTestSuite {
|
|||
XmlPullParser parser = TestUtils.getParser(expected);
|
||||
SecretkeyElement parsed = SecretkeyElementProvider.TEST_INSTANCE.parse(parser);
|
||||
|
||||
assertTrue(Arrays.equals(element.getB64Data(), parsed.getB64Data()));
|
||||
assertArrayEquals(element.getB64Data(), parsed.getB64Data());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,162 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2018 Paul Schaub.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.ox;
|
||||
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
public class TestKeys {
|
||||
|
||||
public TestKeys() {
|
||||
|
||||
}
|
||||
|
||||
public static final BareJid JULIET_JID;
|
||||
public static final BareJid ROMEO_JID;
|
||||
|
||||
static {
|
||||
try {
|
||||
JULIET_JID = JidCreate.bareFrom("juliet@capulet.lit");
|
||||
ROMEO_JID = JidCreate.bareFrom("romeo@montague.lit");
|
||||
} catch (XmppStringprepException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String JULIET_UID = "xmpp:juliet@capulet.lit";
|
||||
|
||||
/**
|
||||
* Public key of xmpp:juliet@capulet.lit.
|
||||
*/
|
||||
public static final String JULIET_PUB =
|
||||
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"mQENBFrxov4BCAChZwPrBxxIlwzpieR5T2pnaOZLWH0WqSON6rVjvfbJHWdDi3Th\n" +
|
||||
"remHW4gg4IBSTXkVFDIeQNVcOvGNgMg3Oe/x0I6FK12jrw9prycmjFxQ7A0ix7ZG\n" +
|
||||
"UkTF5jITgzJbkH100gYfXtZsfTyvgISSAT//6vvvQPZ3zCr09XvAG0CyQ1BhULsv\n" +
|
||||
"mVRe4Oh5b0VK4kLdv+GiA/T+49UKZj6lne9Vdti16ZIj7teVCbicfdhpTzsjur42\n" +
|
||||
"r8ptouKAuyFPw9KnGNwVlIiv5jt/Kit/LoOBenh74sitsCXq8IQ9kKp/eNt8TF4u\n" +
|
||||
"D4IGpxnJfB8XCiixYHoFEajmQBVJXNYtvoPvABEBAAG0F3htcHA6anVsaWV0QGNh\n" +
|
||||
"cHVsZXQubGl0iQFOBBMBCAA4FiEEHQGMdy34xe+GodzJtLUJy1k24D4FAlrxov4C\n" +
|
||||
"Gy8FCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQtLUJy1k24D6H7AgAoTjx4ezc\n" +
|
||||
"A83NeOY3tMHVQTM7hKuy0wMcSzQgVgJmhLYRZS8r+FocPZua/eke49GPhe2yozvl\n" +
|
||||
"ByWHtotklQeJiwOKxuPKMzneVA1ZK3/9LdGvtZlHMcAkEKDhit8HIaEcsFd4Z1re\n" +
|
||||
"EhF2lyvY/E+rrx9YxV0QjisSWV2dSptv6FeGSztr9e5E+Head6hEQhsugiTVRF+1\n" +
|
||||
"6mG90te0WGQ9YNiJ2FJovx5kBLTTuhwUz8Oacqihd2+RDDI5p3wJoogVL31aNb4n\n" +
|
||||
"c7dGo8ieJPHGlkBsOfmreSxijTodZz9MXsgcx7b//u0uQryViJoZHWbtnXOFjjNc\n" +
|
||||
"GWBtS084NKWl9w==\n" +
|
||||
"=ecwX\n" +
|
||||
"-----END PGP PUBLIC KEY BLOCK-----";
|
||||
|
||||
/**
|
||||
* Private key of xmpp:juliet@capulet.lit.
|
||||
*/
|
||||
public static final String JULIET_PRIV =
|
||||
"-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"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\n" +
|
||||
"=yPPE\n" +
|
||||
"-----END PGP PRIVATE KEY BLOCK-----";
|
||||
|
||||
public static final String ROMEO_UID = "xmpp:romeo@montague.lit";
|
||||
|
||||
/**
|
||||
* Public key of xmpp:romeo@montague.lit.
|
||||
*/
|
||||
public static final String ROMEO_PUB =
|
||||
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"mQENBFrxopkBCADiYg/+mEObXgxuMW6/LFKpEyaJK9pBMgutuxnYZ9PXWZmOhDIT\n" +
|
||||
"Ugm9X9YJ3Qh94KaHge9F4uCeFASmM1vvUTRFTEb1W5RR9ZE/sy/cdAttnZ5JloPi\n" +
|
||||
"CT3HDMIJAxIXhRJkeUR9GUb51ql27bMXl6lFh865VdNSXN/B8FzRQHENxv1Bq/6Z\n" +
|
||||
"iQOViIETeRRgO+u6u2iZkYlHgYMaoMK7+YiNlHXanU9Atcuaz0ZCJS/XFNH89iqB\n" +
|
||||
"Kvnv7KCQh4FhrNMLJRzNPXV8MY05nn0zF72qeEsniB16Xde18lMro8fQehg2mLwc\n" +
|
||||
"XGtCwCKI6QbZVxYQt77r3ZACiwl66soFWijVABEBAAG0F3htcHA6cm9tZW9AbW9u\n" +
|
||||
"dGFndWUubGl0iQFOBBMBCAA4FiEENdKZ0IovfYAjCwldBKMhguBeIfcFAlrxopkC\n" +
|
||||
"Gy8FCwkIBwIGFQoJCAsCBBYCAwECHgECF4AACgkQBKMhguBeIfcj8AgAu1wubUwr\n" +
|
||||
"2aQmDN3OqRM4M4yRL3oyYMkCKIjqD6KEeFsIXSSkXOuREJKEo8Mb1+ewV0SYmHCC\n" +
|
||||
"K3bKKq3m71AQ7evDhKGshacPYesiDvMdHWQdQnjfaoHhyn9qIKl7H0Xv1yf/wyuG\n" +
|
||||
"ANy1jYgtCEuYw7D+EsqNDdn8Xh+k/9s4aMI/6mfC0yGZgG8EyLTfbZkGPoS4aZfV\n" +
|
||||
"AGFbuqryg48dXtnuzAPKcdgMTTMSnmR729YlfkjCffcFaldyXoe1VMbudUO7nkO9\n" +
|
||||
"g65i5EXenkbc2h0TRDQ4lDFQyModqFTwYFYxAf/RA6tuhIQEoCnpCytFMvrRKMb3\n" +
|
||||
"Bx5vYRDVmE3jeg==\n" +
|
||||
"=2jSg\n" +
|
||||
"-----END PGP PUBLIC KEY BLOCK-----";
|
||||
|
||||
/**
|
||||
* Private key of xmpp:romeo@montague.lit.
|
||||
*/
|
||||
public static final String ROMEO_PRIV =
|
||||
"-----BEGIN PGP PRIVATE KEY BLOCK-----\n" +
|
||||
"\n" +
|
||||
"lQOYBFrxopkBCADiYg/+mEObXgxuMW6/LFKpEyaJK9pBMgutuxnYZ9PXWZmOhDIT\n" +
|
||||
"Ugm9X9YJ3Qh94KaHge9F4uCeFASmM1vvUTRFTEb1W5RR9ZE/sy/cdAttnZ5JloPi\n" +
|
||||
"CT3HDMIJAxIXhRJkeUR9GUb51ql27bMXl6lFh865VdNSXN/B8FzRQHENxv1Bq/6Z\n" +
|
||||
"iQOViIETeRRgO+u6u2iZkYlHgYMaoMK7+YiNlHXanU9Atcuaz0ZCJS/XFNH89iqB\n" +
|
||||
"Kvnv7KCQh4FhrNMLJRzNPXV8MY05nn0zF72qeEsniB16Xde18lMro8fQehg2mLwc\n" +
|
||||
"XGtCwCKI6QbZVxYQt77r3ZACiwl66soFWijVABEBAAEAB/4mu5p69/hRQ+UikWie\n" +
|
||||
"Yun9rZ4hSBR+pR5kaifA4/rV1Km2PZ4HujiaYyRO6beDOgWkF7IlpezCfzBQc2ce\n" +
|
||||
"ailkVemqHzIgV8CzQmhE8sHlzlr/wjXsXaJpRSCJxDG7PnRoJmt2b/W512WFSKQk\n" +
|
||||
"vDklAVh4U1vlsqhCGWr4DmuJbJkRyDhcX01tplRwim283F7bGqRcMBmKMZHiMgVc\n" +
|
||||
"0u84EYKKVizJ3YAaaVqZyHb4qdeKK2ak3fPNuGT/oGd2sxnkL+BZGjJpu3RGpTA1\n" +
|
||||
"tbOvOQnJGHQtABFxE8n6H9dHPJGtgyz2+udjUhL/P/E3PDoXazZkXRq2oHZKgg0f\n" +
|
||||
"AwOBBADsWncHgvz15rXPF7O6AivbGTJ5ctkgVy4U3Fu2sk9rf0fx0sryBSqtTBw1\n" +
|
||||
"Uvn/p9RwTsKw6fng6Nf78xpZFlUDB00YCcuWkGodxvjTAyB0dtBmkhopeKi0dmHh\n" +
|
||||
"ndnR6Pv0CsXu8nG7lUi+q6s3oc4h2OfDBhrqsyYY5M2gGit3dQQA9TNuinJD9XXv\n" +
|
||||
"QRyauMnSJ5xRcfOu8QCxZlllCvffZjSGCPoVjUpJEe9qsVbXVj2GYCxjLCSXV0V+\n" +
|
||||
"vlJfdPrl1BhZ3fmEpg0u7SyGDDOe8fe1ehk5sAeL8O0eFWlPSEaEccsjlpJ2FO0n\n" +
|
||||
"P04SZdOeM6wmhDTEDzpFnjbPndQTH+ED/R1zNzr55DvxQodmrW/BvTmhGQ22rHtk\n" +
|
||||
"IUfbeMaVfUvNLJA/JksrUIx3Gga9QCDZgfm1RsRhLUlHiqTQe23sPWgKOsbf5O1j\n" +
|
||||
"XJZaCNZ7LloVQbkG7xFcnb/n1+JjBr4FxXjAA6cY/iRGlznjIIaasyklKm1/4LuQ\n" +
|
||||
"hnH3QqTvCN3dOFS0F3htcHA6cm9tZW9AbW9udGFndWUubGl0iQFOBBMBCAA4FiEE\n" +
|
||||
"NdKZ0IovfYAjCwldBKMhguBeIfcFAlrxopkCGy8FCwkIBwIGFQoJCAsCBBYCAwEC\n" +
|
||||
"HgECF4AACgkQBKMhguBeIfcj8AgAu1wubUwr2aQmDN3OqRM4M4yRL3oyYMkCKIjq\n" +
|
||||
"D6KEeFsIXSSkXOuREJKEo8Mb1+ewV0SYmHCCK3bKKq3m71AQ7evDhKGshacPYesi\n" +
|
||||
"DvMdHWQdQnjfaoHhyn9qIKl7H0Xv1yf/wyuGANy1jYgtCEuYw7D+EsqNDdn8Xh+k\n" +
|
||||
"/9s4aMI/6mfC0yGZgG8EyLTfbZkGPoS4aZfVAGFbuqryg48dXtnuzAPKcdgMTTMS\n" +
|
||||
"nmR729YlfkjCffcFaldyXoe1VMbudUO7nkO9g65i5EXenkbc2h0TRDQ4lDFQyMod\n" +
|
||||
"qFTwYFYxAf/RA6tuhIQEoCnpCytFMvrRKMb3Bx5vYRDVmE3jeg==\n" +
|
||||
"=LZ1b\n" +
|
||||
"-----END PGP PRIVATE KEY BLOCK-----";
|
||||
}
|
||||
|
|
@ -16,10 +16,10 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ox_im;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static junit.framework.TestCase.assertNotNull;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -32,14 +32,12 @@ import java.util.Date;
|
|||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.packet.MessageBuilder;
|
||||
import org.jivesoftware.smack.packet.StanzaBuilder;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.util.StringUtils;
|
||||
import org.jivesoftware.smack.xml.XmlPullParserException;
|
||||
|
||||
import org.jivesoftware.smackx.eme.element.ExplicitMessageEncryptionElement;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpContact;
|
||||
import org.jivesoftware.smackx.ox.OpenPgpManager;
|
||||
|
|
@ -137,7 +135,7 @@ public class OXInstantMessagingManagerTest extends SmackTestSuite {
|
|||
assertFalse(ExplicitMessageEncryptionElement.hasProtocol(messageBuilder.build(), ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.openpgpV0));
|
||||
|
||||
aliceOxim.addOxMessage(messageBuilder, bobForAlice,
|
||||
Collections.<ExtensionElement>singletonList(new Message.Body(null, "Hello World!")));
|
||||
Collections.singletonList(new Message.Body(null, "Hello World!")));
|
||||
|
||||
Message message = messageBuilder.build();
|
||||
assertTrue(ExplicitMessageEncryptionElement.hasProtocol(message, ExplicitMessageEncryptionElement.ExplicitMessageEncryptionProtocol.openpgpV0));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue