Fixed issues in permission-scope mapping

4.x.x
Milan Perera 8 years ago
parent 637c014866
commit 42a587904f

@ -66,6 +66,8 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_VALUE = "value";
private static final String ANNOTATIONS_SCOPES = "scopes"; private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String PERMISSION_PREFIX = "/permission/admin";
private StandardContext context; private StandardContext context;
private Method[] pathClazzMethods; private Method[] pathClazzMethods;
@ -201,8 +203,9 @@ public class AnnotationProcessor {
Scope scope; Scope scope;
String permissions[]; String permissions[];
StringBuilder aggregatedPermissions = new StringBuilder(); StringBuilder aggregatedPermissions;
for(int i=0; i<annotatedScopes.length; i++){ for(int i=0; i<annotatedScopes.length; i++){
aggregatedPermissions = new StringBuilder();
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]); methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
scope = new Scope(); scope = new Scope();
scope.setName(invokeMethod(scopeClass scope.setName(invokeMethod(scopeClass
@ -214,6 +217,7 @@ public class AnnotationProcessor {
permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null); .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null);
for (String permission : permissions) { for (String permission : permissions) {
aggregatedPermissions.append(PERMISSION_PREFIX);
aggregatedPermissions.append(permission); aggregatedPermissions.append(permission);
aggregatedPermissions.append(" "); aggregatedPermissions.append(" ");
} }

@ -63,6 +63,8 @@ public class AnnotationProcessor {
private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions"; private static final String SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS = "permissions";
private static final String ANNOTATIONS_SCOPES = "scopes"; private static final String ANNOTATIONS_SCOPES = "scopes";
private static final String PERMISSION_PREFIX = "/permission/admin";
private StandardContext context; private StandardContext context;
private Method[] pathClazzMethods; private Method[] pathClazzMethods;
private Class<Path> pathClazz; private Class<Path> pathClazz;
@ -391,8 +393,9 @@ public class AnnotationProcessor {
Scope scope; Scope scope;
String permissions[]; String permissions[];
StringBuilder aggregatedPermissions = new StringBuilder(); StringBuilder aggregatedPermissions;
for(int i=0; i<annotatedScopes.length; i++){ for(int i=0; i<annotatedScopes.length; i++){
aggregatedPermissions = new StringBuilder();
methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]); methodHandler = Proxy.getInvocationHandler(annotatedScopes[i]);
scope = new Scope(); scope = new Scope();
scope.setName(invokeMethod(scopeClass scope.setName(invokeMethod(scopeClass
@ -403,8 +406,8 @@ public class AnnotationProcessor {
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_KEY), annotatedScopes[i], STRING)); .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_KEY), annotatedScopes[i], STRING));
permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass permissions = (String[])methodHandler.invoke(annotatedScopes[i], scopeClass
.getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null); .getMethod(SWAGGER_ANNOTATIONS_PROPERTIES_PERMISSIONS, null),null);
aggregatedPermissions.setLength(0);
for (String permission : permissions) { for (String permission : permissions) {
aggregatedPermissions.append(PERMISSION_PREFIX);
aggregatedPermissions.append(permission); aggregatedPermissions.append(permission);
aggregatedPermissions.append(" "); aggregatedPermissions.append(" ");
} }

@ -62,53 +62,84 @@
"copyrightSuffix" : " All Rights Reserved." "copyrightSuffix" : " All Rights Reserved."
}, },
"scopes" : [ "scopes" : [
"user:manage", "perm:sign-csr",
"user:view", "perm:admin:devices:view",
"device-type:admin:view", "perm:roles:add",
"device:view", "perm:roles:add-users",
"notification:view", "perm:roles:update",
"device:admin:view", "perm:roles:permissions",
"application:manage", "perm:roles:details",
"activity:view", "perm:roles:view",
"user:admin:reset-password", "perm:roles:create-combined-role",
"policy:manage", "perm:roles:delete",
"policy:view", "perm:dashboard:vulnerabilities",
"role:manage", "perm:dashboard:non-compliant-count",
"role:view", "perm:dashboard:non-compliant",
"configuration:view", "perm:dashboard:by-groups",
"configuration:modify", "perm:dashboard:device-counts",
"device:android:operation:reboot", "perm:dashboard:feature-non-compliant",
"device:android:operation:camera", "perm:dashboard:count-overview",
"device:android:operation:vpn", "perm:dashboard:filtered-count",
"device:android:operation:lock", "perm:dashboard:details",
"device:android:operation:ring", "perm:get-activity",
"device:android:operation:update-app", "perm:devices:delete",
"device:android:operation:wipe", "perm:devices:applications",
"device:android:operation:encrypt", "perm:devices:effective-policy",
"device:android:operation:blacklist-app", "perm:devices:compliance-data",
"device:android:operation:applications", "perm:devices:features",
"device:android:operation:enterprise-wipe", "perm:devices:operations",
"device:android:operation:info", "perm:devices:search",
"device:android:operation:wifi", "perm:devices:details",
"device:android:operation:uninstall-app", "perm:devices:view",
"device:android:operation:change-lock", "perm:view-configuration",
"device:android:operation:notification", "perm:manage-configuration",
"device:android:operation:upgrade", "perm:policies:remove",
"device:android:operation:unlock", "perm:policies:priorities",
"device:android:operation:mute", "perm:policies:deactivate",
"device:android:operation:location", "perm:policies:get-policy-details",
"device:android:operation:webclip", "perm:policies:manage",
"device:android:operation:clear-password", "perm:policies:activate",
"device:android:operation:password-policy", "perm:policies:update",
"device:android:operation:install-app", "perm:policies:changes",
"device:android:event:write", "perm:policies:get-details",
"device:android:event:read", "perm:users:add",
"device:android:enroll", "perm:users:details",
"configuration:manage", "perm:users:count",
"configuration:view", "perm:users:delete",
"device:android:enroll", "perm:users:roles",
"certificate:view", "perm:users:user-details",
"certificate:manage" "perm:users:credentials",
"perm:users:search",
"perm:users:is-exist",
"perm:users:update",
"perm:users:send-invitation",
"perm:admin-users:view",
"perm:groups:devices",
"perm:groups:update",
"perm:groups:add",
"perm:groups:device",
"perm:groups:devices-count",
"perm:groups:remove",
"perm:groups:groups",
"perm:groups:groups-view",
"perm:groups:share",
"perm:groups:count",
"perm:groups:roles",
"perm:groups:devices-remove",
"perm:groups:devices-add",
"perm:groups:assign",
"perm:device-types:features",
"perm:device-types:types",
"perm:applications:install",
"perm:applications:uninstall",
"perm:admin-groups:count",
"perm:admin-groups:view",
"perm:notifications:mark-checked",
"perm:notifications:view",
"perm:admin:certificates:delete",
"perm:admin:certificates:details",
"perm:admin:certificates:view",
"perm:admin:certificates:add"
], ],
"isOAuthEnabled" : true, "isOAuthEnabled" : true,
"backendRestEndpoints" : { "backendRestEndpoints" : {

@ -1940,7 +1940,7 @@
<commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range> <commons-lang.wso2.osgi.version.range>[2.6.0,3.0.0)</commons-lang.wso2.osgi.version.range>
<!-- Carbon API Management --> <!-- Carbon API Management -->
<carbon.api.mgt.version>6.1.30-SNAPSHOT</carbon.api.mgt.version> <carbon.api.mgt.version>6.1.35</carbon.api.mgt.version>
<carbon.api.mgt.version.range>(6.0.0,7.0.0]</carbon.api.mgt.version.range> <carbon.api.mgt.version.range>(6.0.0,7.0.0]</carbon.api.mgt.version.range>
<!-- Carbon Analytics Commons --> <!-- Carbon Analytics Commons -->

Loading…
Cancel
Save