Search in sources :

Example 6 with SecretkeyElement

use of org.jivesoftware.smackx.ox.element.SecretkeyElement in project Smack by igniterealtime.

the class SecretkeyElementTest method providerTest.

@Test
public void providerTest() throws Exception {
    String expected = "<secretkey xmlns='urn:xmpp:openpgp:0'>" + "BASE64_OPENPGP_ENCRYPTED_SECRET_KEY" + "</secretkey>";
    byte[] key = "BASE64_OPENPGP_ENCRYPTED_SECRET_KEY".getBytes(Charset.forName("UTF-8"));
    SecretkeyElement element = new SecretkeyElement(key);
    assertXmlSimilar(expected, element.toXML().toString());
    XmlPullParser parser = TestUtils.getParser(expected);
    SecretkeyElement parsed = SecretkeyElementProvider.TEST_INSTANCE.parse(parser);
    assertArrayEquals(element.getB64Data(), parsed.getB64Data());
}
Also used : SecretkeyElement(org.jivesoftware.smackx.ox.element.SecretkeyElement) XmlPullParser(org.jivesoftware.smack.xml.XmlPullParser) Test(org.junit.jupiter.api.Test)

Aggregations

SecretkeyElement (org.jivesoftware.smackx.ox.element.SecretkeyElement)6 PGPSecretKeyRing (org.bouncycastle.openpgp.PGPSecretKeyRing)3 OpenPgpV4Fingerprint (org.pgpainless.key.OpenPgpV4Fingerprint)3 Test (org.junit.jupiter.api.Test)2 BareJid (org.jxmpp.jid.BareJid)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 HashSet (java.util.HashSet)1 PGPSecretKeyRingCollection (org.bouncycastle.openpgp.PGPSecretKeyRingCollection)1 XmlPullParser (org.jivesoftware.smack.xml.XmlPullParser)1 PainlessOpenPgpProvider (org.jivesoftware.smackx.ox.crypto.PainlessOpenPgpProvider)1 NoBackupFoundException (org.jivesoftware.smackx.ox.exception.NoBackupFoundException)1 FileBasedOpenPgpStore (org.jivesoftware.smackx.ox.store.filebased.FileBasedOpenPgpStore)1 LeafNode (org.jivesoftware.smackx.pubsub.LeafNode)1 PayloadItem (org.jivesoftware.smackx.pubsub.PayloadItem)1 PubSubManager (org.jivesoftware.smackx.pubsub.PubSubManager)1 EntityBareJid (org.jxmpp.jid.EntityBareJid)1 EncryptionOptions (org.pgpainless.encryption_signing.EncryptionOptions)1 EncryptionStream (org.pgpainless.encryption_signing.EncryptionStream)1