mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Apply CR suggestions
This commit is contained in:
		
							parent
							
								
									f35f41688a
								
							
						
					
					
						commit
						37250fc55c
					
				| @ -47,7 +47,10 @@ class RegisterClientRemoteOperation( | |||||||
|         try { |         try { | ||||||
|             val requestBody = clientRegistrationParams.toRequestBody() |             val requestBody = clientRegistrationParams.toRequestBody() | ||||||
| 
 | 
 | ||||||
|             val postMethod = PostMethod(URL(clientRegistrationParams.registrationEndpoint), requestBody) |             val postMethod = PostMethod( | ||||||
|  |                 url = URL(clientRegistrationParams.registrationEndpoint), | ||||||
|  |                 postRequestBody = requestBody | ||||||
|  |             ) | ||||||
| 
 | 
 | ||||||
|             val status = client.executeHttpMethod(postMethod) |             val status = client.executeHttpMethod(postMethod) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -40,17 +40,13 @@ data class ClientRegistrationParams( | |||||||
|     val tokenEndpointAuthMethod: String, |     val tokenEndpointAuthMethod: String, | ||||||
|     val applicationType: String |     val applicationType: String | ||||||
| ) { | ) { | ||||||
|     fun toRequestBody(): RequestBody { |     fun toRequestBody(): RequestBody = | ||||||
|         val jsonObject = JSONObject().apply { |         JSONObject().apply { | ||||||
|             put(PARAM_APPLICATION_TYPE, applicationType) |             put(PARAM_APPLICATION_TYPE, applicationType) | ||||||
|             put(PARAM_CLIENT_NAME, clientName) |             put(PARAM_CLIENT_NAME, clientName) | ||||||
|             put(PARAM_REDIRECT_URIS, JSONArray(redirectUris)) |             put(PARAM_REDIRECT_URIS, JSONArray(redirectUris)) | ||||||
|             put(PARAM_TOKEN_ENDPOINT_AUTH_METHOD, tokenEndpointAuthMethod) |             put(PARAM_TOKEN_ENDPOINT_AUTH_METHOD, tokenEndpointAuthMethod) | ||||||
|         } |         }.toString().toRequestBody(CONTENT_TYPE_JSON.toMediaType()) | ||||||
| 
 |  | ||||||
|         val mediaType = CONTENT_TYPE_JSON.toMediaType() |  | ||||||
|         return jsonObject.toString().toRequestBody(mediaType) |  | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     companion object { |     companion object { | ||||||
|         private const val PARAM_APPLICATION_TYPE = "application_type" |         private const val PARAM_APPLICATION_TYPE = "application_type" | ||||||
|  | |||||||
| @ -42,14 +42,13 @@ sealed class TokenRequestParams( | |||||||
|         val redirectUri: String |         val redirectUri: String | ||||||
|     ) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) { |     ) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) { | ||||||
| 
 | 
 | ||||||
|         override fun toRequestBody(): RequestBody { |         override fun toRequestBody(): RequestBody = | ||||||
|             return FormBody.Builder() |             FormBody.Builder() | ||||||
|                 .add(HttpConstants.OAUTH_HEADER_AUTHORIZATION_CODE, authorizationCode) |                 .add(HttpConstants.OAUTH_HEADER_AUTHORIZATION_CODE, authorizationCode) | ||||||
|                 .add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType) |                 .add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType) | ||||||
|                 .add(HttpConstants.OAUTH_HEADER_REDIRECT_URI, redirectUri) |                 .add(HttpConstants.OAUTH_HEADER_REDIRECT_URI, redirectUri) | ||||||
|                 .build() |                 .build() | ||||||
|     } |     } | ||||||
|     } |  | ||||||
| 
 | 
 | ||||||
|     class RefreshToken( |     class RefreshToken( | ||||||
|         tokenEndpoint: String, |         tokenEndpoint: String, | ||||||
| @ -58,8 +57,8 @@ sealed class TokenRequestParams( | |||||||
|         val refreshToken: String? = null |         val refreshToken: String? = null | ||||||
|     ) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) { |     ) : TokenRequestParams(tokenEndpoint, clientAuth, grantType) { | ||||||
| 
 | 
 | ||||||
|         override fun toRequestBody(): RequestBody { |         override fun toRequestBody(): RequestBody = | ||||||
|             return FormBody.Builder().apply { |             FormBody.Builder().apply { | ||||||
|                 add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType) |                 add(HttpConstants.OAUTH_HEADER_GRANT_TYPE, grantType) | ||||||
|                 if (!refreshToken.isNullOrBlank()) { |                 if (!refreshToken.isNullOrBlank()) { | ||||||
|                     add(HttpConstants.OAUTH_HEADER_REFRESH_TOKEN, refreshToken) |                     add(HttpConstants.OAUTH_HEADER_REFRESH_TOKEN, refreshToken) | ||||||
| @ -68,4 +67,3 @@ sealed class TokenRequestParams( | |||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
| } | } | ||||||
| } |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user