07-08-2010 06:17 AM
07-08-2010 06:48 AM
a) is there any URL with uname/pwd as parameters to login ?There is a Login WebScript for this at the following URL that you can execute with a GET HTTP:
b) is there any URL with only alfresco ticket as parameters to login ?It is not possible to do this. You have to authenticate against Alfresco using username and password for the first time usgin for example the login WebScript.
07-08-2010 07:01 AM
07-08-2010 08:24 AM
08-04-2010 01:51 PM
a) is there any URL with uname/pwd as parameters to login ?There is a Login WebScript for this at the following URL that you can execute with a GET HTTP:
/alfresco/service/api/login?u={username}&pw={password?}
The u parameter is the username and the pw parameter is the password.b) is there any URL with only alfresco ticket as parameters to login ?It is not possible to do this. You have to authenticate against Alfresco using username and password for the first time usgin for example the login WebScript.
The previous URL will return you the Alfresco Ticket in the HTTP response. The ticket can be used to invoke other WebScripts adding the alf_ticket parameter in the query string, for example:
/alfresco/service/ui/myspaces?alf_ticket=ALF_TICKET_VALUE
For all the next requests using the alf_ticket, the user can access to all the services without executing the login process.
Hope this helps.
08-04-2010 05:20 PM
08-26-2010 11:15 PM
public String getAlfTicket(String _userName, String _password)
{
String _ticket = "";
URL url;
HttpURLConnection connection = null;
try
{
String urlParameters = "{ \"username\" : \"" + _userName +"\", \"password\" : \"" + _password +"\" }";
// Create connection
url = new URL("http://localhost:8080/alfresco/service/api/login");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
// Send request
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
// Get Response
InputStream is = connection.getInputStream();
BufferedReader rd = new BufferedReader(new InputStreamReader(is));
String line;
StringBuffer response = new StringBuffer();
while ((line = rd.readLine()) != null)
{
response.append(line);
response.append('\r');
}
rd.close();
String _jsonResponse = response.toString();
JSONObject _jsonResponseObject = (JSONObject)new JSONParser().parse(_jsonResponse);
JSONObject jsonDataObject = (JSONObject)new JSONParser().parse(_jsonResponseObject.get("data").toString());
_ticket = jsonDataObject.get("ticket").toString();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
finally
{
if (connection != null)
{
connection.disconnect();
}
}
return _ticket;
}
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.