How to authenticate user using OpenCMIS

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2014 01:35 PM
Hello Everyone,
I am new to Alfresco & OpenCMIS, infact started working just 3 days ago.
I am writing a Rest service to upload a document in the alfresco repository using OpenCMIS API.
I am able to upload/create the document in the repository by establishing connection using http://localhost:8080/alfresco/service/cmis with admin id/password.
Now the rest service can be invoked by any user and I want to know that:
1)How can I authenticate that user and check whether he has enough access to upload the document in the folder?
2) I have tried to run the application by changing the credentials in cofig file and provide non admin user & paswword, however this user has admin access but I am getting exceptions. Same thing is happening with other user ids too? In short it works only with admin id.
Please help.
Environment Details:
Windows 7
Chemistry OpenCMIS 0.11.0
Alfresco alfresco-community-4.2.c-installer-win-x32
I am new to Alfresco & OpenCMIS, infact started working just 3 days ago.
I am writing a Rest service to upload a document in the alfresco repository using OpenCMIS API.
I am able to upload/create the document in the repository by establishing connection using http://localhost:8080/alfresco/service/cmis with admin id/password.
Now the rest service can be invoked by any user and I want to know that:
1)How can I authenticate that user and check whether he has enough access to upload the document in the folder?
2) I have tried to run the application by changing the credentials in cofig file and provide non admin user & paswword, however this user has admin access but I am getting exceptions. Same thing is happening with other user ids too? In short it works only with admin id.
Please help.
Environment Details:
Windows 7
Chemistry OpenCMIS 0.11.0
Alfresco alfresco-community-4.2.c-installer-win-x32
Labels:
- Labels:
-
Archive
6 REPLIES 6
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2014 11:42 PM
If you are running 4.2.c you are using the wrong service URL, see http://wiki.alfresco.com/wiki/CMIS#CMIS_Service_URL.
Next, take a look at the CMIS spec, the Apache Chemistry docs, and/or the CMIS & Apache Chemistry book from Manning. Those are all good resources for things like this.
In the meantime, maybe this will help…Once you grab a folder, you can get the allowable actions, which includes whether or not the current user can create a new object.
Here is an example using the Groovy console in the OpenCMIS workbench.
This code:
Returns:
Jeff
Next, take a look at the CMIS spec, the Apache Chemistry docs, and/or the CMIS & Apache Chemistry book from Manning. Those are all good resources for things like this.
In the meantime, maybe this will help…Once you grab a folder, you can get the allowable actions, which includes whether or not the current user can create a new object.
Here is an example using the Groovy console in the OpenCMIS workbench.
This code:
doc = session.getObject('a8a507b5-e778-4e67-9795-339c405c0612;1.0')println doc.getAllowableActions()
Returns:
Allowable Actions [allowable actions=[CAN_DELETE_OBJECT, CAN_UPDATE_PROPERTIES, CAN_GET_PROPERTIES, CAN_GET_OBJECT_RELATIONSHIPS, CAN_GET_OBJECT_PARENTS, CAN_MOVE_OBJECT, CAN_DELETE_CONTENT_STREAM, CAN_CHECK_OUT, CAN_SET_CONTENT_STREAM, CAN_GET_ALL_VERSIONS, CAN_ADD_OBJECT_TO_FOLDER, CAN_REMOVE_OBJECT_FROM_FOLDER, CAN_GET_CONTENT_STREAM, CAN_GET_APPLIED_POLICIES, CAN_CREATE_RELATIONSHIP, CAN_GET_RENDITIONS, CAN_GET_ACL, CAN_APPLY_ACL]][extensions=null]
Jeff

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2014 08:27 AM
Thanks for your reply Jeff.
You have mentioned that I am using wrong service, but somehow my code is working fine for upload document.
Also, when I tried to give the service URL mentioned against Alfresco 4.2 i.e. http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom, I got some exceptions, so I reverted back to original one.
Now while uploading document I am setting the property PropertyIds.CREATED_BY but after the operation I am still getting modified by "Administrator", can you provide any pointer?
Thanks
You have mentioned that I am using wrong service, but somehow my code is working fine for upload document.
Also, when I tried to give the service URL mentioned against Alfresco 4.2 i.e. http://[host]:[port]/alfresco/api/-default-/public/cmis/versions/1.1/atom, I got some exceptions, so I reverted back to original one.
Now while uploading document I am setting the property PropertyIds.CREATED_BY but after the operation I am still getting modified by "Administrator", can you provide any pointer?
Thanks
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2014 08:37 AM
Yes, the deprecated/incorrect services may work for some operations but may return unpredictable or inoperable behaviors for others. That's why you should always use the correct service for the version of Alfresco you are running.
The reason you cannot set createdBy is because that property is not writable. If you use <a href="http://docs.oasis-open.org/cmis/CMIS/v1.1/os/CMIS-v1.1-os.html#x1-1830005">getTypeDefinition</a> you can get a list of the properties back and see whether or not they are writable. This is also easily done in the OpenCMIS Workbench by clicking on the "Types" button.
Jeff
The reason you cannot set createdBy is because that property is not writable. If you use <a href="http://docs.oasis-open.org/cmis/CMIS/v1.1/os/CMIS-v1.1-os.html#x1-1830005">getTypeDefinition</a> you can get a list of the properties back and see whether or not they are writable. This is also easily done in the OpenCMIS Workbench by clicking on the "Types" button.
Jeff
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2014 12:07 AM
cmis property "PropertyIds.CREATED_BY" is mapped to alfresco property "cm:creator"
cmis property "PropertyIds.LAST_MODIFIED_BY" is mapped to alfresco property "cm:modifier"
and cm:creator/cm:modifier all belongs to auditable properties,auditable properties are computed accroding to current authenticated user ,you can't override it except you disable disable auditable behaviour.But you can not do it using opencmis
cmis property "PropertyIds.LAST_MODIFIED_BY" is mapped to alfresco property "cm:modifier"
and cm:creator/cm:modifier all belongs to auditable properties,auditable properties are computed accroding to current authenticated user ,you can't override it except you disable disable auditable behaviour.But you can not do it using opencmis

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2014 10:00 AM
Hello Kaynezhang,
If I understood well you are trying to say that through open CMIS we cannot override the properties which are specific to Alfresco?
So how can we do that, can you provide the approach?
Thanks in advance.
If I understood well you are trying to say that through open CMIS we cannot override the properties which are specific to Alfresco?
So how can we do that, can you provide the approach?
Thanks in advance.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2014 10:03 AM
No ,I did not mean any properties ,just several properties that belong to autitable aspect.the auditable properties are automatically maitained by alfresco.
Here is a blog post that provides solution that allows to change values of the autitable properties.
Here is a blog post that provides solution that allows to change values of the autitable properties.
