Updated roleId and super client parameters.
Change-Id: Iebdbf9e6b335860a8911493a65f07824353d4db4
diff --git a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
index 0180c27..64cafd6 100644
--- a/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
+++ b/full/src/main/java/de/ids_mannheim/korap/oauth2/service/OAuth2ClientService.java
@@ -356,9 +356,9 @@
}
public List<OAuth2UserClientDto> listUserAuthorizedClients (String username,
- String clientId, String clientSecret) throws KustvaktException {
- OAuth2Client client = authenticateClient(clientId, clientSecret);
- if (!client.isSuper()) {
+ String superClientId, String superClientSecret) throws KustvaktException {
+ OAuth2Client superClient = authenticateClient(superClientId, superClientSecret);
+ if (!superClient.isSuper()) {
throw new KustvaktException(StatusCodes.CLIENT_AUTHORIZATION_FAILED,
"Only super client is allowed to list user authorized clients.",
OAuth2Error.UNAUTHORIZED_CLIENT);
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
index ea14eb3..16f8bbb 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/OAuthClientController.java
@@ -232,9 +232,9 @@
* user and client authentications.
*
* @param context
- * @param clientId
+ * @param superClientId
* the client id of the super client
- * @param clientSecret
+ * @param superClientSecret
* the client secret of the super client
* @return a list of clients having refresh tokens of the
* given user
@@ -246,8 +246,8 @@
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public List<OAuth2UserClientDto> listUserAuthorizedClients (
@Context SecurityContext context,
- @FormParam("client_id") String clientId,
- @FormParam("client_secret") String clientSecret,
+ @FormParam("super_client_id") String superClientId,
+ @FormParam("super_client_secret") String superClientSecret,
@FormParam("authorized_only") boolean authorizedOnly) {
TokenContext tokenContext = (TokenContext) context.getUserPrincipal();
@@ -258,11 +258,11 @@
OAuth2Scope.LIST_USER_CLIENT);
if(authorizedOnly){
return clientService.listUserAuthorizedClients(username,
- clientId, clientSecret);
+ superClientId, superClientSecret);
}
else {
return clientService.listUserRegisteredClients(username,
- clientId, clientSecret);
+ superClientId, superClientSecret);
}
}
catch (KustvaktException e) {
diff --git a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
index 0d3154e..415d98d 100644
--- a/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
+++ b/full/src/main/java/de/ids_mannheim/korap/web/controller/UserGroupController.java
@@ -292,8 +292,8 @@
* the group name
* @param memberUsername
* the username of a group-member
- * @param roleIds
- * the role ids for the member
+ * @param roleId
+ * a role id or multiple role ids
* @return
*/
@POST
@@ -302,7 +302,7 @@
public Response editMemberRoles (@Context SecurityContext securityContext,
@PathParam("groupName") String groupName,
@FormParam("memberUsername") String memberUsername,
- @FormParam("roleIds") List<Integer> roleIds) {
+ @FormParam("roleId") List<Integer> roleIds) {
TokenContext context =
(TokenContext) securityContext.getUserPrincipal();
try {
@@ -326,8 +326,8 @@
* a group name
* @param memberUsername
* a username of a group member
- * @param roleIds
- * list of role ids
+ * @param roleId
+ * a role id or multiple role ids
* @return if successful, HTTP response status OK
*/
@POST
@@ -336,7 +336,7 @@
public Response addMemberRoles (@Context SecurityContext securityContext,
@PathParam("groupName") String groupName,
@FormParam("memberUsername") String memberUsername,
- @FormParam("roleIds") List<Integer> roleIds) {
+ @FormParam("roleId") List<Integer> roleIds) {
TokenContext context =
(TokenContext) securityContext.getUserPrincipal();
try {
@@ -361,8 +361,8 @@
* a group name
* @param memberUsername
* a username of a group member
- * @param roleIds
- * list of role ids
+ * @param roleId
+ * a role id or multiple role ids
* @return if successful, HTTP response status OK
*/
@POST
@@ -371,7 +371,7 @@
public Response deleteMemberRoles (@Context SecurityContext securityContext,
@PathParam("groupName") String groupName,
@FormParam("memberUsername") String memberUsername,
- @FormParam("roleIds") List<Integer> roleIds) {
+ @FormParam("roleId") List<Integer> roleIds) {
TokenContext context =
(TokenContext) securityContext.getUserPrincipal();
try {
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
index a232d43..05d683e 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/OAuth2ClientControllerTest.java
@@ -516,8 +516,8 @@
private void requestAuthorizedClientList (String userAuthHeader)
throws KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
- form.add("client_id", superClientId);
- form.add("client_secret", clientSecret);
+ form.add("super_client_id", superClientId);
+ form.add("super_client_secret", clientSecret);
form.add("authorized_only", "true");
ClientResponse response = resource().path(API_VERSION).path("oauth2")
@@ -697,8 +697,8 @@
registerClient("dory", json);
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
- form.add("client_id", superClientId);
- form.add("client_secret", clientSecret);
+ form.add("super_client_id", superClientId);
+ form.add("super_client_secret", clientSecret);
ClientResponse response = resource().path(API_VERSION).path("oauth2")
.path("client").path("list")
diff --git a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
index fba9a25..8360083 100644
--- a/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
+++ b/full/src/test/java/de/ids_mannheim/korap/web/controller/UserGroupControllerTest.java
@@ -912,7 +912,7 @@
ClientHandlerException, KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("memberUsername", "dory");
- form.add("roleIds", "1");
+ form.add("roleId", "1");
ClientResponse response = resource().path(API_VERSION).path("group")
.path("@marlin-group").path("role").path("add")
@@ -933,7 +933,7 @@
ClientHandlerException, KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("memberUsername", "dory");
- form.add("roleIds", "1");
+ form.add("roleId", "1");
ClientResponse response = resource().path(API_VERSION).path("group")
.path("@marlin-group").path("role").path("delete")
@@ -978,8 +978,8 @@
KustvaktException {
MultivaluedMap<String, String> form = new MultivaluedMapImpl();
form.add("memberUsername", "dory");
- form.add("roleIds", "1");
- form.add("roleIds", "3");
+ form.add("roleId", "1");
+ form.add("roleId", "3");
ClientResponse response = resource().path(API_VERSION).path("group")
.path("@marlin-group").path("role").path("edit")