Foren

Custom Permissions

Patrick Warnecke, geändert vor 11 Jahren.

Custom Permissions

New Member Beiträge: 20 Beitrittsdatum: 30.11.12 Neueste 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
[...]resource.actions.configs=resource-actions/default.xml,resource-actions/anteros-default.xml[...]

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

../webapps/ROOT/WEB-INF/classes/resource-actions/PF-ObjectList.xml
<!--?xml version="1.0"?-->


<resource-action-mapping>
	<portlet-resource>
		<portlet-name>PFObjectList_WAR_PFObjectListportlet</portlet-name>
		<permissions>
			<supports>
				<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
				<action-key>ADD_TO_PAGE</action-key>
				<action-key>CONFIGURATION</action-key>
				<action-key>VIEW</action-key>
				<action-key>PWTEST</action-key>
				<action-key>PWTEST2</action-key>
			</supports>
			<community-defaults>
				<action-key>VIEW</action-key>
			</community-defaults>
			<guest-defaults>
				<action-key>VIEW</action-key>
			</guest-defaults>
			<guest-unsupported>
				<action-key>ACCESS_IN_CONTROL_PANEL</action-key>
				<action-key>CONFIGURATION</action-key>
			</guest-unsupported>
		</permissions>
	</portlet-resource>
</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, geändert vor 11 Jahren.

RE: Custom Permissions

New Member Beiträge: 20 Beitrittsdatum: 30.11.12 Neueste Beiträge
Is noone working with custom permissions? Or has nobody encoutert this error?
Patrick Warnecke, geändert vor 11 Jahren.

RE: Custom Permissions (Antwort)

New Member Beiträge: 20 Beitrittsdatum: 30.11.12 Neueste 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.