Support adding an SSH key via REST
By POST on /accounts/<account-id>/sshkeys it is now possible to add an SSH key for a user. The SSH public key has to be provided as raw content in the request body. The WebUI is adapted to use the new REST endpint to add SSH keys. The old RPC for this is deleted. Change-Id: I9617ccf19f078f9bcee615803755f445ed68bdc9 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
		 Edwin Kempin
					Edwin Kempin
				
			
				
					committed by
					
						 Edwin Kempin
						Edwin Kempin
					
				
			
			
				
	
			
			
			 Edwin Kempin
						Edwin Kempin
					
				
			
						parent
						
							1e85b1ec3f
						
					
				
				
					commit
					4e2e5216f9
				
			| @@ -19,7 +19,6 @@ import com.google.gerrit.common.ChangeHooks; | ||||
| import com.google.gerrit.common.data.AccountSecurity; | ||||
| import com.google.gerrit.common.data.ContributorAgreement; | ||||
| import com.google.gerrit.common.errors.ContactInformationStoreException; | ||||
| import com.google.gerrit.common.errors.InvalidSshKeyException; | ||||
| import com.google.gerrit.common.errors.NoSuchEntityException; | ||||
| import com.google.gerrit.common.errors.PermissionDeniedException; | ||||
| import com.google.gerrit.httpd.rpc.BaseServiceImplementation; | ||||
| @@ -106,29 +105,6 @@ class AccountSecurityImpl extends BaseServiceImplementation implements | ||||
|     this.groupCache = groupCache; | ||||
|   } | ||||
|  | ||||
|   public void addSshKey(final String keyText, | ||||
|       final AsyncCallback<AccountSshKey> callback) { | ||||
|     run(callback, new Action<AccountSshKey>() { | ||||
|       public AccountSshKey run(final ReviewDb db) throws OrmException, Failure { | ||||
|         int max = 0; | ||||
|         final Account.Id me = user.get().getAccountId(); | ||||
|         for (final AccountSshKey k : db.accountSshKeys().byAccount(me)) { | ||||
|           max = Math.max(max, k.getKey().get()); | ||||
|         } | ||||
|  | ||||
|         final AccountSshKey key; | ||||
|         try { | ||||
|           key = sshKeyCache.create(new AccountSshKey.Id(me, max + 1), keyText); | ||||
|         } catch (InvalidSshKeyException e) { | ||||
|           throw new Failure(e); | ||||
|         } | ||||
|         db.accountSshKeys().insert(Collections.singleton(key)); | ||||
|         uncacheSshKeys(); | ||||
|         return key; | ||||
|       } | ||||
|     }); | ||||
|   } | ||||
|  | ||||
|   public void deleteSshKeys(final Set<AccountSshKey.Id> ids, | ||||
|       final AsyncCallback<VoidResult> callback) { | ||||
|     run(callback, new Action<VoidResult>() { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user