use of com.google.inject.ProvisionException in project gerrit by GerritCodeReview.
the class InMemoryModule method indexModule.
private Module indexModule(String moduleClassName) {
try {
Class<?> clazz = Class.forName(moduleClassName);
Method m = clazz.getMethod("singleVersionWithExplicitVersions", Map.class, int.class);
return (Module) m.invoke(null, getSingleSchemaVersions(), 0);
} catch (ClassNotFoundException | SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
ProvisionException pe = new ProvisionException(e.getMessage());
pe.initCause(e);
throw pe;
}
}
use of com.google.inject.ProvisionException in project gerrit by GerritCodeReview.
the class HostKeyProvider method get.
@Override
public KeyPairProvider get() {
Path objKey = site.ssh_key;
Path rsaKey = site.ssh_rsa;
Path dsaKey = site.ssh_dsa;
Path ecdsaKey_256 = site.ssh_ecdsa_256;
Path ecdsaKey_384 = site.ssh_ecdsa_384;
Path ecdsaKey_521 = site.ssh_ecdsa_521;
Path ed25519Key = site.ssh_ed25519;
final List<File> stdKeys = new ArrayList<>(6);
if (Files.exists(rsaKey)) {
stdKeys.add(rsaKey.toAbsolutePath().toFile());
}
if (Files.exists(dsaKey)) {
stdKeys.add(dsaKey.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_256)) {
stdKeys.add(ecdsaKey_256.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_384)) {
stdKeys.add(ecdsaKey_384.toAbsolutePath().toFile());
}
if (Files.exists(ecdsaKey_521)) {
stdKeys.add(ecdsaKey_521.toAbsolutePath().toFile());
}
if (Files.exists(ed25519Key)) {
stdKeys.add(ed25519Key.toAbsolutePath().toFile());
}
if (Files.exists(objKey)) {
if (stdKeys.isEmpty()) {
SimpleGeneratorHostKeyProvider p = new SimpleGeneratorHostKeyProvider();
p.setPath(objKey.toAbsolutePath());
return p;
}
// Both formats of host key exist, we don't know which format
// should be authoritative. Complain and abort.
//
stdKeys.add(objKey.toAbsolutePath().toFile());
throw new ProvisionException("Multiple host keys exist: " + stdKeys);
}
if (stdKeys.isEmpty()) {
throw new ProvisionException("No SSH keys under " + site.etc_dir);
}
FileKeyPairProvider kp = new FileKeyPairProvider();
kp.setFiles(stdKeys);
return kp;
}
Aggregations