-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from dvilela/master
Adds JwtService and AclService to the API
- Loading branch information
Showing
18 changed files
with
286 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
src/main/java/com/github/vaibhavsinha/kong/api/plugin/authentication/KeyAuthService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package com.github.vaibhavsinha.kong.api.plugin.authentication; | ||
|
||
import com.github.vaibhavsinha.kong.model.plugin.authentication.key.KeyAuthCredential; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.key.KeyAuthCredentialList; | ||
|
||
/** | ||
* Created by vaibhav on 15/06/17. | ||
* | ||
* Updated by dvilela on 17/10/17. | ||
*/ | ||
public interface KeyAuthService { | ||
void addCredentials(String consumerIdOrUsername, String key); | ||
KeyAuthCredential addCredentials(String consumerIdOrUsername, String key); | ||
KeyAuthCredentialList listCredentials(String consumerIdOrUsername, Long size, String offset); | ||
void deleteCredential(String consumerIdOrUsername, String id); | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/java/com/github/vaibhavsinha/kong/api/plugin/security/AclService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
package com.github.vaibhavsinha.kong.api.plugin.security; | ||
|
||
import com.github.vaibhavsinha.kong.model.plugin.security.acl.AclList; | ||
|
||
/** | ||
* Created by vaibhav on 18/06/17. | ||
* | ||
* Upated by dvilela on 22/10/17. | ||
*/ | ||
public interface AclService { | ||
void associateConsumer(String usernameOrId, String group); | ||
AclList listAcls(String usernameOrId, Long size, String offset); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...a/com/github/vaibhavsinha/kong/impl/service/plugin/authentication/JwtAuthServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.github.vaibhavsinha.kong.impl.service.plugin.authentication; | ||
|
||
import com.github.vaibhavsinha.kong.api.plugin.authentication.JwtService; | ||
import com.github.vaibhavsinha.kong.exception.KongClientException; | ||
import com.github.vaibhavsinha.kong.internal.plugin.authentication.RetrofitJwtService; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.jwt.JwtCredential; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.jwt.JwtCredentialList; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Created by dvilela on 10/16/17. | ||
*/ | ||
public class JwtAuthServiceImpl implements JwtService { | ||
|
||
private RetrofitJwtService retrofitJwtService; | ||
|
||
public JwtAuthServiceImpl(RetrofitJwtService retrofitJwtService) { | ||
this.retrofitJwtService = retrofitJwtService; | ||
} | ||
|
||
@Override | ||
public JwtCredential addCredentials(String consumerIdOrUsername, JwtCredential request) { | ||
try { | ||
return retrofitJwtService.addCredentials(consumerIdOrUsername, request).execute().body(); | ||
} catch (IOException e) { | ||
throw new KongClientException(e.getMessage()); | ||
} | ||
} | ||
|
||
@Override | ||
public void deleteCredentials(String consumerIdOrUsername, String id) { | ||
try { | ||
retrofitJwtService.deleteCredentials(consumerIdOrUsername, id).execute(); | ||
} catch (IOException e) { | ||
throw new KongClientException(e.getMessage()); | ||
} | ||
} | ||
|
||
@Override | ||
public JwtCredentialList listCredentials(String consumerIdOrUsername, Long size, String offset) { | ||
try { | ||
return retrofitJwtService.listCredentials(consumerIdOrUsername, size, offset).execute().body(); | ||
} catch (IOException e) { | ||
throw new KongClientException(e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 11 additions & 5 deletions
16
...a/com/github/vaibhavsinha/kong/internal/plugin/authentication/RetrofitKeyAuthService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package com.github.vaibhavsinha.kong.internal.plugin.authentication; | ||
|
||
import com.github.vaibhavsinha.kong.model.plugin.authentication.basic.BasicAuthCredential; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.key.KeyAuthCredential; | ||
import com.github.vaibhavsinha.kong.model.plugin.authentication.key.KeyAuthCredentialList; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.*; | ||
|
||
/** | ||
* Created by vaibhav on 15/06/17. | ||
* | ||
* Updated by dvilela on 17/10/17. | ||
*/ | ||
public interface RetrofitKeyAuthService { | ||
|
||
@POST("consumers/{id}/key-auth") | ||
Call<BasicAuthCredential> addCredentials(@Path("id") String consumerIdOrUsername, @Body KeyAuthCredential request); | ||
Call<KeyAuthCredential> addCredentials(@Path("id") String consumerIdOrUsername, @Body KeyAuthCredential request); | ||
|
||
@GET("consumers/{id}/key-auth") | ||
Call<KeyAuthCredentialList> listCredentials(@Path("id") String consumerIdOrUsername, @Query("size") Long size, @Query("offset") String offset); | ||
|
||
@DELETE("consumers/{consumer}/key-auth/{id}") | ||
Call<Void> deleteCredential(@Path("consumer") String consumer, @Path("id") String id); | ||
} |
10 changes: 7 additions & 3 deletions
10
src/main/java/com/github/vaibhavsinha/kong/internal/plugin/security/RetrofitAclService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
package com.github.vaibhavsinha.kong.internal.plugin.security; | ||
|
||
import com.github.vaibhavsinha.kong.model.plugin.security.acl.Acl; | ||
import com.github.vaibhavsinha.kong.model.plugin.security.acl.AclList; | ||
import retrofit2.Call; | ||
import retrofit2.http.Body; | ||
import retrofit2.http.POST; | ||
import retrofit2.http.Path; | ||
import retrofit2.http.*; | ||
|
||
/** | ||
* Created by vaibhav on 18/06/17. | ||
* | ||
* Upated by dvilela on 22/10/17. | ||
*/ | ||
public interface RetrofitAclService { | ||
@POST("consumers/{id}/acls") | ||
Call<Void> associateConsumer(@Path("id") String consumerIdOrUsername, @Body Acl request); | ||
|
||
@GET("consumers/{id}/acls") | ||
Call<AclList> listAcls(@Path("id") String consumerIdOrUsername, @Query("size") Long size, @Query("offset") String offset); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
.../java/com/github/vaibhavsinha/kong/model/plugin/authentication/jwt/JwtCredentialList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.