KeyManagerImpl implements KeyManager { @Override public PGPPublicKeyRing setKeyTrust( PGPSecretKeyRing sourceSecRing, PGPPublicKeyRing targetPubRing, int trustLevel ) { String sFingerprint = PGPKeyUtil.getFingerprint( sourceSecRing.getPublicKey().getFingerprint() ); String tFingerprint = PGPKeyUtil.getFingerprint( targetPubRing.getPublicKey().getFingerprint() ); SecurityKeyTrust keyTrust = securityDataService.getKeyTrustData( sFingerprint, tFingerprint ); try { if ( keyTrust == null ) { keyTrust = saveKeyTrustData( sFingerprint, tFingerprint, KeyTrustLevel.NEVER.getId() ); } if ( trustLevel == KeyTrustLevel.NEVER.getId() ) { targetPubRing = removeSignature( sourceSecRing.getPublicKey(), targetPubRing ); updatePublicKeyRing( targetPubRing ); } else { if ( keyTrust.getLevel() == KeyTrustLevel.NEVER.getId() ) { targetPubRing = signKey( sourceSecRing, targetPubRing, trustLevel ); updatePublicKeyRing( targetPubRing ); } } keyTrust.setLevel( trustLevel ); securityDataService.updateKeyTrustData( keyTrust ); } catch ( Exception ex ) { LOG.error( " **** Error!!! Error creating key trust:" + ex.toString(), ex ); } return targetPubRing; } KeyManagerImpl( SecurityDataService securityDataService, KeyServer keyServer,
                           SecurityKeyData securityKeyData ); @Override String getPeerId(); @Override void setPeerOwnerId( String id ); @Override String getPeerOwnerId(); @Override PGPPublicKeyRing signKey( PGPSecretKeyRing sourceSecRing, PGPPublicKeyRing targetPubRing, int trustLevel ); @Override PGPPublicKeyRing signKey( String sourceFingerprint, String targetFingerprint, int trustLevel ); @Override String signPublicKey( String sourceIdentityId, String keyText, int trustLevel ); @Override PGPPublicKeyRing setKeyTrust( PGPSecretKeyRing sourceSecRing, PGPPublicKeyRing targetPubRing,
                                         int trustLevel ); @Override PGPPublicKeyRing setKeyTrust( String sourceFingerprint, String targetFingerprint, int trustLevel ); @Override boolean verifySignature( String sourceFingerprint, String targetFingerprint ); @Override boolean verifySignature( PGPPublicKeyRing sourcePubRing, PGPPublicKeyRing targetPubRing ); @Override PGPPublicKeyRing removeSignature( String sourceFingerprint, String targetFingerprint ); @Override PGPPublicKeyRing removeSignature( PGPPublicKey sourcePublicKey, PGPPublicKeyRing targetPubRing ); @Override SecurityKeyTrust getKeyTrustData( String sourceFingerprint, String targetFingerprint ); @Override List<SecurityKeyTrust> getKeyTrustData( final String sourceFingerprint ); @Override void removeKeyTrust( String sourceFingerprint ); @Override void removeKeyAllTrustData( String fingerprint ); @Override void removeKeyTrustData( String sourceFingerprint, String targetFingerprint ); @Override SecurityKeyTrust saveKeyTrustData( String sourceFingerprint, String targetFingerprint, int trustLevel ); @Override void saveSecretKeyRing( String identityId, int type, PGPSecretKeyRing secretKeyRing ); @Override void savePublicKeyRing( String identityId, int type, String keyringAsASCII ); @Override void savePublicKeyRing( String identityId, int type, PGPPublicKeyRing publicKeyRing ); @Override void removePublicKeyRing( String identityId ); @Override void removeSecretKeyRing( String identityId ); @Override SecurityKey getKeyData( String identityId ); @Override SecurityKey getKeyDataByFingerprint( String fingerprint ); @Override void removeKeyData( String identityId ); @Override PGPPublicKey getPublicKey( String identityId ); @Override PGPPublicKeyRing getPublicKeyRingByFingerprint( String fingerprint ); @Override String getPublicKeyRingAsASCII( String identityId ); @Override PGPPublicKeyRing getPublicKeyRing( String identityId ); @Override String getFingerprint( String identityId ); @Override PGPSecretKeyRing getSecretKeyRing( String identityId ); @Override InputStream getSecretKeyRingInputStream( String identityId ); @Override PGPSecretKey getSecretKey( String identityId ); @Override PGPPrivateKey getPrivateKey( String identityId ); @Override void updatePublicKeyRing( final PGPPublicKeyRing publicKeyRing ); @Override PGPSecretKey getSecretKeyByFingerprint( String fingerprint ); @Override PGPSecretKeyRing getSecretKeyRingByFingerprint( String fingerprint ); @Override KeyPair generateKeyPair( String identityId, boolean armored ); @Override void saveKeyPair( String identityId, int type, KeyPair keyPair ); @Override void removeKeyRings( String identityId ); @Override PGPPublicKey getRemoteHostPublicKey( PeerInfo peerInfo ); @Override PGPPublicKey getRemoteHostPublicKey( final String hostIdTarget ); @Override SecurityKey getKeyDetails( final String fingerprint ); @Override SecurityKey getKeyTrustTree( String identityId ); @Override int getTrustLevel( String sourceFingerprint, String targetFingerprint );  }
@Test public void testSetKeyTrust() throws Exception { }