01-12-2015 10:37 AM
09-21-2016 06:01 PM
Both CMIS and web scripts can use tickets for authentication. So the answer is that you should grab a ticket and then use that to hit either CMIS or web script end points.
I do this a lot with little groovy utilities. You call /api/login to get a ticket, like this:
// Login to Alfresco
def client = new RESTClient(url)
def resp = client.get(path : ALF_SERVICE + '/api/login', query: ['u': userName, 'pw': password.toString(), 'format': 'json'])
assert resp.status == 200
def ticket = resp.data.data.ticket
println "Successfully logged in to Alfresco..."
Then once you have that ticket you can use it to make other calls.
For example, you might use CMIS to check for a folder:
// Leave the username as an empty string to auth with a ticketSession session = createCMISSession(url + CMIS_SERVICE, CMIS_BINDING, "", ticket);
Folder folder = findFolder(session, folderPath)
if (folder == null) {
println "ERROR: Could not find: " + folderPath
System.exit(0)
}
Folder findFolder(Session session, String folderPath) {
Folder result = null;
try {
CmisObject folder = session.getObjectByPath(folderPath);
if (folder != null && BaseTypeId.CMIS_FOLDER.equals(folder.getBaseTypeId())) {
result = (Folder) folder;
}
} catch (CmisObjectNotFoundException confe) {
println "ERROR: getObjectByPath threw a CmisObjectNotFoundException"
}
return result;
}
Or you might use the Alfresco API to look for a site:
// Checking for presence of site
resp = client.get(path : ALF_SERVICE + '/api/sites/' + siteId, query: ['alf_ticket': ticket])
assert resp.status == 200
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.