OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.net; | 5 package org.chromium.net; |
6 | 6 |
7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
9 import android.content.Context; | 9 import android.content.Context; |
10 import android.content.Intent; | 10 import android.content.Intent; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 @JNINamespace("net") | 48 @JNINamespace("net") |
49 public class X509Util { | 49 public class X509Util { |
50 | 50 |
51 private static final String TAG = "X509Util"; | 51 private static final String TAG = "X509Util"; |
52 | 52 |
53 private static final class TrustStorageListener extends BroadcastReceiver { | 53 private static final class TrustStorageListener extends BroadcastReceiver { |
54 @Override public void onReceive(Context context, Intent intent) { | 54 @Override public void onReceive(Context context, Intent intent) { |
55 if (intent.getAction().equals(KeyChain.ACTION_STORAGE_CHANGED)) { | 55 if (intent.getAction().equals(KeyChain.ACTION_STORAGE_CHANGED)) { |
56 try { | 56 try { |
57 reloadDefaultTrustManager(); | 57 reloadDefaultTrustManager(); |
58 } | 58 } catch (CertificateException e) { |
59 catch (CertificateException e) { | |
60 Log.e(TAG, "Unable to reload the default TrustManager", e); | 59 Log.e(TAG, "Unable to reload the default TrustManager", e); |
61 } | 60 } catch (KeyStoreException e) { |
62 catch (KeyStoreException e) { | |
63 Log.e(TAG, "Unable to reload the default TrustManager", e); | 61 Log.e(TAG, "Unable to reload the default TrustManager", e); |
64 } | 62 } catch (NoSuchAlgorithmException e) { |
65 catch (NoSuchAlgorithmException e) { | |
66 Log.e(TAG, "Unable to reload the default TrustManager", e); | 63 Log.e(TAG, "Unable to reload the default TrustManager", e); |
67 } | 64 } |
68 } | 65 } |
69 } | 66 } |
70 } | 67 } |
71 | 68 |
72 /** | 69 /** |
73 * Interface that wraps one of X509TrustManager or | 70 * Interface that wraps one of X509TrustManager or |
74 * X509TrustManagerExtensions to support platforms before the latter was | 71 * X509TrustManagerExtensions to support platforms before the latter was |
75 * added. | 72 * added. |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 continue; | 367 continue; |
371 | 368 |
372 if (!(anchor instanceof X509Certificate)) { | 369 if (!(anchor instanceof X509Certificate)) { |
373 // This should never happen. | 370 // This should never happen. |
374 String className = anchor.getClass().getName(); | 371 String className = anchor.getClass().getName(); |
375 Log.e(TAG, "Anchor " + alias + " not an X509Certificate: " + cla
ssName); | 372 Log.e(TAG, "Anchor " + alias + " not an X509Certificate: " + cla
ssName); |
376 continue; | 373 continue; |
377 } | 374 } |
378 | 375 |
379 // If the subject and public key match, this is a system root. | 376 // If the subject and public key match, this is a system root. |
380 X509Certificate anchorX509 = (X509Certificate)anchor; | 377 X509Certificate anchorX509 = (X509Certificate) anchor; |
381 if (root.getSubjectX500Principal().equals(anchorX509.getSubjectX500P
rincipal()) && | 378 if (root.getSubjectX500Principal().equals(anchorX509.getSubjectX500P
rincipal()) && |
382 root.getPublicKey().equals(anchorX509.getPublicKey())) { | 379 root.getPublicKey().equals(anchorX509.getPublicKey())) { |
383 sSystemTrustAnchorCache.add(key); | 380 sSystemTrustAnchorCache.add(key); |
384 return true; | 381 return true; |
385 } | 382 } |
386 } | 383 } |
387 | 384 |
388 return false; | 385 return false; |
389 } | 386 } |
390 | 387 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 */ | 510 */ |
514 private static native void nativeRecordCertVerifyCapabilitiesHistogram( | 511 private static native void nativeRecordCertVerifyCapabilitiesHistogram( |
515 boolean foundSystemTrustRoots); | 512 boolean foundSystemTrustRoots); |
516 | 513 |
517 /** | 514 /** |
518 * Returns the application context. | 515 * Returns the application context. |
519 */ | 516 */ |
520 private static native Context nativeGetApplicationContext(); | 517 private static native Context nativeGetApplicationContext(); |
521 | 518 |
522 } | 519 } |
OLD | NEW |