String _userName = username;
String _password = password;
String _firstName = fristname;
String _lastName = lastname;
String _mail = mail;
String _disableAccount = "false";
String _quota = "-1";
String urlParameters = "{ \"username\" : \"" + _userName +"\", \"password\" : \"" + _password +"\"" +
",\"firstName\" : \"" + _firstName +"\", \"lastName\" : \"" + _lastName +"\"" +
",\"email\" : " + _mail +
",\"disableAccount\" : false , \"quota\" : -1 ,\"groups\":[] }";
//System.out.println("——-> " + urlParameters);
// {"userName":"jack","password":"1111","firstName":"jack","lastName":"den","email":"test@test.net","disableAccount":false,"quota":-1,"groups":[]};
//urlParameters ="{\"username\":\"jack\",\"password\":\"jack\",\"firstName\":\"jack\",\"lastName\":\"jack\",\"email\":jack@jack.it,\"disableAccount\":false,\"quota\":-1,\"groups\":[]};";
int _resultCode = 0;
String _userNameLogin = "admin";
String _passwordLogin = "admin";
URL url;
HttpURLConnection connection = null;
try
{
//JSON che verrà inviato alla post per la login
//String urlParameters = "{ \"username\" : \"" + _userName +"\", \"password\" : \"" + _password +"\" }";
// Apri la connessione
url = new URL("http://localhost:8080/alfresco/service/api/people");
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
//Imposto autenticazione
BASE64Encoder enc = new sun.misc.BASE64Encoder();
String userpassword = _userNameLogin + ":" + _passwordLogin;
String encodedAuthorization = enc.encode( userpassword.getBytes() );
connection.setRequestProperty("Authorization", "Basic "+ encodedAuthorization);
// String ticket = this.autorizathionUser(_userNameLogin, _passwordLogin);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length));
connection.setRequestProperty("Content-Language", "en-US");
// connection.setRequestProperty("ticket", ticket);
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
// Invia la richiesta
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(urlParameters);
wr.flush();
wr.close();
// OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream());
// osw.write(urlParameters);
// osw.close();
connection.connect();
_resultCode = connection.getResponseCode();
}
catch (Exception e)
{
e.printStackTrace();
return _resultCode;
}
finally
{
if (connection != null)
{
connection.disconnect();
}
}
return _resultCode;
}
Archive content from product discussions in Italian.
This group is now closed and content is read-only.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.