[opencms-dev] CmsObject.hasPermissions & CmsObject.readResource

Jonathan Woods jonathan.woods at scintillance.com
Wed Sep 27 08:36:38 CEST 2006


As far as I remember, I just tried to read the resource and caught the
Exception which arose when it wasn't possible - there didn't seem to be a
better way.  Maybe I didn't look hard enough, but it works fine.
 
Jon

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Joe Lam
Sent: 27 September 2006 07:26
To: opencms-dev at opencms.org
Subject: [opencms-dev] CmsObject.hasPermissions & CmsObject.readResource


Hi all,

I wanna execute hasPermissions before I read a resource. my problem is
hasPermissions requires CmsResource as parameter.

boolean	 hasPermissions
<http://www.opencms.org/export/javadoc/core/org/opencms/file/CmsObject.html#
hasPermissions%28org.opencms.file.CmsResource,%20org.opencms.security.CmsPer
missionSet%29> (CmsResource
<http://www.opencms.org/export/javadoc/core/org/opencms/file/CmsResource.htm
l>  resource, CmsPermissionSet
<http://www.opencms.org/export/javadoc/core/org/opencms/security/CmsPermissi
onSet.html>  requiredPermissions) 
          Checks if the current user has required permissions to access a
given resource.	
 boolean	 hasPermissions
<http://www.opencms.org/export/javadoc/core/org/opencms/file/CmsObject.html#
hasPermissions%28org.opencms.file.CmsResource,%20org.opencms.security.CmsPer
missionSet,%20boolean,%20org.opencms.file.CmsResourceFilter%29> (CmsResource
<http://www.opencms.org/export/javadoc/core/org/opencms/file/CmsResource.htm
l>  resource, CmsPermissionSet
<http://www.opencms.org/export/javadoc/core/org/opencms/security/CmsPermissi
onSet.html>  requiredPermissions, boolean checkLock, CmsResourceFilter
<http://www.opencms.org/export/javadoc/core/org/opencms/file/CmsResourceFilt
er.html>  filter) 	

How can I check the current user's permission b4 I read the resource?

if I do
CmsResource res=cmso.readResource(uri,
CmsResourceFilter.ONLY_VISIBLE_NO_DELETED );
I got run time error when someone has no read permission on that resource.
I think I should do hasPermissions check (or something similar) first.

please help

Thanks
Joe Lam

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060927/713dcb54/attachment.htm>


More information about the opencms-dev mailing list