TrustStoreImpl extends ComponentSupport implements EventAware, TrustStore { @Override public void removeTrustCertificate(final String alias) throws KeystoreException { freezeService.checkWritable("Unable to remove a certificate while database is frozen."); Certificate certificate = getTrustedCertificate(alias); keyStoreManager.removeTrustCertificate(alias); sslcontext = null; eventManager.post(new CertificateDeletedEvent(alias, certificate)); log.info( "Certificate removed successfully from trust-store with Fingerprint : {}, Name : {} and SHA1 Identifier : {}", alias, getCertificateName(certificate), getCertificateSha1(certificate)); } @Inject  TrustStoreImpl(final EventManager eventManager,
                        @Named("ssl") final KeyStoreManager keyStoreManager,
                        final FreezeService freezeService); @Override Certificate importTrustCertificate(final Certificate certificate, final String alias); @Override Certificate importTrustCertificate(final String certificateInPEM, final String alias); @Override Certificate getTrustedCertificate(final String alias); @Override Collection<Certificate> getTrustedCertificates(); @Override void removeTrustCertificate(final String alias); @Override SSLContext getSSLContext(); @Override KeyManager[] getKeyManagers(); @Subscribe void onKeyStoreDataUpdated(final KeyStoreDataEvent event); static final SecureRandom DEFAULT_RANDOM; }
@Test public void testDelete_frozen() throws KeystoreException { doThrow(frozenException).when(freezeService).checkWritable(anyString()); try { underTest.removeTrustCertificate("test"); fail(); } catch (OModificationOperationProhibitedException e) { } verify(keyStoreManager, times(0)).removeTrustCertificate(anyString()); verifyZeroInteractions(eventManager); }