mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
OC-2465: review code
This commit is contained in:
parent
d3e0c5c6ce
commit
ea18765828
1 changed files with 8 additions and 11 deletions
|
@ -1181,7 +1181,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
|
||||||
|
|
||||||
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
|
} else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
|
||||||
|
|
||||||
String username= getUserNameForSaml(mHostBaseUrl);
|
String username= getUserNameForSaml();
|
||||||
if (username == null)
|
if (username == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1224,7 +1224,7 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
|
||||||
Uri uri = Uri.parse(mHostBaseUrl);
|
Uri uri = Uri.parse(mHostBaseUrl);
|
||||||
String username = mUsernameInput.getText().toString().trim();
|
String username = mUsernameInput.getText().toString().trim();
|
||||||
if (isSaml) {
|
if (isSaml) {
|
||||||
username = getUserNameForSaml(mHostBaseUrl);
|
username = getUserNameForSaml();
|
||||||
if (username == null)
|
if (username == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -1653,15 +1653,13 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
|
||||||
* Asynchronous task to get the SAML User name from OCS-API
|
* Asynchronous task to get the SAML User name from OCS-API
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private class GetUserNameTask extends AsyncTask<String, Void, String>{
|
private class GetUserNameTask extends AsyncTask<Void, Void, String>{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(String... params) {
|
protected String doInBackground(Void... params) {
|
||||||
|
|
||||||
String hostUrl = (String)params[0];
|
GetUserNameRemoteOperation getUserOperation = new GetUserNameRemoteOperation(mHostBaseUrl, mAuthToken);
|
||||||
|
WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl), getApplicationContext(), true);
|
||||||
GetUserNameRemoteOperation getUserOperation = new GetUserNameRemoteOperation(hostUrl, mAuthToken);
|
|
||||||
WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(hostUrl), getApplicationContext(), true);
|
|
||||||
RemoteOperationResult result = getUserOperation.execute(client);
|
RemoteOperationResult result = getUserOperation.execute(client);
|
||||||
|
|
||||||
return result.getUserName();
|
return result.getUserName();
|
||||||
|
@ -1671,15 +1669,14 @@ implements OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the user name form OCS-API
|
* Get the user name form OCS-API
|
||||||
* @param hostUrl
|
|
||||||
* @return username
|
* @return username
|
||||||
*/
|
*/
|
||||||
private String getUserNameForSaml(String hostUrl){
|
private String getUserNameForSaml(){
|
||||||
|
|
||||||
GetUserNameTask getUserTask = new GetUserNameTask();
|
GetUserNameTask getUserTask = new GetUserNameTask();
|
||||||
String username = null;
|
String username = null;
|
||||||
try {
|
try {
|
||||||
username = getUserTask.execute(mHostBaseUrl).get();
|
username = getUserTask.execute().get();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
|
Loading…
Reference in a new issue