mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Clean-up at NetworkUtils.java
This commit is contained in:
parent
93e08bc215
commit
fcf3bd2769
@ -57,6 +57,12 @@ public class NetworkUtils {
|
||||
|
||||
/** Default timeout for establishing a connection */
|
||||
public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
|
||||
|
||||
/** Standard name for protocol TLS version 1.2 in Java Secure Socket Extension (JSSE) API */
|
||||
public static final String PROTOCOL_TLSv1_2 = "TLSv1.2";
|
||||
|
||||
/** 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;
|
||||
@ -72,7 +78,9 @@ public class NetworkUtils {
|
||||
* Registers or unregisters the proper components for advanced SSL handling.
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void registerAdvancedSslContext(boolean register, Context context) throws GeneralSecurityException, IOException {
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void registerAdvancedSslContext(boolean register, Context context)
|
||||
throws GeneralSecurityException, IOException {
|
||||
Protocol pr = null;
|
||||
try {
|
||||
pr = Protocol.getProtocol("https");
|
||||
@ -136,9 +144,11 @@ public class NetworkUtils {
|
||||
* @throws KeyStoreException When the KeyStore instance could not be created.
|
||||
* @throws IOException When an existing local trust store could not be loaded.
|
||||
* @throws NoSuchAlgorithmException When the existing local trust store was saved with an unsupported algorithm.
|
||||
* @throws CertificateException When an exception occurred while loading the certificates from the local trust store.
|
||||
* @throws CertificateException When an exception occurred while loading the certificates from the local
|
||||
* trust store.
|
||||
*/
|
||||
private static KeyStore getKnownServersStore(Context context) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
|
||||
private static KeyStore getKnownServersStore(Context context)
|
||||
throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
|
||||
if (mKnownServersStore == null) {
|
||||
//mKnownServersStore = KeyStore.getInstance("BKS");
|
||||
mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||
@ -152,15 +162,17 @@ public class NetworkUtils {
|
||||
in.close();
|
||||
}
|
||||
} else {
|
||||
mKnownServersStore.load(null, LOCAL_TRUSTSTORE_PASSWORD.toCharArray()); // necessary to initialize an empty KeyStore instance
|
||||
// next is necessary to initialize an empty KeyStore instance
|
||||
mKnownServersStore.load(null, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
|
||||
}
|
||||
}
|
||||
return mKnownServersStore;
|
||||
}
|
||||
|
||||
|
||||
public static void addCertToKnownServersStore(Certificate cert, Context context) throws KeyStoreException, NoSuchAlgorithmException,
|
||||
CertificateException, IOException {
|
||||
public static void addCertToKnownServersStore(Certificate cert, Context context)
|
||||
throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
|
||||
|
||||
KeyStore knownServers = getKnownServersStore(context);
|
||||
knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert);
|
||||
FileOutputStream fos = null;
|
||||
@ -182,7 +194,8 @@ public class NetworkUtils {
|
||||
return mConnManager;
|
||||
}
|
||||
|
||||
public static boolean isCertInKnownServersStore(Certificate cert, Context context) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
|
||||
public static boolean isCertInKnownServersStore(Certificate cert, Context context)
|
||||
throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
|
||||
|
||||
KeyStore knownServers = getKnownServersStore(context);
|
||||
Log_OC.d(TAG, "Certificate - HashCode: " + cert.hashCode() + " "
|
||||
|
Loading…
x
Reference in New Issue
Block a user