@Test(expected = IllegalArgumentException.class) public void testSortedSignerConfigsWithUnknownSignerFails() throws Exception { SigningCertificateLineage lineage = createLineageWithSignersFromResources( FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME); DefaultApkSignerEngine.SignerConfig oldSigner = getApkSignerEngineSignerConfigFromResources( FIRST_RSA_2048_SIGNER_RESOURCE_NAME); DefaultApkSignerEngine.SignerConfig newSigner = getApkSignerEngineSignerConfigFromResources( SECOND_RSA_2048_SIGNER_RESOURCE_NAME); DefaultApkSignerEngine.SignerConfig unknownSigner = getApkSignerEngineSignerConfigFromResources(THIRD_RSA_2048_SIGNER_RESOURCE_NAME); List<DefaultApkSignerEngine.SignerConfig> signers = Arrays.asList(newSigner, oldSigner, unknownSigner); lineage.sortSignerConfigs(signers); }
public List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs( List<DefaultApkSignerEngine.SignerConfig> signerConfigs) { if (signerConfigs == null) { throw new NullPointerException("signerConfigs == null"); } List<DefaultApkSignerEngine.SignerConfig> sortedSignerConfigs = new ArrayList<>(signerConfigs.size()); for (int i = 0; i < mSigningLineage.size(); i++) { for (int j = 0; j < signerConfigs.size(); j++) { DefaultApkSignerEngine.SignerConfig config = signerConfigs.get(j); if (mSigningLineage.get(i).signingCert.equals(config.getCertificates().get(0))) { sortedSignerConfigs.add(config); break; } } } if (sortedSignerConfigs.size() != signerConfigs.size()) { throw new IllegalArgumentException("SignerConfigs supplied which are not present in the" + " SigningCertificateLineage"); } return sortedSignerConfigs; }
SigningCertificateLineage { public List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs( List<DefaultApkSignerEngine.SignerConfig> signerConfigs) { if (signerConfigs == null) { throw new NullPointerException("signerConfigs == null"); } List<DefaultApkSignerEngine.SignerConfig> sortedSignerConfigs = new ArrayList<>(signerConfigs.size()); for (int i = 0; i < mSigningLineage.size(); i++) { for (int j = 0; j < signerConfigs.size(); j++) { DefaultApkSignerEngine.SignerConfig config = signerConfigs.get(j); if (mSigningLineage.get(i).signingCert.equals(config.getCertificates().get(0))) { sortedSignerConfigs.add(config); break; } } } if (sortedSignerConfigs.size() != signerConfigs.size()) { throw new IllegalArgumentException("SignerConfigs supplied which are not present in the" + " SigningCertificateLineage"); } return sortedSignerConfigs; } }
SigningCertificateLineage { public List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs( List<DefaultApkSignerEngine.SignerConfig> signerConfigs) { if (signerConfigs == null) { throw new NullPointerException("signerConfigs == null"); } List<DefaultApkSignerEngine.SignerConfig> sortedSignerConfigs = new ArrayList<>(signerConfigs.size()); for (int i = 0; i < mSigningLineage.size(); i++) { for (int j = 0; j < signerConfigs.size(); j++) { DefaultApkSignerEngine.SignerConfig config = signerConfigs.get(j); if (mSigningLineage.get(i).signingCert.equals(config.getCertificates().get(0))) { sortedSignerConfigs.add(config); break; } } } if (sortedSignerConfigs.size() != signerConfigs.size()) { throw new IllegalArgumentException("SignerConfigs supplied which are not present in the" + " SigningCertificateLineage"); } return sortedSignerConfigs; } private  SigningCertificateLineage(int minSdkVersion, List<SigningCertificateNode> list); }
SigningCertificateLineage { public List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs( List<DefaultApkSignerEngine.SignerConfig> signerConfigs) { if (signerConfigs == null) { throw new NullPointerException("signerConfigs == null"); } List<DefaultApkSignerEngine.SignerConfig> sortedSignerConfigs = new ArrayList<>(signerConfigs.size()); for (int i = 0; i < mSigningLineage.size(); i++) { for (int j = 0; j < signerConfigs.size(); j++) { DefaultApkSignerEngine.SignerConfig config = signerConfigs.get(j); if (mSigningLineage.get(i).signingCert.equals(config.getCertificates().get(0))) { sortedSignerConfigs.add(config); break; } } } if (sortedSignerConfigs.size() != signerConfigs.size()) { throw new IllegalArgumentException("SignerConfigs supplied which are not present in the" + " SigningCertificateLineage"); } return sortedSignerConfigs; } private  SigningCertificateLineage(int minSdkVersion, List<SigningCertificateNode> list); static SigningCertificateLineage readFromFile(File file); static SigningCertificateLineage readFromDataSource(DataSource dataSource); static SigningCertificateLineage readFromV3AttributeValue(byte[] attrValue); static SigningCertificateLineage readFromApkFile(File apkFile); static SigningCertificateLineage readFromApkDataSource(DataSource apk); static SigningCertificateLineage readFromSignedData(ByteBuffer signedData); void writeToFile(File file); void writeToDataSink(DataSink dataSink); SigningCertificateLineage spawnDescendant(SignerConfig parent, SignerConfig child); SigningCertificateLineage spawnDescendant(
            SignerConfig parent, SignerConfig child, SignerCapabilities childCapabilities); int size(); byte[] generateV3SignerAttribute(); List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs(
            List<DefaultApkSignerEngine.SignerConfig> signerConfigs); SignerCapabilities getSignerCapabilities(SignerConfig config); SignerCapabilities getSignerCapabilities(X509Certificate cert); void updateSignerCapabilities(SignerConfig config, SignerCapabilities capabilities); List<X509Certificate> getCertificatesInLineage(); boolean isSignerInLineage(SignerConfig config); boolean isCertificateInLineage(X509Certificate cert); SigningCertificateLineage getSubLineage(X509Certificate x509Certificate); static SigningCertificateLineage consolidateLineages(
            List<SigningCertificateLineage> lineages); }
SigningCertificateLineage { public List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs( List<DefaultApkSignerEngine.SignerConfig> signerConfigs) { if (signerConfigs == null) { throw new NullPointerException("signerConfigs == null"); } List<DefaultApkSignerEngine.SignerConfig> sortedSignerConfigs = new ArrayList<>(signerConfigs.size()); for (int i = 0; i < mSigningLineage.size(); i++) { for (int j = 0; j < signerConfigs.size(); j++) { DefaultApkSignerEngine.SignerConfig config = signerConfigs.get(j); if (mSigningLineage.get(i).signingCert.equals(config.getCertificates().get(0))) { sortedSignerConfigs.add(config); break; } } } if (sortedSignerConfigs.size() != signerConfigs.size()) { throw new IllegalArgumentException("SignerConfigs supplied which are not present in the" + " SigningCertificateLineage"); } return sortedSignerConfigs; } private  SigningCertificateLineage(int minSdkVersion, List<SigningCertificateNode> list); static SigningCertificateLineage readFromFile(File file); static SigningCertificateLineage readFromDataSource(DataSource dataSource); static SigningCertificateLineage readFromV3AttributeValue(byte[] attrValue); static SigningCertificateLineage readFromApkFile(File apkFile); static SigningCertificateLineage readFromApkDataSource(DataSource apk); static SigningCertificateLineage readFromSignedData(ByteBuffer signedData); void writeToFile(File file); void writeToDataSink(DataSink dataSink); SigningCertificateLineage spawnDescendant(SignerConfig parent, SignerConfig child); SigningCertificateLineage spawnDescendant(
            SignerConfig parent, SignerConfig child, SignerCapabilities childCapabilities); int size(); byte[] generateV3SignerAttribute(); List<DefaultApkSignerEngine.SignerConfig> sortSignerConfigs(
            List<DefaultApkSignerEngine.SignerConfig> signerConfigs); SignerCapabilities getSignerCapabilities(SignerConfig config); SignerCapabilities getSignerCapabilities(X509Certificate cert); void updateSignerCapabilities(SignerConfig config, SignerCapabilities capabilities); List<X509Certificate> getCertificatesInLineage(); boolean isSignerInLineage(SignerConfig config); boolean isCertificateInLineage(X509Certificate cert); SigningCertificateLineage getSubLineage(X509Certificate x509Certificate); static SigningCertificateLineage consolidateLineages(
            List<SigningCertificateLineage> lineages); final static int MAGIC; }