Example usage for org.bouncycastle.openpgp PGPPublicKeyRing getEncoded

List of usage examples for org.bouncycastle.openpgp PGPPublicKeyRing getEncoded

Introduction

In this page you can find the example usage for org.bouncycastle.openpgp PGPPublicKeyRing getEncoded.

Prototype

public byte[] getEncoded(boolean forTransfer) throws IOException 

Source Link

Document

Return an encoding of the key ring, with trust packets stripped out if forTransfer is true.

Usage

From source file:org.jivesoftware.smackx.ox.OpenPgpManager.java

License:Apache License

/**
 * Create a {@link PubkeyElement} which contains the OpenPGP public key of {@code owner} which belongs to
 * the {@link OpenPgpV4Fingerprint} {@code fingerprint}.
 *
 * @param owner owner of the public key//from  w  ww  . ja va 2  s.  c  o  m
 * @param fingerprint fingerprint of the key
 * @param date date of creation of the element
 * @return {@link PubkeyElement} containing the key
 *
 * @throws MissingOpenPgpKeyException if the public key notated by the fingerprint cannot be found
 */
private PubkeyElement createPubkeyElement(BareJid owner, OpenPgpV4Fingerprint fingerprint, Date date)
        throws MissingOpenPgpKeyException, IOException, PGPException {
    PGPPublicKeyRing ring = provider.getStore().getPublicKeyRing(owner, fingerprint);
    if (ring != null) {
        byte[] keyBytes = ring.getEncoded(true);
        return createPubkeyElement(keyBytes, date);
    }
    throw new MissingOpenPgpKeyException(owner, fingerprint);
}