Catch missing BouncyCastle PGP during contact store creation

If the class isn't found, we return the dummy store which
is disabled.  This is necessary because PGP installation is
an optional dependency.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-08-08 12:26:47 -07:00
parent 080b40f7bb
commit 278d48534e

View File

@@ -45,19 +45,28 @@ public class EncryptedContactStoreProvider implements Provider<ContactStore> {
public ContactStore get() {
try {
return new EncryptedContactStore(config, sitePath, schema);
} catch (NoClassDefFoundError notInstalled) {
return noContact(new ContactInformationStoreException(
new ClassNotFoundException("BouncyCastle PGP not installed",
notInstalled)));
} catch (final ContactInformationStoreException initError) {
return new ContactStore() {
@Override
public boolean isEnabled() {
return false;
}
@Override
public void store(Account account, ContactInformation info)
throws ContactInformationStoreException {
throw initError;
}
};
return noContact(initError);
}
}
private ContactStore noContact(
final ContactInformationStoreException initError) {
return new ContactStore() {
@Override
public boolean isEnabled() {
return false;
}
@Override
public void store(Account account, ContactInformation info)
throws ContactInformationStoreException {
throw initError;
}
};
}
}