diff options
| author | Dmitry Dementyev <dementyev@google.com> | 2018-03-22 17:55:27 -0700 |
|---|---|---|
| committer | Dmitry Dementyev <dementyev@google.com> | 2018-03-22 19:43:17 -0700 |
| commit | 3b67e06de57549cfa9b4db88b13d105126d7ad94 (patch) | |
| tree | df68ee62b61749f74c0550cd07070811ce26a70f /core/java/android | |
| parent | 3a31f6c5ccd9c8e490ecb475262059e7f52717b3 (diff) | |
Prepare KeyChainSnapshot to removing deprecated getTrustedHardwarePublicKey method.
Add null checks to getTrustedHardwareCertPath.
Remove unused and outdated PersistentKeyChainSnapshot class.
Use CertPath instead of public keys in KeySyncTaskTest.
Bug: 75952916
Test: adb shell am instrument \
-w -e package com.android.server.locksettings.recoverablekeystore \
com.android.frameworks.servicestests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Ifabe7d5fa250069ebe0885ce52ec29b01294f63a
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/security/keystore/recovery/KeyChainSnapshot.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/core/java/android/security/keystore/recovery/KeyChainSnapshot.java b/core/java/android/security/keystore/recovery/KeyChainSnapshot.java index 00f54e16863d..69b9123c3c3e 100644 --- a/core/java/android/security/keystore/recovery/KeyChainSnapshot.java +++ b/core/java/android/security/keystore/recovery/KeyChainSnapshot.java @@ -127,18 +127,13 @@ public final class KeyChainSnapshot implements Parcelable { /** * CertPath containing the public key used to encrypt {@code encryptedRecoveryKeyBlob}. */ - // TODO: Change to @NonNull - public CertPath getTrustedHardwareCertPath() { - if (mCertPath == null) { - return null; - } else { - try { - return mCertPath.getCertPath(); - } catch (CertificateException e) { - // Rethrow an unchecked exception as it should not happen. If such an issue exists, - // an exception should have been thrown during service initialization. - throw new BadParcelableException(e); - } + public @NonNull CertPath getTrustedHardwareCertPath() { + try { + return mCertPath.getCertPath(); + } catch (CertificateException e) { + // Rethrow an unchecked exception as it should not happen. If such an issue exists, + // an exception should have been thrown during service initialization. + throw new BadParcelableException(e); } } @@ -248,13 +243,9 @@ public final class KeyChainSnapshot implements Parcelable { * @throws CertificateException if the given certificate path cannot be encoded properly * @return This builder. */ - public Builder setTrustedHardwareCertPath(CertPath certPath) throws CertificateException { - // TODO: Make it NonNull when the caller code is all updated - if (certPath == null) { - mInstance.mCertPath = null; - } else { - mInstance.mCertPath = RecoveryCertPath.createRecoveryCertPath(certPath); - } + public Builder setTrustedHardwareCertPath(@NonNull CertPath certPath) + throws CertificateException { + mInstance.mCertPath = RecoveryCertPath.createRecoveryCertPath(certPath); return this; } @@ -282,7 +273,7 @@ public final class KeyChainSnapshot implements Parcelable { } /** - * Sets recovery key blob + * Sets recovery key blob. * * @param encryptedRecoveryKeyBlob The recovery key blob. * @return This builder. @@ -297,7 +288,7 @@ public final class KeyChainSnapshot implements Parcelable { * Creates a new {@link KeyChainSnapshot} instance. * * @return new instance - * @throws NullPointerException if some required fields were not set. + * @throws NullPointerException if some of the required fields were not set. */ @NonNull public KeyChainSnapshot build() { Preconditions.checkCollectionElementsNotNull(mInstance.mKeyChainProtectionParams, @@ -306,6 +297,7 @@ public final class KeyChainSnapshot implements Parcelable { "entryRecoveryData"); Preconditions.checkNotNull(mInstance.mEncryptedRecoveryKeyBlob); Preconditions.checkNotNull(mInstance.mServerParams); + Preconditions.checkNotNull(mInstance.mCertPath); return mInstance; } } |
