X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/e8239f434aeb23f598080033ec5f15e0b1971f31..ea7f8fe49152fee3d92f1762d0e6538fa081c9d8:/src/com/owncloud/android/authentication/AccountAuthenticator.java diff --git a/src/com/owncloud/android/authentication/AccountAuthenticator.java b/src/com/owncloud/android/authentication/AccountAuthenticator.java index 30eda593..5d798917 100644 --- a/src/com/owncloud/android/authentication/AccountAuthenticator.java +++ b/src/com/owncloud/android/authentication/AccountAuthenticator.java @@ -23,6 +23,7 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; import com.owncloud.android.Log_OC; +import com.owncloud.android.MainApp; /** * Authenticator for ownCloud accounts. @@ -40,13 +41,15 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { * Is used by android system to assign accounts to authenticators. Should be * used by application and all extensions. */ - public static final String ACCOUNT_TYPE = "owncloud"; - public static final String AUTHORITY = "org.owncloud"; - public static final String AUTH_TOKEN_TYPE = "org.owncloud"; - public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password"; - public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token"; - public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token"; - + /* These constants are now in MainApp + public static final String ACCOUNT_TYPE = "owncloud"; + public static final String AUTHORITY = "org.owncloud"; + public static final String AUTH_TOKEN_TYPE = "org.owncloud"; + public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password"; + public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token"; + public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token"; + public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie"; + */ public static final String KEY_AUTH_TOKEN_TYPE = "authTokenType"; public static final String KEY_REQUIRED_FEATURES = "requiredFeatures"; public static final String KEY_LOGIN_OPTIONS = "loginOptions"; @@ -75,6 +78,10 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { * Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens. */ public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2"; + /** + * Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on. + */ + public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso"; private static final String TAG = AccountAuthenticator.class.getSimpleName(); @@ -171,7 +178,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { /// check if required token is stored final AccountManager am = AccountManager.get(mContext); String accessToken; - if (authTokenType.equals(AUTH_TOKEN_TYPE_PASSWORD)) { + if (authTokenType.equals(MainApp.getAuthTokenTypePass())) { accessToken = am.getPassword(account); } else { accessToken = am.peekAuthToken(account, authTokenType); @@ -179,7 +186,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { if (accessToken != null) { final Bundle result = new Bundle(); result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name); - result.putString(AccountManager.KEY_ACCOUNT_TYPE, ACCOUNT_TYPE); + result.putString(AccountManager.KEY_ACCOUNT_TYPE, MainApp.getAccountType()); result.putString(AccountManager.KEY_AUTHTOKEN, accessToken); return result; } @@ -244,17 +251,18 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator { private void validateAccountType(String type) throws UnsupportedAccountTypeException { - if (!type.equals(ACCOUNT_TYPE)) { + if (!type.equals(MainApp.getAccountType())) { throw new UnsupportedAccountTypeException(); } } private void validateAuthTokenType(String authTokenType) throws UnsupportedAuthTokenTypeException { - if (!authTokenType.equals(AUTH_TOKEN_TYPE) && - !authTokenType.equals(AUTH_TOKEN_TYPE_PASSWORD) && - !authTokenType.equals(AUTH_TOKEN_TYPE_ACCESS_TOKEN) && - !authTokenType.equals(AUTH_TOKEN_TYPE_REFRESH_TOKEN) ) { + if (!authTokenType.equals(MainApp.getAuthTokenType()) && + !authTokenType.equals(MainApp.getAuthTokenTypePass()) && + !authTokenType.equals(MainApp.getAuthTokenTypeAccessToken()) && + !authTokenType.equals(MainApp.getAuthTokenTypeRefreshToken()) && + !authTokenType.equals(MainApp.getAuthTokenTypeSamlSessionCookie())) { throw new UnsupportedAuthTokenTypeException(); } }