Fix for upstream ssh-key changes

Upstream changed ssh key storage to git, resulting
in new exceptions being thrown.

Change-Id: Ifee526c9ebbaba08faebbb1774b6966a3b66472d
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/AddSshKey.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/AddSshKey.java
index 3d9fd1c..c230aaf 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/AddSshKey.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/AddSshKey.java
@@ -25,6 +25,8 @@
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+
 import java.io.IOException;
 
 @Singleton
@@ -38,7 +40,8 @@
 
   @Override
   public Response<SshKeyInfo> apply(ServiceUserResource rsrc, Input input)
-      throws AuthException, BadRequestException, OrmException, IOException {
+      throws AuthException, BadRequestException, OrmException, IOException,
+      ConfigInvalidException {
     return addSshKey.get().apply(rsrc.getUser(), input);
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
index c1684d8..5f95945 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUser.java
@@ -55,6 +55,7 @@
 import com.googlesource.gerrit.plugins.serviceuser.CreateServiceUser.Input;
 import com.googlesource.gerrit.plugins.serviceuser.GetServiceUser.ServiceUserInfo;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.PersonIdent;
 import org.slf4j.Logger;
@@ -152,7 +153,8 @@
   @Override
   public Response<ServiceUserInfo> apply(ConfigResource resource, Input input)
       throws AuthException, BadRequestException, ResourceConflictException,
-      UnprocessableEntityException, OrmException, IOException {
+      UnprocessableEntityException, OrmException, IOException,
+      ConfigInvalidException {
     CurrentUser user = userProvider.get();
     if (user == null || !user.isIdentifiedUser()) {
       throw new AuthException("authentication required");
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java
index feccb9e..98a0556 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/CreateServiceUserCommand.java
@@ -22,6 +22,7 @@
 import com.google.gwtorm.server.OrmException;
 import com.google.inject.Inject;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
 import org.kohsuke.args4j.Argument;
 import org.kohsuke.args4j.Option;
 
@@ -44,7 +45,8 @@
   private CreateServiceUser.Factory createServiceUser;
 
   @Override
-  protected void run() throws OrmException, IOException, UnloggedFailure {
+  protected void run() throws OrmException, IOException, UnloggedFailure,
+      ConfigInvalidException {
     CreateServiceUser.Input input = new CreateServiceUser.Input();
     input.sshKey = readSshKey();
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
index e7e0340..d3685cc 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/DeleteSshKey.java
@@ -24,19 +24,26 @@
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+
+import java.io.IOException;
+
 @Singleton
-class DeleteSshKey implements
-    RestModifyView<ServiceUserResource.SshKey, Input> {
+class DeleteSshKey
+    implements RestModifyView<ServiceUserResource.SshKey, Input> {
   private final Provider<com.google.gerrit.server.account.DeleteSshKey> deleteSshKey;
 
   @Inject
-  DeleteSshKey(Provider<com.google.gerrit.server.account.DeleteSshKey> deleteSshKey) {
+  DeleteSshKey(
+      Provider<com.google.gerrit.server.account.DeleteSshKey> deleteSshKey) {
     this.deleteSshKey = deleteSshKey;
   }
 
   @Override
   public Response<?> apply(ServiceUserResource.SshKey rsrc, Input input)
-      throws OrmException, AuthException {
+      throws OrmException, AuthException, RepositoryNotFoundException,
+      IOException, ConfigInvalidException {
     return deleteSshKey.get().apply(
         new AccountResource.SshKey(rsrc.getUser(), rsrc.getSshKey()), input);
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetSshKeys.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetSshKeys.java
index a75df30..1948329 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetSshKeys.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/GetSshKeys.java
@@ -22,6 +22,10 @@
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.errors.RepositoryNotFoundException;
+
+import java.io.IOException;
 import java.util.List;
 
 @Singleton
@@ -34,8 +38,9 @@
   }
 
   @Override
-  public List<SshKeyInfo> apply(ServiceUserResource rsrc) throws AuthException,
-      OrmException {
+  public List<SshKeyInfo> apply(ServiceUserResource rsrc)
+      throws AuthException, OrmException, RepositoryNotFoundException,
+      IOException, ConfigInvalidException {
     return getSshKeys.get().apply(rsrc.getUser());
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/SshKeys.java b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/SshKeys.java
index a585d37..74ea24f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/serviceuser/SshKeys.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/serviceuser/SshKeys.java
@@ -24,6 +24,10 @@
 import com.google.inject.Provider;
 import com.google.inject.Singleton;
 
+import org.eclipse.jgit.errors.ConfigInvalidException;
+
+import java.io.IOException;
+
 @Singleton
 class SshKeys implements
     ChildCollection<ServiceUserResource, ServiceUserResource.SshKey> {
@@ -47,7 +51,8 @@
 
   @Override
   public ServiceUserResource.SshKey parse(ServiceUserResource parent, IdString id)
-      throws ResourceNotFoundException, OrmException {
+      throws ResourceNotFoundException, OrmException, IOException,
+      ConfigInvalidException {
     return new ServiceUserResource.SshKey(sshKeys.get().parse(parent.getUser(), id));
   }