projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added skeleton of new operation to detect authentication method in the server side
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
authentication
/
AuthenticatorActivity.java
diff --git
a/src/com/owncloud/android/authentication/AuthenticatorActivity.java
b/src/com/owncloud/android/authentication/AuthenticatorActivity.java
index
955dc54
..
a8293c3
100644
(file)
--- a/
src/com/owncloud/android/authentication/AuthenticatorActivity.java
+++ b/
src/com/owncloud/android/authentication/AuthenticatorActivity.java
@@
-35,7
+35,6
@@
import android.net.http.SslError;
import android.os.Bundle;
\r
import android.os.Handler;
\r
import android.preference.PreferenceManager;
\r
import android.os.Bundle;
\r
import android.os.Handler;
\r
import android.preference.PreferenceManager;
\r
-import android.support.v4.app.DialogFragment;
\r
import android.support.v4.app.Fragment;
\r
import android.support.v4.app.FragmentManager;
\r
import android.support.v4.app.FragmentTransaction;
\r
import android.support.v4.app.Fragment;
\r
import android.support.v4.app.FragmentManager;
\r
import android.support.v4.app.FragmentTransaction;
\r
@@
-74,8
+73,7
@@
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
\r
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
\r
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
\r
import com.owncloud.android.lib.common.operations.RemoteOperationResult.ResultCode;
\r
import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation;
\r
import com.owncloud.android.lib.resources.users.GetRemoteUserNameOperation;
\r
-
-import com.owncloud.android.ui.dialog.AlertMessageDialog;
\r
+
\r
import com.owncloud.android.ui.dialog.SamlWebViewDialog;
\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
\r
import com.owncloud.android.ui.dialog.SamlWebViewDialog;
\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog;
\r
import com.owncloud.android.ui.dialog.SslUntrustedCertDialog.OnSslUntrustedCertListener;
\r
@@
-130,7
+128,6
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
public static final byte ACTION_UPDATE_TOKEN = 1;
\r
\r
private static final String TAG_SAML_DIALOG = "samlWebViewDialog";
\r
public static final byte ACTION_UPDATE_TOKEN = 1;
\r
\r
private static final String TAG_SAML_DIALOG = "samlWebViewDialog";
\r
- private static final String TAG_ALERT_MESSAGE_DIALOG = "alertMessagewDialog";
\r
\r
private String mHostBaseUrl;
\r
private OwnCloudVersion mDiscoveredVersion;
\r
\r
private String mHostBaseUrl;
\r
private OwnCloudVersion mDiscoveredVersion;
\r
@@
-179,7
+176,7
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
\r
public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";
\r
\r
\r
public static String DIALOG_UNTRUSTED_CERT = "DIALOG_UNTRUSTED_CERT";
\r
\r
- private boolean m
TryEmptyAuthorization
= false;
\r
+ private boolean m
DetectAuthorizationMethod
= false;
\r
\r
\r
/**
\r
\r
\r
/**
\r
@@
-900,17
+897,20
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
mDiscoveredVersion = operation.getDiscoveredVersion();
\r
mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());
\r
\r
mDiscoveredVersion = operation.getDiscoveredVersion();
\r
mHostBaseUrl = normalizeUrl(mHostUrlInput.getText().toString());
\r
\r
+ // Refresh server status, but don't show it
\r
+ updateServerStatusIconAndText(result);
\r
+
\r
/// update status icon and text
\r
if (mServerIsValid) {
\r
hideRefreshButton();
\r
// Try to create an account with user and pass "", to know if it is a regular server
\r
// Update connect button in the answer of this method
\r
/// update status icon and text
\r
if (mServerIsValid) {
\r
hideRefreshButton();
\r
// Try to create an account with user and pass "", to know if it is a regular server
\r
// Update connect button in the answer of this method
\r
-
tryEmptyAuthorization
();
\r
+
detectAuthorizationMethod
();
\r
} else {
\r
showRefreshButton();
\r
} else {
\r
showRefreshButton();
\r
+ // Show server status
\r
+ showServerStatus();
\r
}
\r
}
\r
- updateServerStatusIconAndText(result);
\r
- showServerStatus();
\r
\r
/// very special case (TODO: move to a common place for all the remote operations)
\r
if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
\r
\r
/// very special case (TODO: move to a common place for all the remote operations)
\r
if (result.getCode() == ResultCode.SSL_RECOVERABLE_PEER_UNVERIFIED) {
\r
@@
-926,14
+926,11
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
/**
\r
* Try to access with user/pass ""/"", to know if it is a regular server
\r
*/
\r
/**
\r
* Try to access with user/pass ""/"", to know if it is a regular server
\r
*/
\r
- private void
tryEmptyAuthorization
() {
\r
- m
TryEmptyAuthorization
= true;
\r
+ private void
detectAuthorizationMethod
() {
\r
+ m
DetectAuthorizationMethod
= true;
\r
\r
Log_OC.d(TAG, "Trying empty authorization to detect authentication method");
\r
\r
\r
Log_OC.d(TAG, "Trying empty authorization to detect authentication method");
\r
\r
- /// be gentle with the user
\r
- showDialog(DIALOG_LOGIN_PROGRESS);
\r
-
\r
/// get the path to the root folder through WebDAV from the version server
\r
String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);
\r
\r
/// get the path to the root folder through WebDAV from the version server
\r
String webdav_path = AccountUtils.getWebdavPath(mDiscoveredVersion, mAuthTokenType);
\r
\r
@@
-1146,10
+1143,15
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
\r
\r
private void updateStatusIconFailUserName(){
\r
\r
\r
private void updateStatusIconFailUserName(){
\r
- mAuthStatusIcon =
android.R.drawable.ic_secure
;
\r
+ mAuthStatusIcon =
R.drawable.common_error
;
\r
mAuthStatusText = R.string.auth_fail_get_user_name;
\r
}
\r
\r
mAuthStatusText = R.string.auth_fail_get_user_name;
\r
}
\r
\r
+ private void updateServerStatusIconNoRegularAuth(){
\r
+ mServerStatusIcon = R.drawable.common_error;
\r
+ mServerStatusText = R.string.auth_can_not_auth_against_server;
\r
+ }
\r
+
\r
/**
\r
* Processes the result of the request for and access token send
\r
* to an OAuth authorization server.
\r
/**
\r
* Processes the result of the request for and access token send
\r
* to an OAuth authorization server.
\r
@@
-1201,14
+1203,14
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
\r
\r
if (result.isSuccess()) {
\r
}
\r
\r
if (result.isSuccess()) {
\r
-
\r
- if (mTryEmptyAuthorization) {
\r
- //allow or not the user try to access the server
\r
+ //allow or not the user try to access the server
\r
+ if (mDetectAuthorizationMethod) {
\r
mOkButton.setEnabled(false);
\r
mOkButton.setEnabled(false);
\r
- m
TryEmptyAuthorization
= false;
\r
+ m
DetectAuthorizationMethod
= false;
\r
mServerIsValid = false;
\r
mServerIsValid = false;
\r
- //show an alert message
\r
- showAlertMessageDialog(R.string.common_alert_title, R.string.auth_unsupported_auth_method);
\r
+ //show an alert message ( Server Status )
\r
+ updateServerStatusIconNoRegularAuth();
\r
+ showServerStatus();
\r
\r
} else {
\r
Log_OC.d(TAG, "Successful access - time to save the account");
\r
\r
} else {
\r
Log_OC.d(TAG, "Successful access - time to save the account");
\r
@@
-1228,10
+1230,14
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
\r
\r
} else {
\r
}
\r
\r
} else {
\r
- if (mTryEmptyAuthorization) {
\r
- mTryEmptyAuthorization = false;
\r
+ if (mDetectAuthorizationMethod &&
\r
+ ( result.getCode() == ResultCode.UNAUTHORIZED && result.isBasicAuthentication())) {
\r
+ mDetectAuthorizationMethod = false;
\r
mOkButton.setEnabled(true);
\r
mOkButton.setEnabled(true);
\r
-
\r
+
\r
+ // Show server status
\r
+ showServerStatus();
\r
+
\r
} else if (result.isServerFail() || result.isException()) {
\r
/// if server fail or exception in authorization, the UI is updated as when a server check failed
\r
mServerIsChecked = true;
\r
} else if (result.isServerFail() || result.isException()) {
\r
/// if server fail or exception in authorization, the UI is updated as when a server check failed
\r
mServerIsChecked = true;
\r
@@
-1781,10
+1787,5
@@
public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
\r
\r
}
\r
}
\r
\r
}
\r
-
\r
- private void showAlertMessageDialog(int tittle, int message) {
\r
- DialogFragment newAlertMessage = AlertMessageDialog.newInstance(tittle, message);
\r
- newAlertMessage.show(getSupportFragmentManager(), TAG_ALERT_MESSAGE_DIALOG);
\r
- }
\r
\r
}
\r
\r
}
\r