PGPSignatureUtil { public static boolean isSignedBy( PGPPublicKey pubKey, PGPPublicKey signerPubKey ) { PGPSignature sig = getSignatures( pubKey ).get( signerPubKey.getKeyID() ); return sig != null && ( sig.getSignatureType() == PGPSignature.DEFAULT_CERTIFICATION || sig.getSignatureType() == PGPSignature.DIRECT_KEY ); } private  PGPSignatureUtil(); static boolean isSignedBy( PGPPublicKey pubKey, PGPPublicKey signerPubKey ); static Map<Long, PGPSignature> getSignatures( PGPPublicKey pubKey ); static PGPPublicKey mergeSignatures( PGPPublicKey targetKey, PGPPublicKey sourceKey );  }
@Test public void testIsSignedBy() throws Exception { PGPPublicKey applePublicKey = PGPTestDataFactory.getPublicKey( "apple" ); PGPPublicKey alicePublicKey = PGPTestDataFactory.getPublicKey( "alice" ); assertTrue( PGPSignatureUtil.isSignedBy( applePublicKey, alicePublicKey ) ); PGPPublicKey bobbyPublicKey = PGPTestDataFactory.getPublicKey( "bobby" ); assertFalse( PGPSignatureUtil.isSignedBy( applePublicKey, bobbyPublicKey ) ); }