Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Permissions
Permissions [message #1063937] Sun, 16 June 2013 06:33 Go to next message
Kjell Dirdal is currently offline Kjell Dirdal
Messages: 1
Registered: June 2013
Junior Member
Hi. I'm trying to learn my self Eclipse Scout.
I have gone thorugh all tutorials and is now on the tutorials about miniCrm/Permissions. Here I have some problems. When I run this part of code for loading all permissions:

if (getRoleNr() == null) {
    ArrayList<String> rows = new ArrayList<String>();
    BundleClassDescriptor[] permissions = SERVICES.getService(IPermissionService.class).getAllPermissionClasses();
    for (int i = 0; i < permissions.length; i++) {
      if (permissions[i].getBundleSymbolicName().contains("minicrm")) {
	rows.add(permissions[i].getSimpleClassName());
      }
      else {
	// Skip bookmark permissions and other permissions that are not specific to our application
      }
    }
    Collections.sort(rows);
    Object[][] data = new Object[rows.size()][1];
    for (int i = 0; i < rows.size(); i++) {
      data[i][0] = rows.get(i);
    }
    return data;
  }
  else {
    return SERVICES.getService(IAdministrationOutlineService.class).getPermissionTableData(getRoleNr());
  }


This part of code:
BundleClassDescriptor[] permissions = SERVICES.getService(IPermissionService.class).getAllPermissionClasses();
    for (int i = 0; i < permissions.length; i++) {
      if (permissions[i].getBundleSymbolicName().contains("minicrm")) {
	rows.add(permissions[i].getSimpleClassName());
      }


Don't find minicrm in the SERVICES.getService(IPermissionService.class).getAllPermissionClasses();

Why? Can someone help me.
Re: Permissions [message #1063981 is a reply to message #1063937] Mon, 17 June 2013 02:46 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 649
Registered: October 2011
Senior Member
Hi,

Thank you for providing feedback on the tutorial.

I have tried to reproduce it myself. Executing your code snippet in my workspace, I got like you, no minicrm Permission in the permissions arrray:
BundleClassDescriptor[] permissions == [
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.NoAccessPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.DeleteUserBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.CopyToClipboardPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.RemoteServiceAccessPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.ReadUserBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.PublishUserBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.UpdateServiceConfigurationPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.CreateCustomColumnPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.DeleteGlobalBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.UpdateGlobalBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.UpdateCustomColumnPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.DeleteCustomColumnPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.CreateUserBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.UpdateUserBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.ReadGlobalBookmarkPermission@org.eclipse.scout.rt.shared], 
BundleClassDescriptor[org.eclipse.scout.rt.shared.security.CreateGlobalBookmarkPermission@org.eclipse.scout.rt.shared]
]


The problem is that the new SDK do not create the Permission in a security subpackage. My permissions objects are here:
org.eclipsescout.demo.minicrm.shared.ui.desktop.form.CreateCompanyPermission,
org.eclipsescout.demo.minicrm.shared.ui.desktop.form.ReadCompanyPermission,
org.eclipsescout.demo.minicrm.shared.ui.desktop.form.UpdateCompanyPermission

Side note: In my workspace I do not have any permission for Person (maybe I skipped this step, when I went to the tutorial).


The runtime still assumes that the Permissions are in a security subpackage. See the implementation of
org.eclipse.scout.rt.server.services.common.security.PermissionService#acceptClassName(Bundle, String) :
protected boolean acceptClassName(Bundle bundle, String className) {
  return isCandidate(className);
}


And org.eclipse.scout.rt.server.services.common.security.PermissionService#isCandidate(String) :
@Deprecated
protected boolean isCandidate(String className) {
  return className.indexOf("Permission") >= 0 && className.indexOf(".security.") >= 0;
}



--------------------------------------------------------

To solve this you can:

1. Move the Permission objects

The full qualified name of the class need to contain ".security.".

2. Register a service implementing IPermissionService
This service should not ignore Permission objects that are not in a security subpackage. (you can extend PermissionService if you want).


Do not hesitate if you need more help.


--------------------------------------------------------

I think we need to file a bug, because the implementation of the default PermissionService is not acceptable. Or we solve this as part of Bug 410625


Re: Permissions [message #1063992 is a reply to message #1063981] Mon, 17 June 2013 03:56 Go to previous messageGo to next message
Judith Gull is currently offline Judith Gull
Messages: 47
Registered: February 2010
Member
The issue is described in Bug 410561 (planned for SR1).

The default PermissionService will be changed, such that Permissions not in the security package are found as well. Until then one of the two solutions described by Jeremie has to be applied.
Re: Permissions [message #1064005 is a reply to message #1063981] Mon, 17 June 2013 05:00 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 649
Registered: October 2011
Senior Member
Jeremie Bresson wrote on Mon, 17 June 2013 08:46
Hi,
2. Register a service implementing IPermissionService
This service should not ignore Permission objects that are not in a security subpackage. (you can extend PermissionService if you want).


I have extended the tutorial to add the custom permission service. See: Permissions > PermissionService

I hope this helps.

index.php/fa/15281/0/

Previous Topic:How to add more actionable Icons at the icons bar?
Next Topic:Announcement: Moving Scout Kepler M4 to M6 to Eclipse archive
Goto Forum:
  


Current Time: Thu Jul 31 15:57:32 EDT 2014

Powered by FUDForum. Page generated in 0.01560 seconds