mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 06:05:42 +03:00
Merge pull request #2689 from nextcloud/fixAuth
Auth: Do not use context on static
This commit is contained in:
commit
84776053ff
2 changed files with 18 additions and 15 deletions
|
@ -14,7 +14,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.1.2'
|
||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
classpath 'org.codehaus.groovy:groovy-all:2.4.12'
|
||||
classpath('com.dicedmelon.gradle:jacoco-android:0.1.2') {
|
||||
|
|
|
@ -242,10 +242,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
/// Identifier of operation in progress which result shouldn't be lost
|
||||
private long mWaitingForOpId = Long.MAX_VALUE;
|
||||
|
||||
private final String BASIC_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType(this));
|
||||
private final String OAUTH_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType(this));
|
||||
private final String SAML_TOKEN_TYPE = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(
|
||||
MainApp.getAccountType(this));
|
||||
private String basicTokenType;
|
||||
private String oauthTokenType;
|
||||
private String samlTokenType;
|
||||
|
||||
private boolean webViewLoginMethod;
|
||||
private String webViewUser;
|
||||
|
@ -264,6 +263,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
//Log_OC.e(TAG, "onCreate init");
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
basicTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType(this));
|
||||
oauthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType(this));
|
||||
samlTokenType = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType(this));
|
||||
|
||||
// delete cookies for webView
|
||||
deleteCookies();
|
||||
|
||||
|
@ -561,11 +564,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
|
||||
private String chooseAuthTokenType(boolean oauth, boolean saml) {
|
||||
if (saml) {
|
||||
return SAML_TOKEN_TYPE;
|
||||
return samlTokenType;
|
||||
} else if (oauth) {
|
||||
return OAUTH_TOKEN_TYPE;
|
||||
return oauthTokenType;
|
||||
} else {
|
||||
return BASIC_TOKEN_TYPE;
|
||||
return basicTokenType;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -911,10 +914,10 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
String password = savedInstanceState.getString(KEY_PASSWORD);
|
||||
|
||||
OwnCloudCredentials credentials = null;
|
||||
if (BASIC_TOKEN_TYPE.equals(mAuthTokenType)) {
|
||||
if (basicTokenType.equals(mAuthTokenType)) {
|
||||
credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password);
|
||||
|
||||
} else if (OAUTH_TOKEN_TYPE.equals(mAuthTokenType)) {
|
||||
} else if (oauthTokenType.equals(mAuthTokenType)) {
|
||||
credentials = OwnCloudCredentialsFactory.newBearerCredentials(mAuthToken);
|
||||
|
||||
}
|
||||
|
@ -1475,11 +1478,11 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
|
||||
|
||||
private boolean authSupported(AuthenticationMethod authMethod) {
|
||||
return ((BASIC_TOKEN_TYPE.equals(mAuthTokenType) &&
|
||||
return ((basicTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BASIC_HTTP_AUTH.equals(authMethod)) ||
|
||||
(OAUTH_TOKEN_TYPE.equals(mAuthTokenType) &&
|
||||
(oauthTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.BEARER_TOKEN.equals(authMethod)) ||
|
||||
(SAML_TOKEN_TYPE.equals(mAuthTokenType) &&
|
||||
(samlTokenType.equals(mAuthTokenType) &&
|
||||
AuthenticationMethod.SAML_WEB_SSO.equals(authMethod))
|
||||
);
|
||||
}
|
||||
|
@ -2020,9 +2023,9 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
|
|||
public void onCheckClick(View view) {
|
||||
CheckBox oAuth2Check = (CheckBox) view;
|
||||
if (oAuth2Check.isChecked()) {
|
||||
mAuthTokenType = OAUTH_TOKEN_TYPE;
|
||||
mAuthTokenType = oauthTokenType;
|
||||
} else {
|
||||
mAuthTokenType = BASIC_TOKEN_TYPE;
|
||||
mAuthTokenType = basicTokenType;
|
||||
}
|
||||
updateAuthenticationPreFragmentVisibility();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue