Loading src/com/owncloud/android/lib/common/DynamicSessionManager.java +0 −10 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import android.accounts.OperationCanceledException; import android.content.Context; import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import java.io.IOException; Loading Loading @@ -36,16 +35,7 @@ public class DynamicSessionManager implements OwnCloudClientManager { throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { OwnCloudVersion ownCloudVersion = null; if (account.getSavedAccount() != null) { ownCloudVersion = AccountUtils.getServerVersionForAccount(account.getSavedAccount(), context); } if (ownCloudVersion != null && ownCloudVersion.isPreemptiveAuthenticationPreferred()) { return mSingleSessionManager.getClientFor(account, context, useNextcloudUserAgent); } else { return mSimpleFactoryManager.getClientFor(account, context, useNextcloudUserAgent); } } @Override Loading src/com/owncloud/android/lib/common/OwnCloudClient.java +7 −13 Original line number Diff line number Diff line Loading @@ -282,9 +282,7 @@ public class OwnCloudClient extends HttpClient { if (destination != null) { int suffixIndex = locationStr.lastIndexOf( (mCredentials instanceof OwnCloudBearerCredentials) ? AccountUtils.ODAV_PATH : AccountUtils.WEBDAV_PATH_4_0 ); AccountUtils.ODAV_PATH : AccountUtils.WEBDAV_PATH_4_0); String redirectionBase = locationStr.substring(0, suffixIndex); String destinationStr = destination.getValue(); Loading Loading @@ -345,17 +343,13 @@ public class OwnCloudClient extends HttpClient { } } public Uri getNewWebdavUri(boolean filesUri) { public Uri getNewWebdavUri() { if (mCredentials instanceof OwnCloudBearerCredentials) { return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH); } else { if (filesUri) { return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0); } else { return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_9_0); } } } /** * Sets the root URI to the ownCloud server. Loading src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +2 −3 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public class OwnCloudClientFactory { OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext); OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials( username, password, (version != null && version.isPreemptiveAuthenticationPreferred())); username, password); client.setCredentials(credentials); } Loading Loading @@ -188,9 +188,8 @@ public class OwnCloudClientFactory { Bundle result = future.getResult(); String password = result.getString(AccountManager.KEY_AUTHTOKEN); OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext); OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials( username, password, (version != null && version.isPreemptiveAuthenticationPreferred())); username, password); client.setCredentials(credentials); } Loading src/com/owncloud/android/lib/common/OwnCloudCredentialsFactory.java +0 −4 Original line number Diff line number Diff line Loading @@ -34,10 +34,6 @@ public class OwnCloudCredentialsFactory { return new OwnCloudBasicCredentials(username, password); } public static OwnCloudCredentials newBasicCredentials(String username, String password, boolean preemptiveMode) { return new OwnCloudBasicCredentials(username, password, preemptiveMode); } public static OwnCloudCredentials newBearerCredentials(String authToken) { return new OwnCloudBearerCredentials(authToken); } Loading src/com/owncloud/android/lib/common/accounts/AccountUtils.java +30 −62 Original line number Diff line number Diff line Loading @@ -47,27 +47,21 @@ public class AccountUtils { private static final String TAG = AccountUtils.class.getSimpleName(); public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php"; public static final String WEBDAV_PATH_2_0 = "/files/webdav.php"; public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav"; public static final String WEBDAV_PATH_9_0 = "/remote.php/dav"; public static final String ODAV_PATH = "/remote.php/odav"; private static final String SAML_SSO_PATH = "/remote.php/webdav"; public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php"; public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php"; public static final String STATUS_PATH = "/status.php"; /** * Returns the proper URL path to access the WebDAV interface of an ownCloud server, * according to its version and the authorization method used. * according to its authorization method used. * * @param version Version of ownCloud server. * @param supportsOAuth If true, access with OAuth 2 authorization is considered. * @param supportsSamlSso If true, and supportsOAuth is false, access with SAML-based single-sign-on is considered. * @return WebDAV path for given OC version, null if OC version unknown * @return default WebDAV path, if no OAuth/Samal */ public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth, boolean supportsSamlSso) { if (version != null) { public static String getWebdavPath(boolean supportsOAuth, boolean supportsSamlSso) { if (supportsOAuth) { return ODAV_PATH; } Loading @@ -75,15 +69,7 @@ public class AccountUtils { return SAML_SSO_PATH; } if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0) return WEBDAV_PATH_4_0; if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0 || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0) return WEBDAV_PATH_2_0; if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0) return WEBDAV_PATH_1_2; } return null; } /** Loading @@ -103,8 +89,7 @@ public class AccountUtils { String version = ama.getUserData(account, Constants.KEY_OC_VERSION); boolean supportsOAuth = (ama.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2) != null); boolean supportsSamlSso = (ama.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null); OwnCloudVersion ver = new OwnCloudVersion(version); String webdavpath = getWebdavPath(ver, supportsOAuth, supportsSamlSso); String webdavpath = getWebdavPath(supportsOAuth, supportsSamlSso); if (baseurl == null || webdavpath == null) throw new AccountNotFoundException(account, "Account not found", null); Loading Loading @@ -207,44 +192,27 @@ public class AccountUtils { AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; String username = AccountUtils.getUsernameForAccount(account); String ocVersion = am.getUserData(account, Constants.KEY_OC_VERSION); OwnCloudVersion version; if (ocVersion == null) { // set to oldest supported version version = OwnCloudVersion.nextcloud_10; } else { version = new OwnCloudVersion(ocVersion); } if (isOauth2) { String accessToken = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), false); String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), false); credentials = OwnCloudCredentialsFactory.newBearerCredentials(accessToken); } else if (isSamlSso) { String accessToken = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), false); String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), false); credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken); } else { String password = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypePass(account.type), String password = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypePass(account.type), false); credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password, version.isPreemptiveAuthenticationPreferred()); credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password); } return credentials; } Loading Loading
src/com/owncloud/android/lib/common/DynamicSessionManager.java +0 −10 Original line number Diff line number Diff line Loading @@ -5,7 +5,6 @@ import android.accounts.OperationCanceledException; import android.content.Context; import com.owncloud.android.lib.common.accounts.AccountUtils; import com.owncloud.android.lib.resources.status.OwnCloudVersion; import java.io.IOException; Loading Loading @@ -36,16 +35,7 @@ public class DynamicSessionManager implements OwnCloudClientManager { throws AccountUtils.AccountNotFoundException, OperationCanceledException, AuthenticatorException, IOException { OwnCloudVersion ownCloudVersion = null; if (account.getSavedAccount() != null) { ownCloudVersion = AccountUtils.getServerVersionForAccount(account.getSavedAccount(), context); } if (ownCloudVersion != null && ownCloudVersion.isPreemptiveAuthenticationPreferred()) { return mSingleSessionManager.getClientFor(account, context, useNextcloudUserAgent); } else { return mSimpleFactoryManager.getClientFor(account, context, useNextcloudUserAgent); } } @Override Loading
src/com/owncloud/android/lib/common/OwnCloudClient.java +7 −13 Original line number Diff line number Diff line Loading @@ -282,9 +282,7 @@ public class OwnCloudClient extends HttpClient { if (destination != null) { int suffixIndex = locationStr.lastIndexOf( (mCredentials instanceof OwnCloudBearerCredentials) ? AccountUtils.ODAV_PATH : AccountUtils.WEBDAV_PATH_4_0 ); AccountUtils.ODAV_PATH : AccountUtils.WEBDAV_PATH_4_0); String redirectionBase = locationStr.substring(0, suffixIndex); String destinationStr = destination.getValue(); Loading Loading @@ -345,17 +343,13 @@ public class OwnCloudClient extends HttpClient { } } public Uri getNewWebdavUri(boolean filesUri) { public Uri getNewWebdavUri() { if (mCredentials instanceof OwnCloudBearerCredentials) { return Uri.parse(mBaseUri + AccountUtils.ODAV_PATH); } else { if (filesUri) { return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_4_0); } else { return Uri.parse(mBaseUri + AccountUtils.WEBDAV_PATH_9_0); } } } /** * Sets the root URI to the ownCloud server. Loading
src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +2 −3 Original line number Diff line number Diff line Loading @@ -114,7 +114,7 @@ public class OwnCloudClientFactory { OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext); OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials( username, password, (version != null && version.isPreemptiveAuthenticationPreferred())); username, password); client.setCredentials(credentials); } Loading Loading @@ -188,9 +188,8 @@ public class OwnCloudClientFactory { Bundle result = future.getResult(); String password = result.getString(AccountManager.KEY_AUTHTOKEN); OwnCloudVersion version = AccountUtils.getServerVersionForAccount(account, appContext); OwnCloudCredentials credentials = OwnCloudCredentialsFactory.newBasicCredentials( username, password, (version != null && version.isPreemptiveAuthenticationPreferred())); username, password); client.setCredentials(credentials); } Loading
src/com/owncloud/android/lib/common/OwnCloudCredentialsFactory.java +0 −4 Original line number Diff line number Diff line Loading @@ -34,10 +34,6 @@ public class OwnCloudCredentialsFactory { return new OwnCloudBasicCredentials(username, password); } public static OwnCloudCredentials newBasicCredentials(String username, String password, boolean preemptiveMode) { return new OwnCloudBasicCredentials(username, password, preemptiveMode); } public static OwnCloudCredentials newBearerCredentials(String authToken) { return new OwnCloudBearerCredentials(authToken); } Loading
src/com/owncloud/android/lib/common/accounts/AccountUtils.java +30 −62 Original line number Diff line number Diff line Loading @@ -47,27 +47,21 @@ public class AccountUtils { private static final String TAG = AccountUtils.class.getSimpleName(); public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php"; public static final String WEBDAV_PATH_2_0 = "/files/webdav.php"; public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav"; public static final String WEBDAV_PATH_9_0 = "/remote.php/dav"; public static final String ODAV_PATH = "/remote.php/odav"; private static final String SAML_SSO_PATH = "/remote.php/webdav"; public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php"; public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php"; public static final String STATUS_PATH = "/status.php"; /** * Returns the proper URL path to access the WebDAV interface of an ownCloud server, * according to its version and the authorization method used. * according to its authorization method used. * * @param version Version of ownCloud server. * @param supportsOAuth If true, access with OAuth 2 authorization is considered. * @param supportsSamlSso If true, and supportsOAuth is false, access with SAML-based single-sign-on is considered. * @return WebDAV path for given OC version, null if OC version unknown * @return default WebDAV path, if no OAuth/Samal */ public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth, boolean supportsSamlSso) { if (version != null) { public static String getWebdavPath(boolean supportsOAuth, boolean supportsSamlSso) { if (supportsOAuth) { return ODAV_PATH; } Loading @@ -75,15 +69,7 @@ public class AccountUtils { return SAML_SSO_PATH; } if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0) return WEBDAV_PATH_4_0; if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0 || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0) return WEBDAV_PATH_2_0; if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0) return WEBDAV_PATH_1_2; } return null; } /** Loading @@ -103,8 +89,7 @@ public class AccountUtils { String version = ama.getUserData(account, Constants.KEY_OC_VERSION); boolean supportsOAuth = (ama.getUserData(account, Constants.KEY_SUPPORTS_OAUTH2) != null); boolean supportsSamlSso = (ama.getUserData(account, Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null); OwnCloudVersion ver = new OwnCloudVersion(version); String webdavpath = getWebdavPath(ver, supportsOAuth, supportsSamlSso); String webdavpath = getWebdavPath(supportsOAuth, supportsSamlSso); if (baseurl == null || webdavpath == null) throw new AccountNotFoundException(account, "Account not found", null); Loading Loading @@ -207,44 +192,27 @@ public class AccountUtils { AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; String username = AccountUtils.getUsernameForAccount(account); String ocVersion = am.getUserData(account, Constants.KEY_OC_VERSION); OwnCloudVersion version; if (ocVersion == null) { // set to oldest supported version version = OwnCloudVersion.nextcloud_10; } else { version = new OwnCloudVersion(ocVersion); } if (isOauth2) { String accessToken = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), false); String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), false); credentials = OwnCloudCredentialsFactory.newBearerCredentials(accessToken); } else if (isSamlSso) { String accessToken = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), false); String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), false); credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken); } else { String password = am.blockingGetAuthToken( account, AccountTypeUtils.getAuthTokenTypePass(account.type), String password = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypePass(account.type), false); credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password, version.isPreemptiveAuthenticationPreferred()); credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password); } return credentials; } Loading