@Test(expected = IllegalArgumentException.class) public void testConsolidatedLineageWithDisjointLineagesFail() throws Exception { List<SigningCertificateLineage> lineages = new ArrayList<>(); lineages.add(createLineageWithSignersFromResources(FIRST_RSA_1024_SIGNER_RESOURCE_NAME, SECOND_RSA_1024_SIGNER_RESOURCE_NAME)); lineages.add(createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME)); SigningCertificateLineage.consolidateLineages(lineages); }
public static SigningCertificateLineage consolidateLineages( List<SigningCertificateLineage> lineages) { if (lineages == null || lineages.isEmpty()) { return null; } int largestIndex = 0; int maxSize = 0; for (int i = 0; i < lineages.size(); i++) { int curSize = lineages.get(i).size(); if (curSize > maxSize) { largestIndex = i; maxSize = curSize; } } List<SigningCertificateNode> largestList = lineages.get(largestIndex).mSigningLineage; for (int i = 0; i < lineages.size(); i++) { if (i == largestIndex) { continue; } List<SigningCertificateNode> underTest = lineages.get(i).mSigningLineage; if (!underTest.equals(largestList.subList(0, underTest.size()))) { throw new IllegalArgumentException("Inconsistent SigningCertificateLineages. " + "Not all lineages are subsets of each other."); } } return lineages.get(largestIndex); }
SigningCertificateLineage { public static SigningCertificateLineage consolidateLineages( List<SigningCertificateLineage> lineages) { if (lineages == null || lineages.isEmpty()) { return null; } int largestIndex = 0; int maxSize = 0; for (int i = 0; i < lineages.size(); i++) { int curSize = lineages.get(i).size(); if (curSize > maxSize) { largestIndex = i; maxSize = curSize; } } List<SigningCertificateNode> largestList = lineages.get(largestIndex).mSigningLineage; for (int i = 0; i < lineages.size(); i++) { if (i == largestIndex) { continue; } List<SigningCertificateNode> underTest = lineages.get(i).mSigningLineage; if (!underTest.equals(largestList.subList(0, underTest.size()))) { throw new IllegalArgumentException("Inconsistent SigningCertificateLineages. " + "Not all lineages are subsets of each other."); } } return lineages.get(largestIndex); } }
SigningCertificateLineage { public static SigningCertificateLineage consolidateLineages( List<SigningCertificateLineage> lineages) { if (lineages == null || lineages.isEmpty()) { return null; } int largestIndex = 0; int maxSize = 0; for (int i = 0; i < lineages.size(); i++) { int curSize = lineages.get(i).size(); if (curSize > maxSize) { largestIndex = i; maxSize = curSize; } } List<SigningCertificateNode> largestList = lineages.get(largestIndex).mSigningLineage; for (int i = 0; i < lineages.size(); i++) { if (i == largestIndex) { continue; } List<SigningCertificateNode> underTest = lineages.get(i).mSigningLineage; if (!underTest.equals(largestList.subList(0, underTest.size()))) { throw new IllegalArgumentException("Inconsistent SigningCertificateLineages. " + "Not all lineages are subsets of each other."); } } return lineages.get(largestIndex); } private  SigningCertificateLineage(int minSdkVersion, List<SigningCertificateNode> list); }
SigningCertificateLineage { public static SigningCertificateLineage consolidateLineages( List<SigningCertificateLineage> lineages) { if (lineages == null || lineages.isEmpty()) { return null; } int largestIndex = 0; int maxSize = 0; for (int i = 0; i < lineages.size(); i++) { int curSize = lineages.get(i).size(); if (curSize > maxSize) { largestIndex = i; maxSize = curSize; } } List<SigningCertificateNode> largestList = lineages.get(largestIndex).mSigningLineage; for (int i = 0; i < lineages.size(); i++) { if (i == largestIndex) { continue; } List<SigningCertificateNode> underTest = lineages.get(i).mSigningLineage; if (!underTest.equals(largestList.subList(0, underTest.size()))) { throw new IllegalArgumentException("Inconsistent SigningCertificateLineages. " + "Not all lineages are subsets of each other."); } } return lineages.get(largestIndex); } 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 static SigningCertificateLineage consolidateLineages( List<SigningCertificateLineage> lineages) { if (lineages == null || lineages.isEmpty()) { return null; } int largestIndex = 0; int maxSize = 0; for (int i = 0; i < lineages.size(); i++) { int curSize = lineages.get(i).size(); if (curSize > maxSize) { largestIndex = i; maxSize = curSize; } } List<SigningCertificateNode> largestList = lineages.get(largestIndex).mSigningLineage; for (int i = 0; i < lineages.size(); i++) { if (i == largestIndex) { continue; } List<SigningCertificateNode> underTest = lineages.get(i).mSigningLineage; if (!underTest.equals(largestList.subList(0, underTest.size()))) { throw new IllegalArgumentException("Inconsistent SigningCertificateLineages. " + "Not all lineages are subsets of each other."); } } return lineages.get(largestIndex); } 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; }