From 0d0b711556551e3fd7fef04329616d779bec699b Mon Sep 17 00:00:00 2001 From: theScrabi Date: Wed, 27 Jun 2018 17:16:07 +0200 Subject: [PATCH] remove apache httpclient imports --- .../lib/common/OwnCloudClientFactory.java | 11 - .../lib/common/SingleSessionManager.java | 2 +- .../OwnCloudBasicCredentials.java | 15 +- .../OwnCloudBearerCredentials.java | 10 - .../OwnCloudSamlSsoCredentials.java | 2 +- .../oauth/BearerAuthScheme.java | 262 ------------- .../oauth/BearerCredentials.java | 13 +- .../lib/common/http/HttpConstants.java | 4 + .../network/AdvancedSslSocketFactory.java | 344 ------------------ .../ChunkFromFileChannelRequestEntity.java | 4 +- .../lib/common/network/FileRequestEntity.java | 74 +--- .../lib/common/network/NetworkUtils.java | 74 +--- .../lib/common/network/RedirectionPath.java | 6 +- .../operations/RemoteOperationResult.java | 130 +------ .../status/GetRemoteStatusOperation.java | 2 +- .../users/GetRemoteUserAvatarOperation.java | 4 +- .../SelfSignedConfidentSslSocketFactory.java | 6 - .../lib/test_project/TestActivity.java | 4 +- .../lib/test_project/test/CopyFileTest.java | 8 +- .../test/GetCapabilitiesTest.java | 4 +- .../lib/test_project/test/GetShareesTest.java | 14 +- .../test_project/test/GetUserAvatarTest.java | 4 +- .../lib/test_project/test/MoveFileTest.java | 8 +- .../test_project/test/OwnCloudClientTest.java | 14 +- .../test/SimpleFactoryManagerTest.java | 4 +- .../test/SingleSessionManagerTest.java | 4 +- .../test/UpdatePrivateShareTest.java | 4 +- .../test/UpdatePublicShareTest.java | 4 +- 28 files changed, 83 insertions(+), 952 deletions(-) delete mode 100644 src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java delete mode 100644 src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java diff --git a/src/com/owncloud/android/lib/common/OwnCloudClientFactory.java b/src/com/owncloud/android/lib/common/OwnCloudClientFactory.java index 33ded0e5..a77568f5 100644 --- a/src/com/owncloud/android/lib/common/OwnCloudClientFactory.java +++ b/src/com/owncloud/android/lib/common/OwnCloudClientFactory.java @@ -162,17 +162,6 @@ public class OwnCloudClientFactory { * @return A OwnCloudClient object ready to be used */ public static OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) { - try { - NetworkUtils.registerAdvancedSslContext(true, context); - } catch (GeneralSecurityException e) { - Log_OC.e(TAG, "Advanced SSL Context could not be loaded. Default SSL management in" + - " the system will be used for HTTPS connections", e); - - } catch (IOException e) { - Log_OC.e(TAG, "The local server truststore could not be read. Default SSL management" + - " in the system will be used for HTTPS connections", e); - } - OwnCloudClient client = new OwnCloudClient(uri); client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT); diff --git a/src/com/owncloud/android/lib/common/SingleSessionManager.java b/src/com/owncloud/android/lib/common/SingleSessionManager.java index 993fbd85..911ac59d 100644 --- a/src/com/owncloud/android/lib/common/SingleSessionManager.java +++ b/src/com/owncloud/android/lib/common/SingleSessionManager.java @@ -29,7 +29,7 @@ import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; -import org.apache.commons.httpclient.cookie.CookiePolicy; + import android.accounts.Account; import android.accounts.AuthenticatorException; diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java index d7be9cec..8fce943d 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudBasicCredentials.java @@ -31,11 +31,11 @@ import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor; import com.owncloud.android.lib.common.http.interceptors.HttpInterceptor.RequestInterceptor; import com.owncloud.android.lib.common.http.interceptors.SamlAuthInterceptor; -import org.apache.commons.httpclient.UsernamePasswordCredentials; -import org.apache.commons.httpclient.auth.AuthPolicy; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.auth.AuthState; -import org.apache.commons.httpclient.auth.BasicScheme; + + + + + import java.util.ArrayList; import java.util.List; @@ -62,11 +62,6 @@ public class OwnCloudBasicCredentials implements OwnCloudCredentials { @Override public void applyTo(OwnCloudClient client) { - AuthPolicy.registerAuthScheme(AuthState.PREEMPTIVE_AUTH_SCHEME, BasicScheme.class); - - List authPrefs = new ArrayList<>(1); - authPrefs.add(AuthPolicy.BASIC); - ArrayList requestInterceptors = HttpClient.getOkHttpInterceptor().getRequestInterceptors(); // Clear previous basic credentials diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java index c22a0ae7..2f44f12e 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudBearerCredentials.java @@ -23,18 +23,10 @@ */ package com.owncloud.android.lib.common.authentication; -import android.app.DownloadManager; - import java.util.ArrayList; -import java.util.List; -import org.apache.commons.httpclient.auth.AuthPolicy; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.auth.AuthState; import com.owncloud.android.lib.common.OwnCloudClient; -import com.owncloud.android.lib.common.authentication.oauth.BearerAuthScheme; -import com.owncloud.android.lib.common.authentication.oauth.BearerCredentials; import com.owncloud.android.lib.common.http.HttpClient; import com.owncloud.android.lib.common.http.interceptors.BarearAuthInterceptor; import com.owncloud.android.lib.common.http.interceptors.BasicAuthInterceptor; @@ -53,8 +45,6 @@ public class OwnCloudBearerCredentials implements OwnCloudCredentials { @Override public void applyTo(OwnCloudClient client) { - AuthPolicy.registerAuthScheme(BearerAuthScheme.AUTH_POLICY, BearerAuthScheme.class); - AuthPolicy.registerAuthScheme(AuthState.PREEMPTIVE_AUTH_SCHEME, BearerAuthScheme.class); final ArrayList requestInterceptors = HttpClient.getOkHttpInterceptor().getRequestInterceptors(); diff --git a/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java b/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java index 69c88316..40d4c785 100644 --- a/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/OwnCloudSamlSsoCredentials.java @@ -23,7 +23,7 @@ */ package com.owncloud.android.lib.common.authentication; -import org.apache.commons.httpclient.cookie.CookiePolicy; + import android.net.Uri; diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java b/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java deleted file mode 100644 index b0104342..00000000 --- a/src/com/owncloud/android/lib/common/authentication/oauth/BearerAuthScheme.java +++ /dev/null @@ -1,262 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.common.authentication.oauth; - -import java.util.Map; - -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.auth.AuthChallengeParser; -import org.apache.commons.httpclient.auth.AuthScheme; -import org.apache.commons.httpclient.auth.AuthenticationException; -import org.apache.commons.httpclient.auth.InvalidCredentialsException; -import org.apache.commons.httpclient.auth.MalformedChallengeException; - - - -/** - * Bearer authentication scheme as defined in RFC 6750. - * - * @author David A. Velasco - */ - -public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ { - - private static final String TAG = BearerAuthScheme.class.getSimpleName(); - - public static final String AUTH_POLICY = "Bearer"; - - /** Whether the bearer authentication process is complete */ - private boolean mComplete; - - /** Authentication parameter map */ - @SuppressWarnings("rawtypes") - private Map mParams = null; - - - /** - * Default constructor for the bearer authentication scheme. - */ - public BearerAuthScheme() { - mComplete = false; - } - - /** - * Constructor for the basic authentication scheme. - * - * @param challenge Authentication challenge - * - * @throws MalformedChallengeException Thrown if the authentication challenge is malformed - */ - public BearerAuthScheme(final String challenge) throws MalformedChallengeException { - processChallenge(challenge); - mComplete = true; - } - - /** - * Returns textual designation of the bearer authentication scheme. - * - * @return "Bearer" - */ - public String getSchemeName() { - return "bearer"; - } - - /** - * Processes the Bearer challenge. - * - * @param challenge The challenge string - * - * @throws MalformedChallengeException Thrown if the authentication challenge is malformed - */ - public void processChallenge(String challenge) throws MalformedChallengeException { - String s = AuthChallengeParser.extractScheme(challenge); - if (!s.equalsIgnoreCase(getSchemeName())) { - throw new MalformedChallengeException( - "Invalid " + getSchemeName() + " challenge: " + challenge); - } - mParams = AuthChallengeParser.extractParams(challenge); - mComplete = true; - } - - /** - * Tests if the Bearer authentication process has been completed. - * - * @return 'true' if Bearer authorization has been processed, 'false' otherwise. - */ - public boolean isComplete() { - return this.mComplete; - } - - /** - * Produces bearer authorization string for the given set of - * {@link Credentials}. - * - * @param credentials The set of credentials to be used for authentication - * @param method Method name is ignored by the bearer authentication scheme - * @param uri URI is ignored by the bearer authentication scheme - * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable - * for this authentication scheme - * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure - * @return A bearer authorization string - */ - public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException { - BearerCredentials bearer; - try { - bearer = (BearerCredentials) credentials; - } catch (ClassCastException e) { - throw new InvalidCredentialsException( - "Credentials cannot be used for bearer authentication: " - + credentials.getClass().getName()); - } - return BearerAuthScheme.authenticate(bearer); - } - - - /** - * Returns 'false'. Bearer authentication scheme is request based. - * - * @return 'false'. - */ - public boolean isConnectionBased() { - return false; - } - - /** - * Produces bearer authorization string for the given set of {@link Credentials}. - * - * @param credentials The set of credentials to be used for authentication - * @param method The method being authenticated - * @throws InvalidCredentialsException If authentication credentials are not valid or not applicable for this authentication - * scheme. - * @throws AuthenticationException If authorization string cannot be generated due to an authentication failure. - * - * @return a basic authorization string - */ - public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException { - if (method == null) { - throw new IllegalArgumentException("Method may not be null"); - } - BearerCredentials bearer = null; - try { - bearer = (BearerCredentials) credentials; - } catch (ClassCastException e) { - throw new InvalidCredentialsException( - "Credentials cannot be used for bearer authentication: " - + credentials.getClass().getName()); - } - return BearerAuthScheme.authenticate( - bearer, - method.getParams().getCredentialCharset()); - } - - /** - * Returns a bearer Authorization header value for the given - * {@link BearerCredentials}. - * - * @param credentials The credentials to encode. - * - * @return A bearer authorization string - */ - public static String authenticate(BearerCredentials credentials) { - return authenticate(credentials, "ISO-8859-1"); - } - - /** - * Returns a bearer Authorization header value for the given - * {@link BearerCredentials} and charset. - * - * @param credentials The credentials to encode. - * @param charset The charset to use for encoding the credentials - * - * @return A bearer authorization string - * - * @since 3.0 - */ - public static String authenticate(BearerCredentials credentials, String charset) { - - if (credentials == null) { - throw new IllegalArgumentException("Credentials may not be null"); - } - if (charset == null || charset.length() == 0) { - throw new IllegalArgumentException("charset may not be null or empty"); - } - StringBuffer buffer = new StringBuffer(); - buffer.append(credentials.getAccessToken()); - - return "Bearer " + buffer.toString(); - } - - /** - * Returns a String identifying the authentication challenge. This is - * used, in combination with the host and port to determine if - * authorization has already been attempted or not. Schemes which - * require multiple requests to complete the authentication should - * return a different value for each stage in the request. - * - * Additionally, the ID should take into account any changes to the - * authentication challenge and return a different value when appropriate. - * For example when the realm changes in basic authentication it should be - * considered a different authentication attempt and a different value should - * be returned. - * - * This method simply returns the realm for the challenge. - * - * @return String a String identifying the authentication challenge. - */ - @Override - public String getID() { - return getRealm(); - } - - /** - * Returns authentication parameter with the given name, if available. - * - * @param name The name of the parameter to be returned - * - * @return The parameter with the given name - */ - @Override - public String getParameter(String name) { - if (name == null) { - throw new IllegalArgumentException("Parameter name may not be null"); - } - if (mParams == null) { - return null; - } - return (String) mParams.get(name.toLowerCase()); - } - - /** - * Returns authentication realm. The realm may not be null. - * - * @return The authentication realm - */ - @Override - public String getRealm() { - return getParameter("realm"); - } - -} diff --git a/src/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java b/src/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java index c815bc4c..f83e6fd5 100644 --- a/src/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java +++ b/src/com/owncloud/android/lib/common/authentication/oauth/BearerCredentials.java @@ -24,16 +24,15 @@ package com.owncloud.android.lib.common.authentication.oauth; -import org.apache.commons.httpclient.Credentials; -import org.apache.commons.httpclient.util.LangUtils; /** - * Bearer token {@link Credentials} * * @author David A. Velasco */ -public class BearerCredentials implements Credentials { +public class BearerCredentials { + public static final int HASH_SEED = 17; + public static final int HASH_OFFSET = 37; private String mAccessToken; @@ -76,9 +75,7 @@ public class BearerCredentials implements Credentials { * @return The hash code of the access token */ public int hashCode() { - int hash = LangUtils.HASH_SEED; - hash = LangUtils.hashCode(hash, mAccessToken); - return hash; + return HASH_SEED * HASH_OFFSET + mAccessToken.hashCode(); } /** @@ -93,7 +90,7 @@ public class BearerCredentials implements Credentials { if (this == o) return true; if (this.getClass().equals(o.getClass())) { BearerCredentials that = (BearerCredentials) o; - if (LangUtils.equals(mAccessToken, that.mAccessToken)) { + if (mAccessToken.equals(that.mAccessToken)) { return true; } } diff --git a/src/com/owncloud/android/lib/common/http/HttpConstants.java b/src/com/owncloud/android/lib/common/http/HttpConstants.java index a892d812..76321402 100644 --- a/src/com/owncloud/android/lib/common/http/HttpConstants.java +++ b/src/com/owncloud/android/lib/common/http/HttpConstants.java @@ -29,6 +29,10 @@ package com.owncloud.android.lib.common.http; */ public class HttpConstants { + /*********************************************************************************************************** + *************************************************** HEADERS *********************************************** + ***********************************************************************************************************/ + /*********************************************************************************************************** *************************************************** HEADERS *********************************************** ***********************************************************************************************************/ diff --git a/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java b/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java deleted file mode 100644 index 873ec656..00000000 --- a/src/com/owncloud/android/lib/common/network/AdvancedSslSocketFactory.java +++ /dev/null @@ -1,344 +0,0 @@ -/* ownCloud Android Library is available under MIT license - * Copyright (C) 2016 ownCloud GmbH. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ - -package com.owncloud.android.lib.common.network; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketAddress; -import java.net.UnknownHostException; -import java.security.cert.X509Certificate; - -import javax.net.SocketFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLException; -import javax.net.ssl.SSLHandshakeException; -import javax.net.ssl.SSLParameters; -import javax.net.ssl.SSLPeerUnverifiedException; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocket; - -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.params.HttpConnectionParams; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.http.conn.ssl.X509HostnameVerifier; - -import com.owncloud.android.lib.common.utils.Log_OC; - - -/** - * AdvancedSSLProtocolSocketFactory allows to create SSL {@link Socket}s with - * a custom SSLContext and an optional Hostname Verifier. - * - * @author David A. Velasco - */ - -public class AdvancedSslSocketFactory implements SecureProtocolSocketFactory { - - private static final String TAG = AdvancedSslSocketFactory.class.getSimpleName(); - - private SSLContext mSslContext = null; - private AdvancedX509TrustManager mTrustManager = null; - private X509HostnameVerifier mHostnameVerifier = null; - - public SSLContext getSslContext() { - return mSslContext; - } - - /** - * Constructor for AdvancedSSLProtocolSocketFactory. - */ - public AdvancedSslSocketFactory( - SSLContext sslContext, AdvancedX509TrustManager trustManager, X509HostnameVerifier hostnameVerifier - ) { - - if (sslContext == null) - throw new IllegalArgumentException("AdvancedSslSocketFactory can not be created with a null SSLContext"); - if (trustManager == null && mHostnameVerifier != null) - throw new IllegalArgumentException( - "AdvancedSslSocketFactory can not be created with a null Trust Manager and a " + - "not null Hostname Verifier" - ); - mSslContext = sslContext; - mTrustManager = trustManager; - mHostnameVerifier = hostnameVerifier; - } - - /** - * @see ProtocolSocketFactory#createSocket(java.lang.String, int, java.net.InetAddress, int) - */ - @Override - public Socket createSocket(String host, int port, InetAddress clientHost, int clientPort) - throws IOException, UnknownHostException { - - Socket socket = mSslContext.getSocketFactory().createSocket(host, port, clientHost, clientPort); - enableSecureProtocols(socket); - verifyPeerIdentity(host, port, socket); - return socket; - } - - /* - private void logSslInfo() { - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.FROYO) { - Log_OC.v(TAG, "SUPPORTED SSL PARAMETERS"); - logSslParameters(mSslContext.getSupportedSSLParameters()); - Log_OC.v(TAG, "DEFAULT SSL PARAMETERS"); - logSslParameters(mSslContext.getDefaultSSLParameters()); - Log_OC.i(TAG, "CURRENT PARAMETERS"); - Log_OC.i(TAG, "Protocol: " + mSslContext.getProtocol()); - } - Log_OC.i(TAG, "PROVIDER"); - logSecurityProvider(mSslContext.getProvider()); - } - - private void logSecurityProvider(Provider provider) { - Log_OC.i(TAG, "name: " + provider.getName()); - Log_OC.i(TAG, "version: " + provider.getVersion()); - Log_OC.i(TAG, "info: " + provider.getInfo()); - Enumeration keys = provider.propertyNames(); - String key; - while (keys.hasMoreElements()) { - key = (String) keys.nextElement(); - Log_OC.i(TAG, " property " + key + " : " + provider.getProperty(key)); - } - } - - private void logSslParameters(SSLParameters params) { - Log_OC.v(TAG, "Cipher suites: "); - String [] elements = params.getCipherSuites(); - for (int i=0; i it = null; - long transferred = 0; - long size = mFile.length(); - if (size == 0) size = -1; - try { - while ((readResult = channel.read(tmp)) >= 0) { - try { - out.write(tmp.array(), 0, readResult); - } catch (IOException io) { - // work-around try catch to filter exception in writing - throw new WriteException(io); - } - tmp.clear(); - transferred += readResult; - synchronized (mDataTransferListeners) { - it = mDataTransferListeners.iterator(); - while (it.hasNext()) { - it.next().onTransferProgress(readResult, transferred, size, mFile.getAbsolutePath()); - } - } - } - - } catch (IOException io) { - // any read problem will be handled as if the file is not there - if (io instanceof FileNotFoundException) { - throw io; - } else { - FileNotFoundException fnf = new FileNotFoundException("Exception reading source file"); - fnf.initCause(io); - throw fnf; - } - - } catch (WriteException we) { - throw we.getWrapped(); - - } finally { - try { - channel.close(); - raf.close(); - } catch (IOException io) { - // ignore failures closing source file - } - } - } protected static class WriteException extends Exception { IOException mWrapped; diff --git a/src/com/owncloud/android/lib/common/network/NetworkUtils.java b/src/com/owncloud/android/lib/common/network/NetworkUtils.java index b5fa0cde..71740bc1 100644 --- a/src/com/owncloud/android/lib/common/network/NetworkUtils.java +++ b/src/com/owncloud/android/lib/common/network/NetworkUtils.java @@ -39,8 +39,8 @@ import java.security.cert.CertificateException; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; -import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; -import org.apache.commons.httpclient.protocol.Protocol; + + import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier; import org.apache.http.conn.ssl.X509HostnameVerifier; @@ -64,67 +64,7 @@ public class NetworkUtils { /** Standard name for protocol TLS version 1.0 in JSSE API */ public static final String PROTOCOL_TLSv1_0 = "TLSv1"; - /** Connection manager for all the OwnCloudClients */ - private static MultiThreadedHttpConnectionManager mConnManager = null; - - private static Protocol mDefaultHttpsProtocol = null; - - private static AdvancedSslSocketFactory mAdvancedSslSocketFactory = null; - private static X509HostnameVerifier mHostnameVerifier = null; - - - /** - * Registers or unregisters the proper components for advanced SSL handling. - * @throws IOException - */ - @SuppressWarnings("deprecation") - public static void registerAdvancedSslContext(boolean register, Context context) - throws GeneralSecurityException, IOException { - Protocol pr = null; - try { - pr = Protocol.getProtocol("https"); - if (pr != null && mDefaultHttpsProtocol == null) { - mDefaultHttpsProtocol = pr; - } - } catch (IllegalStateException e) { - // nothing to do here; really - } - boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory); - if (register && !isRegistered) { - Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443)); - - } else if (!register && isRegistered) { - if (mDefaultHttpsProtocol != null) { - Protocol.registerProtocol("https", mDefaultHttpsProtocol); - } - } - } - - public static AdvancedSslSocketFactory getAdvancedSslSocketFactory(Context context) - throws GeneralSecurityException, IOException { - if (mAdvancedSslSocketFactory == null) { - KeyStore trustStore = getKnownServersStore(context); - AdvancedX509TrustManager trustMgr = new AdvancedX509TrustManager(trustStore); - TrustManager[] tms = new TrustManager[] { trustMgr }; - - SSLContext sslContext; - try { - sslContext = SSLContext.getInstance("TLSv1.2"); - } catch (NoSuchAlgorithmException e) { - Log_OC.w(TAG, "TLSv1.2 is not supported in this device; falling through TLSv1.0"); - sslContext = SSLContext.getInstance("TLSv1"); - // should be available in any device; see reference of supported protocols in - // http://developer.android.com/reference/javax/net/ssl/SSLSocket.html - } - sslContext.init(null, tms, null); - - mHostnameVerifier = new BrowserCompatHostnameVerifier(); - mAdvancedSslSocketFactory = new AdvancedSslSocketFactory(sslContext, trustMgr, mHostnameVerifier); - } - return mAdvancedSslSocketFactory; - } - private static String LOCAL_TRUSTSTORE_FILENAME = "knownServers.bks"; @@ -183,16 +123,6 @@ public class NetworkUtils { fos.close(); } } - - - static public MultiThreadedHttpConnectionManager getMultiThreadedConnManager() { - if (mConnManager == null) { - mConnManager = new MultiThreadedHttpConnectionManager(); - mConnManager.getParams().setDefaultMaxConnectionsPerHost(5); - mConnManager.getParams().setMaxTotalConnections(5); - } - return mConnManager; - } public static boolean isCertInKnownServersStore(Certificate cert, Context context) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException { diff --git a/src/com/owncloud/android/lib/common/network/RedirectionPath.java b/src/com/owncloud/android/lib/common/network/RedirectionPath.java index eb8a8919..5f1b67ce 100644 --- a/src/com/owncloud/android/lib/common/network/RedirectionPath.java +++ b/src/com/owncloud/android/lib/common/network/RedirectionPath.java @@ -27,7 +27,9 @@ package com.owncloud.android.lib.common.network; -import org.apache.commons.httpclient.HttpStatus; + + +import com.owncloud.android.lib.common.http.HttpConstants; import java.util.Arrays; @@ -108,7 +110,7 @@ public class RedirectionPath { */ public String getLastPermanentLocation() { for (int i = mLastStatus; i >= 0; i--) { - if (mStatuses[i] == HttpStatus.SC_MOVED_PERMANENTLY && i <= mLastLocation) { + if (mStatuses[i] == HttpConstants.HTTP_MOVED_PERMANENTLY && i <= mLastLocation) { return mLocations[i]; } } diff --git a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java index 4b1d1347..c667ee1c 100644 --- a/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java +++ b/src/com/owncloud/android/lib/common/operations/RemoteOperationResult.java @@ -28,14 +28,15 @@ import android.accounts.Account; import android.accounts.AccountsException; import com.owncloud.android.lib.common.accounts.AccountUtils.AccountNotFoundException; +import com.owncloud.android.lib.common.http.HttpConstants; import com.owncloud.android.lib.common.http.methods.HttpBaseMethod; import com.owncloud.android.lib.common.network.CertificateCombinedException; import com.owncloud.android.lib.common.utils.Log_OC; -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.HttpMethod; -import org.apache.commons.httpclient.HttpStatus; + + + + import org.apache.jackrabbit.webdav.DavException; import org.json.JSONException; @@ -55,6 +56,7 @@ import java.util.Map; import javax.net.ssl.SSLException; import javax.net.ssl.SSLPeerUnverifiedException; +import at.bitfire.dav4android.exception.HttpException; import okhttp3.Headers; @@ -180,9 +182,6 @@ public class RemoteOperationResult implements Serializable { } else if (e instanceof SocketTimeoutException) { mCode = ResultCode.TIMEOUT; - } else if (e instanceof ConnectTimeoutException) { - mCode = ResultCode.TIMEOUT; - } else if (e instanceof MalformedURLException) { mCode = ResultCode.INCORRECT_ADDRESS; @@ -221,64 +220,6 @@ public class RemoteOperationResult implements Serializable { } } - /** - * Public constructor from separate elements of an HTTP or DAV response. - * - * To be used when the result needs to be interpreted from the response of an HTTP/DAV method. - * - * Determines a {@link ResultCode} from the already executed method received as a parameter. Generally, - * will depend on the HTTP code and HTTP response headers received. In some cases will inspect also the - * response body. - * - * @param success The operation was considered successful or not. - * @param httpMethod HTTP/DAV method already executed which response will be examined to interpret the - * result. - */ - // TODO Delete this - public RemoteOperationResult(boolean success, HttpMethod httpMethod) throws IOException { -// this( -// success, -// httpMethod.getStatusCode(), -// httpMethod.getStatusText(), -// httpMethod.getResponseHeaders() -// ); - - if (mHttpCode == HttpStatus.SC_BAD_REQUEST) { // 400 - - String bodyResponse = httpMethod.getResponseBodyAsString(); - // do not get for other HTTP codes!; could not be available - - if (bodyResponse != null && bodyResponse.length() > 0) { - InputStream is = new ByteArrayInputStream(bodyResponse.getBytes()); - InvalidCharacterExceptionParser xmlParser = new InvalidCharacterExceptionParser(); - try { - if (xmlParser.parseXMLResponse(is)) { - mCode = ResultCode.INVALID_CHARACTER_DETECT_IN_SERVER; - } - - } catch (Exception e) { - Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage()); - // mCode stays as set in this(success, httpCode, headers) - } - } - } - - if (mHttpCode == HttpStatus.SC_FORBIDDEN) { // 403 - - parseErrorMessageAndSetCode(httpMethod, ResultCode.SPECIFIC_FORBIDDEN); - } - - if (mHttpCode == HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE) { // 415 - - parseErrorMessageAndSetCode(httpMethod, ResultCode.SPECIFIC_UNSUPPORTED_MEDIA_TYPE); - } - - if (mHttpCode == HttpStatus.SC_SERVICE_UNAVAILABLE) { // 503 - - parseErrorMessageAndSetCode(httpMethod, ResultCode.SPECIFIC_SERVICE_UNAVAILABLE); - } - } - /** * Public constructor from separate elements of an HTTP or DAV response. * @@ -297,7 +238,7 @@ public class RemoteOperationResult implements Serializable { httpMethod.getResponseHeaders() ); - if (mHttpCode == HttpStatus.SC_BAD_REQUEST) { // 400 + if (mHttpCode == HttpConstants.HTTP_FORBIDDEN) { // 400 String bodyResponse = httpMethod.getResponseBodyAsString(); // do not get for other HTTP codes!; could not be available @@ -318,19 +259,19 @@ public class RemoteOperationResult implements Serializable { // before switch (mHttpCode) { - case HttpStatus.SC_FORBIDDEN: + case HttpConstants.HTTP_FORBIDDEN: parseErrorMessageAndSetCode( httpMethod.getResponseBodyAsString(), ResultCode.SPECIFIC_FORBIDDEN ); break; - case HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE: + case HttpConstants.HTTP_UNSUPPORTED_MEDIA_TYPE: parseErrorMessageAndSetCode( httpMethod.getResponseBodyAsString(), ResultCode.SPECIFIC_UNSUPPORTED_MEDIA_TYPE ); break; - case HttpStatus.SC_SERVICE_UNAVAILABLE: + case HttpConstants.HTTP_SERVICE_UNAVAILABLE: parseErrorMessageAndSetCode( httpMethod.getResponseBodyAsString(), ResultCode.SPECIFIC_SERVICE_UNAVAILABLE @@ -341,36 +282,6 @@ public class RemoteOperationResult implements Serializable { } } - /** - * Parse the error message included in the body response, if any, and set the specific result - * code - * @param httpMethod HTTP/DAV method already executed which response body will be parsed to get - * the specific error message - * @param resultCode specific result code - * @throws IOException - */ - private void parseErrorMessageAndSetCode(HttpMethod httpMethod, ResultCode resultCode) - throws IOException { - - String bodyResponse = httpMethod.getResponseBodyAsString(); - - if (bodyResponse != null && bodyResponse.length() > 0) { - InputStream is = new ByteArrayInputStream(bodyResponse.getBytes()); - ErrorMessageParser xmlParser = new ErrorMessageParser(); - try { - String errorMessage = xmlParser.parseXMLResponse(is); - if (errorMessage != "" && errorMessage != null) { - mCode = resultCode; - mHttpPhrase = errorMessage; - } - } catch (Exception e) { - Log_OC.w(TAG, "Error reading exception from server: " + e.getMessage()); - // mCode stays as set in this(success, httpCode, headers) - } - } - } - - /** * Parse the error message included in the body response, if any, and set the specific result * code @@ -403,8 +314,6 @@ public class RemoteOperationResult implements Serializable { * To be used when the result needs to be interpreted from HTTP response elements that could come from * different requests (WARNING: black magic, try to avoid). * - * If all the fields come from the same HTTP/DAV response, {@link #RemoteOperationResult(boolean, HttpMethod)} - * should be used instead. * * Determines a {@link ResultCode} depending on the HTTP code and HTTP response headers received. * @@ -445,25 +354,25 @@ public class RemoteOperationResult implements Serializable { if (httpCode > 0) { switch (httpCode) { - case HttpStatus.SC_UNAUTHORIZED: // 401 + case HttpConstants.HTTP_UNAUTHORIZED: // 401 mCode = ResultCode.UNAUTHORIZED; break; - case HttpStatus.SC_FORBIDDEN: // 403 + case HttpConstants.HTTP_FORBIDDEN: // 403 mCode = ResultCode.FORBIDDEN; break; - case HttpStatus.SC_NOT_FOUND: // 404 + case HttpConstants.HTTP_NOT_FOUND: // 404 mCode = ResultCode.FILE_NOT_FOUND; break; - case HttpStatus.SC_CONFLICT: // 409 + case HttpConstants.HTTP_CONFLICT: // 409 mCode = ResultCode.CONFLICT; break; - case HttpStatus.SC_INTERNAL_SERVER_ERROR: // 500 + case HttpConstants.HTTP_INTERNAL_SERVER_ERROR: // 500 mCode = ResultCode.INSTANCE_NOT_CONFIGURED; // assuming too much... break; - case HttpStatus.SC_SERVICE_UNAVAILABLE: // 503 + case HttpConstants.HTTP_SERVICE_UNAVAILABLE: // 503 mCode = ResultCode.SERVICE_UNAVAILABLE; break; - case HttpStatus.SC_INSUFFICIENT_STORAGE: // 507 + case HttpConstants.HTTP_INSUFFICIENT_STORAGE: // 507 mCode = ResultCode.QUOTA_EXCEEDED; // surprise! break; default: @@ -547,9 +456,6 @@ public class RemoteOperationResult implements Serializable { } else if (mException instanceof SocketTimeoutException) { return "Socket timeout exception"; - } else if (mException instanceof ConnectTimeoutException) { - return "Connect timeout exception"; - } else if (mException instanceof MalformedURLException) { return "Malformed URL exception"; @@ -628,7 +534,7 @@ public class RemoteOperationResult implements Serializable { } public boolean isServerFail() { - return (mHttpCode >= HttpStatus.SC_INTERNAL_SERVER_ERROR); + return (mHttpCode >= HttpConstants.HTTP_INTERNAL_SERVER_ERROR); } public boolean isException() { diff --git a/src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java b/src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java index 6a4d5a2f..719a25d1 100644 --- a/src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java +++ b/src/com/owncloud/android/lib/resources/status/GetRemoteStatusOperation.java @@ -117,7 +117,7 @@ public class GetRemoteStatusOperation extends RemoteOperation { // get = new GetMethod(redirectedLocation); // status = client.executeRequest(get, TRY_CONNECTION_TIMEOUT, TRY_CONNECTION_TIMEOUT); // mLatestResult = new RemoteOperationResult( -// (status == HttpStatus.SC_OK), +// (status == HttpConstants.HTTP_OK), // get // ); // redirectedLocation = mLatestResult.getRedirectedLocation(); diff --git a/src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java b/src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java index 2231ac14..1d72b7cb 100644 --- a/src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java +++ b/src/com/owncloud/android/lib/resources/users/GetRemoteUserAvatarOperation.java @@ -26,6 +26,7 @@ package com.owncloud.android.lib.resources.users; import com.owncloud.android.lib.common.OwnCloudClient; +import com.owncloud.android.lib.common.http.HttpConstants; import com.owncloud.android.lib.common.http.HttpUtils; import com.owncloud.android.lib.common.http.methods.nonwebdav.GetMethod; import com.owncloud.android.lib.common.network.WebdavUtils; @@ -33,7 +34,6 @@ import com.owncloud.android.lib.common.operations.RemoteOperation; import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.common.utils.Log_OC; -import org.apache.commons.httpclient.HttpStatus; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; @@ -182,7 +182,7 @@ public class GetRemoteUserAvatarOperation extends RemoteOperation { } private boolean isSuccess(int status) { - return (status == HttpStatus.SC_OK); + return (status == HttpConstants.HTTP_OK); } public static class ResultData { diff --git a/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java b/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java index 9be2fab8..1612873c 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java +++ b/test_client/src/com/owncloud/android/lib/test_project/SelfSignedConfidentSslSocketFactory.java @@ -41,12 +41,6 @@ import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import javax.net.ssl.X509TrustManager; -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.params.HttpConnectionParams; -import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; - -import com.owncloud.android.lib.common.network.AdvancedSslSocketFactory; - /** * SelfSignedConfidentSslSocketFactory allows to create SSL {@link Socket}s diff --git a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java index 46beb44e..2a4333ed 100644 --- a/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java +++ b/test_client/src/com/owncloud/android/lib/test_project/TestActivity.java @@ -30,8 +30,8 @@ import java.io.IOException; import java.io.InputStream; import java.security.GeneralSecurityException; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.app.Activity; import android.content.Context; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java index 4c9e0d97..9c6bf379 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/CopyFileTest.java @@ -42,9 +42,9 @@ import com.owncloud.android.lib.test_project.TestActivity; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + + import java.io.File; import java.security.GeneralSecurityException; @@ -373,7 +373,7 @@ public class CopyFileTest extends ActivityInstrumentationTestCase2 false ); result = copyOperation.execute(mClient); - assertTrue(result.getHttpCode() == HttpStatus.SC_CONFLICT); + assertTrue(result.getHttpCode() == HttpConstants.HTTP_CONFLICT); // target location (renaming) has invalid characters copyOperation = new CopyRemoteFileOperation( diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetCapabilitiesTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetCapabilitiesTest.java index bbdd37d0..fa950575 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetCapabilitiesTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetCapabilitiesTest.java @@ -29,8 +29,8 @@ import java.security.GeneralSecurityException; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.content.Context; import android.net.Uri; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetShareesTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetShareesTest.java index e9d25fd2..9055c162 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetShareesTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetShareesTest.java @@ -29,9 +29,9 @@ import java.security.GeneralSecurityException; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + + import org.json.JSONException; import org.json.JSONObject; @@ -184,11 +184,11 @@ public class GetShareesTest extends RemoteTest { // search for sharees including wrong page values getShareesOperation = new GetRemoteShareesOperation("a", 0, 50); result = getShareesOperation.execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); + assertTrue(!result.isSuccess() && result.getHttpCode() == HttpConstants.HTTP_BAD_REQUEST); getShareesOperation = new GetRemoteShareesOperation("a", 1, 0); result = getShareesOperation.execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); + assertTrue(!result.isSuccess() && result.getHttpCode() == HttpConstants.HTTP_BAD_REQUEST); } /** @@ -237,11 +237,11 @@ public class GetShareesTest extends RemoteTest { // search for sharees including wrong page values getShareesOperation = new GetRemoteShareesOperation("@", 0, 50); result = getShareesOperation.execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); + assertTrue(!result.isSuccess() && result.getHttpCode() == HttpConstants.HTTP_BAD_REQUEST); getShareesOperation = new GetRemoteShareesOperation("@", 1, 0); result = getShareesOperation.execute(mClient); - assertTrue(!result.isSuccess() && result.getHttpCode() == HttpStatus.SC_BAD_REQUEST); + assertTrue(!result.isSuccess() && result.getHttpCode() == HttpConstants.HTTP_BAD_REQUEST); } @Override diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetUserAvatarTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetUserAvatarTest.java index fc61ed31..46dfe8a8 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetUserAvatarTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/GetUserAvatarTest.java @@ -31,7 +31,7 @@ import com.owncloud.android.lib.common.operations.RemoteOperationResult; import com.owncloud.android.lib.resources.users.GetRemoteUserAvatarOperation.ResultData; import com.owncloud.android.lib.test_project.TestActivity; -import org.apache.commons.httpclient.HttpStatus; + /** * Class to test {@link GetRemoteUserAvatarOperation} @@ -81,7 +81,7 @@ public class GetUserAvatarTest extends RemoteTest { // request again, with the just received etag result = mActivity.getUserAvatar(AVATAR_DIMENSION, etag); assertFalse(result.isSuccess()); - assertTrue(result.getHttpCode() == HttpStatus.SC_NOT_MODIFIED); + assertTrue(result.getHttpCode() == HttpConstants.HTTP_NOT_MODIFIED); } */ diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/MoveFileTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/MoveFileTest.java index 9ac235ce..76215cb3 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/MoveFileTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/MoveFileTest.java @@ -29,9 +29,9 @@ import java.security.GeneralSecurityException; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.HttpStatus; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + + import com.owncloud.android.lib.common.OwnCloudClient; import com.owncloud.android.lib.common.OwnCloudClientFactory; @@ -373,7 +373,7 @@ public class MoveFileTest extends RemoteTest { false ); result = moveOperation.execute(mClient); - assertTrue(result.getHttpCode() == HttpStatus.SC_CONFLICT); + assertTrue(result.getHttpCode() == HttpConstants.HTTP_CONFLICT); // target location (renaming) has invalid characters moveOperation = new MoveRemoteFileOperation( diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java index 206fa0cc..9d7dca35 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/OwnCloudClientTest.java @@ -27,12 +27,12 @@ import java.io.IOException; import java.io.InputStream; import java.net.SocketTimeoutException; import java.security.GeneralSecurityException; -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.HttpException; -import org.apache.commons.httpclient.methods.HeadMethod; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; -import org.apache.commons.httpclient.HttpStatus; + + + + + + import org.apache.jackrabbit.webdav.DavConstants; import org.apache.jackrabbit.webdav.client.methods.PropFindMethod; @@ -314,7 +314,7 @@ public class OwnCloudClientTest extends AndroidTestCase { DavConstants.DEPTH_0); int status = client.executeMethod(propfind); assertEquals("WebDAV request did not work on WebDAV URI", - HttpStatus.SC_MULTI_STATUS, status); + HttpConstants.HTTP_MULTI_STATUS, status); } catch (IOException e) { Log.e(TAG, "Exception in PROPFIND method execution", e); diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/SimpleFactoryManagerTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/SimpleFactoryManagerTest.java index de70c7ed..408d200a 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/SimpleFactoryManagerTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/SimpleFactoryManagerTest.java @@ -25,8 +25,8 @@ package com.owncloud.android.lib.test_project.test; import java.security.GeneralSecurityException; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.net.Uri; import android.test.AndroidTestCase; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/SingleSessionManagerTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/SingleSessionManagerTest.java index bcc3fb82..8ad850e8 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/SingleSessionManagerTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/SingleSessionManagerTest.java @@ -25,8 +25,8 @@ package com.owncloud.android.lib.test_project.test; import java.security.GeneralSecurityException; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.net.Uri; import android.test.AndroidTestCase; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePrivateShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePrivateShareTest.java index 2f1155dd..0873ddbc 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePrivateShareTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePrivateShareTest.java @@ -31,8 +31,8 @@ import java.security.GeneralSecurityException; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.content.Context; import android.net.Uri; diff --git a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePublicShareTest.java b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePublicShareTest.java index a7792b84..3441b6ed 100644 --- a/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePublicShareTest.java +++ b/test_client/tests/src/com/owncloud/android/lib/test_project/test/UpdatePublicShareTest.java @@ -32,8 +32,8 @@ import java.util.Calendar; import junit.framework.AssertionFailedError; -import org.apache.commons.httpclient.protocol.Protocol; -import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; + + import android.content.Context; import android.net.Uri;