cancel
Showing results for 
Search instead for 
Did you mean: 

Adding ACL entry to KM collection

Former Member
0 Kudos
64

Hello,

I'm tying to grant permission to access KM directory to connected user and some group by code (without try/catch clauses and aGroup fetching):

com.sapportals.portal.security.usermanagement.IUser aUser = (com.sapportals.portal.security.usermanagement.IUser) aRequest.getUser().getUser();

String root = "/documents/timesheet/CV";

String userId = aUser.getId();

IResourceContext resourceContext = new ResourceContext(aUser);

RID rid = RID.getRID(root);

ICollection rootResource = (ICollection) ResourceFactory.getInstance().getResource(rid, resourceContext);

userDirResource = rootResource.createCollection(userId, null);

IResourceAclManager aclMan = ((IAclSecurityManager) userDirResource.getRepositoryManager().getSecurityManager(userDirResource)).getAclManager();

IResourceAcl userDirResourceAcl = aclMan.getAcl(userDirResource);

aclMan.createAclEntry((IUMPrincipal) aUser, false, aclMan.getPermission("read"), 2);

aclMan.createAclEntry((IUMPrincipal) aGroup, false, aclMan.getPermission("fullcontrol"), 1);

... but no ACL is set. I think, I should somehow add created Acl entries to AclList. Or what am I doing wrong?

Best Regards,

Josef Motl

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Josef,

first, code can be read easier if set between [ code ] and [/ code ] (without spaces.

Then, by the method createAclEntry of the aclManager you retrieve an IResourceAclEntry. This you have to add to the ACL in question. And for the rights, it's more elegant to use given constants; so together we have:


IResourceAclEntry entry =
  aclMan.createAclEntry(
    (IUMPrincipal) aUser, false, aclMan.getPermission(IAclPermission.ACL_PERMISSION_READ), 2);
userDirResourceAcl.addEntry(entry);

Hope it helps

Detlev

Former Member
0 Kudos

What jar files contain IUMPrincipal class?

detlev_beutner
Active Contributor
0 Kudos

Hi Yuri,

didn't I say "search by yourself"?

OK, asked twice, answered once... Old men are good natured...

com.sap.portal.usermanagement/lib/com.sap.security.api.ep5.jar

Hope it helps

Detlev

Former Member
0 Kudos

Detlev,

Thank you very much. I knew about com.sap.security.api.ep5.jar,

but hoped things changed since my last research.

Thanks again,

Yuri

Answers (2)

Answers (2)

Former Member
0 Kudos

Try seeing detlevs answer to Cory in this post:

[/message/759864#759864 [original link is broken];

Former Member
0 Kudos

Hi,

i am trying the same example. but its througing null exception.

can u please guide me one this?

IResourceAclManager aclMan = ((IAclSecurityManager) rootResource.getRepositoryManager().getSecurityManager(rootResource)).getAclManager();

thanks & regards,

Kathiresan R

Edited by: kathiresan rajendran on Jan 3, 2009 12:29 AM

Edited by: kathiresan rajendran on Jan 3, 2009 12:29 AM