Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Patrick Warnecke
Custom Permissions
1. Februar 2013 05:38
Antwort

Patrick Warnecke

Rang: New Member

Nachrichten: 20

Eintrittsdatum: 30. November 2012

Neue Beiträge

Hi,
I'm trying to get my custom permissions to work, but I'm at a point where it feels like running into a brick wall over and over. Maybe (hopefully) someone can help me.

Ok the following setup:
After a lot of researched I figured out that I have to place my xml-files fot the permission definition in the "../webapps/ROOT/WEB-INF/classes/resource-actions/" folder.
Is there no better way?? At first I had the xml files in the src folder of my eclipse portlet project, but that didn't seem to work. Putting the files in a ext-plugin and there in ext-impl-src didn't work either. This is not too much of a problem, but maybe someone knows how I can handle the files through eclipse without the need of editing the fieles directly in tomcat.

The source of the files:
../webapps/ROOT/WEB-INF/classes/portal-ext.properties
1[...]resource.actions.configs=resource-actions/default.xml,resource-actions/anteros-default.xml[...]

../webapps/ROOT/WEB-INF/classes/resource-actions/anteros-default.xml
1<?xml version="1.0"?>
2<resource-action-mapping>
3    <resource file="resource-actions/PF-ObjectList.xml" />
4</resource-action-mapping>

../webapps/ROOT/WEB-INF/classes/resource-actions/PF-ObjectList.xml
 1<?xml version="1.0"?>
 2<!DOCTYPE resource-action-mapping PUBLIC "-//Liferay//DTD Resource Action Mapping 6.1.0//EN" "http://www.liferay.com/dtd/liferay-resource-action-mapping_6_1_0.dtd">
 3
 4<resource-action-mapping>
 5    <portlet-resource>
 6        <portlet-name>PFObjectList_WAR_PFObjectListportlet</portlet-name>
 7        <permissions>
 8            <supports>
 9                <action-key>ACCESS_IN_CONTROL_PANEL</action-key>
10                <action-key>ADD_TO_PAGE</action-key>
11                <action-key>CONFIGURATION</action-key>
12                <action-key>VIEW</action-key>
13                <action-key>PWTEST</action-key>
14                <action-key>PWTEST2</action-key>
15            </supports>
16            <community-defaults>
17                <action-key>VIEW</action-key>
18            </community-defaults>
19            <guest-defaults>
20                <action-key>VIEW</action-key>
21            </guest-defaults>
22            <guest-unsupported>
23                <action-key>ACCESS_IN_CONTROL_PANEL</action-key>
24                <action-key>CONFIGURATION</action-key>
25            </guest-unsupported>
26        </permissions>
27    </portlet-resource>
28</resource-action-mapping>


Like I said, with the above file content & location I am finally able to see my custom permissions (PWTEST & PWTEST1) when I click on the "Configuration" Button of my portlet or in the backend.
However, I am by no means able to check if the permission is set or not.
I tried following methods:
PortletPermissionUtil.contains => returns always true
PortletPermissionUtil.check => as far as I understood it the an exception should be thrown if the Permission isn't checked, but nothing happens
PermissionLocalServiceUtil.hasRolePermission => always false
PermissionChecker perm = themeDisplay.getPermissionChecker().hasPermission => always true

The only check I was able to influence was "PermissionLocalServiceUtil.hasUserPermission". This returend false at the beginning but after I set "PermissionLocalServiceUtil.setUserPermissions" it returns true (makes sense).

But how on earth am I able to check if the checkboxes in the configuration window of a portlet are set to true or false?
If someone can help me I would appreaciate it very much. I can provide further information, just ask. I hope my problem & question is clear.

Thanks in advance.
Patrick Warnecke
RE: Custom Permissions
3. Februar 2013 22:51
Antwort

Patrick Warnecke

Rang: New Member

Nachrichten: 20

Eintrittsdatum: 30. November 2012

Neue Beiträge

Is noone working with custom permissions? Or has nobody encoutert this error?
Patrick Warnecke
RE: Custom Permissions
4. Februar 2013 06:32
Antwort

Patrick Warnecke

Rang: New Member

Nachrichten: 20

Eintrittsdatum: 30. November 2012

Neue Beiträge

Just in case someone runs into this problem in the future and seeks help and doesn't find any, like me, here is what caused me the headache:
I tested it with the default User "Test" which has the admin Role or something and secretly inherits all the permissions. So even if you uncheck all permissions in the Config Menu the check still return true.
Test it with a newly created user and everything is fine.