From e1c9f1c6025622d649536f23bbe40124a180843f Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 21 Oct 2015 12:55:44 +0530 Subject: [PATCH 1/3] Added url param support to permission tree. --- .../extensions/validators/PermissionBasedScopeValidator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java index 67b944dc16..71138525c9 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -65,7 +65,8 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { int idx = resource.lastIndexOf(':'); String url = resource.substring(0, idx); String method = resource.substring(++idx, resource.length()); - + //This is to remove the url params + url = url.substring(0, url.indexOf('?')); Properties properties = new Properties(); properties.put(PermissionBasedScopeValidator.URL_PROPERTY, url); properties.put(PermissionBasedScopeValidator.HTTP_METHOD_PROPERTY, method); From 52fab37c61232afb1f0104d824b1645b39191ace Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 21 Oct 2015 15:43:26 +0530 Subject: [PATCH 2/3] Fixed issue in permission validator --- .../validators/PermissionBasedScopeValidator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java index 71138525c9..f419362f2e 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -66,7 +66,11 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { String url = resource.substring(0, idx); String method = resource.substring(++idx, resource.length()); //This is to remove the url params - url = url.substring(0, url.indexOf('?')); + int urlParamIndex = url.indexOf('?'); + if(urlParamIndex > 0) { + url = url.substring(0, urlParamIndex); + } + Properties properties = new Properties(); properties.put(PermissionBasedScopeValidator.URL_PROPERTY, url); properties.put(PermissionBasedScopeValidator.HTTP_METHOD_PROPERTY, method); From b3e0f804b078a29a33cf690551fc269bdba88e23 Mon Sep 17 00:00:00 2001 From: harshanl Date: Wed, 21 Oct 2015 17:19:49 +0530 Subject: [PATCH 3/3] Added comments. --- .../extensions/validators/PermissionBasedScopeValidator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java index f419362f2e..e8e27b1263 100644 --- a/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java +++ b/components/identity-extensions/org.wso2.carbon.device.mgt.oauth.extensions/src/main/java/org/wso2/carbon/device/mgt/oauth/extensions/validators/PermissionBasedScopeValidator.java @@ -65,7 +65,7 @@ public class PermissionBasedScopeValidator extends OAuth2ScopeValidator { int idx = resource.lastIndexOf(':'); String url = resource.substring(0, idx); String method = resource.substring(++idx, resource.length()); - //This is to remove the url params + //This is to remove the url params for request path. int urlParamIndex = url.indexOf('?'); if(urlParamIndex > 0) { url = url.substring(0, urlParamIndex);