Java Code Examples for org.bouncycastle.openpgp.PGPSecretKeyRing#getPublicKey()

The following examples show how to use org.bouncycastle.openpgp.PGPSecretKeyRing#getPublicKey() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KeyManagerImpl.java    From peer-os with Apache License 2.0 6 votes vote down vote up
@Override
public void saveSecretKeyRing( String identityId, int type, PGPSecretKeyRing secretKeyRing )
{
    try
    {
        PGPPublicKey publicKey = secretKeyRing.getPublicKey();

        if ( publicKey != null )
        {
            // Store secretKey
            String fingerprint = PGPKeyUtil.getFingerprint( publicKey.getFingerprint() );
            String pwd = keyData.getSecretKeyringPwd();

            //*******************
            securityDataService.saveSecretKeyData( fingerprint, secretKeyRing.getEncoded(), pwd, type );
            securityDataService.saveKeyData( identityId, fingerprint, "", type );
            //*******************
        }
    }
    catch ( Exception ex )
    {
        LOG.error( " ******** Error storing Public key:" + ex.toString(), ex );
    }
}
 
Example 2
Source File: KeyFilesOperationsPgpImpl.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
protected static KeyInfo buildKeyInfoFromSecret(PGPSecretKeyRing secretKeyRing) throws PGPException {
	KeyInfo ret = new KeyInfo();
	ret.setKeyType(KeyTypeEnum.KeyPair);
	PGPPublicKey key = secretKeyRing.getPublicKey();
	ret.setUser(buildUser(key.getUserIDs()));

	ret.setKeyId(KeyDataPgp.buildKeyIdStr(key.getKeyID()));
	fillDates(ret, key);
	fillAlgorithmName(ret, key);
	return ret;
}
 
Example 3
Source File: OpenPgpSelf.java    From Smack with Apache License 2.0 2 votes vote down vote up
/**
 * Return the {@link OpenPgpV4Fingerprint} of our signing key.
 * @return fingerprint of signing key
 * @throws IOException IO is dangerous
 * @throws PGPException PGP is brittle
 */
public OpenPgpV4Fingerprint getSigningKeyFingerprint() throws IOException, PGPException {
    PGPSecretKeyRing signingKeyRing = getSigningKeyRing();
    return signingKeyRing != null ? new OpenPgpV4Fingerprint(signingKeyRing.getPublicKey()) : null;
}