-
1. Re: Granting Permissions with JPA (NPE)
shane.bryzak Mar 10, 2014 9:01 PM (in response to noamichael)1 of 1 people found this helpfulYou shouldn't need the @PermissionsHandledBy annotation as PicketLink provides built-in support for entity bean permissions already. You will need an entity annotated with @PermissionManaged to store your permission records (I'll make a note that we need to cover this in the reference docs) - check out the following class for an example:
-
2. Re: Granting Permissions with JPA (NPE)
noamichael Mar 10, 2014 10:08 PM (in response to shane.bryzak)Thank you for the speedy response and perfect example! That almost seemed to do it! I got an error without the @PermissionsHandledBy annotation stating that the resource class needed one, so I simply left it. I'm no longer receiving the NPE, however identity.hasPermission is returning false incorrectly. This is what the conditions looked like:
Current identity id = [27e4119c-195e-4abc-ad54-8454438103d9], Assignee id = [27e4119c-195e-4abc-ad54-8454438103d9], ResourceClass = [com.test.picketlink.model.CustomUser], resourceIdentifier = [59589dfc-83f3-49be-aa44-02be06579d2a], currentResource = [59589dfc-83f3-49be-aa44-02be06579d2a], Operation = [CREATE]
So it seems like it should be returning true. After doing some debugging, it seems it's returning false because there are no "PermissionVoter"s. Any idea why?
-
3. Re: Granting Permissions with JPA (NPE)
shane.bryzak Mar 11, 2014 2:35 AM (in response to noamichael)Hmm, you'll probably need to add a producer method for the PersistentPermissionVoter. We should probably provide this in the base module of PicketLink itself. For now, adding the following producer method somewhere in one of your beans *should* work:
@Produces @ApplicationScoped
public PermissionVoter producePermissionVoter(PartitionManager partitionManager) {
return new PersistentPermissionVoter(partitionManager);
}
-
4. Re: Granting Permissions with JPA (NPE)
noamichael Mar 11, 2014 8:00 AM (in response to shane.bryzak)Thank you! That did the trick!
-
5. Re: Granting Permissions with JPA (NPE)
anil.saldhana Mar 11, 2014 1:44 PM (in response to noamichael)Hi Michael - I am very glad that your use cases are working with PicketLink.
Have you considered:
a) Contributing a short tutorial on your use case. The community will find it very useful in the future.
b) Becoming a contributor to PicketLink. I am sure you will find areas to contribute yourself.