use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.
the class SigningCertificateLineageTest method testLineageFromAPKContainsExpectedSigners.
@Test
public void testLineageFromAPKContainsExpectedSigners() throws Exception {
SignerConfig firstSigner = getSignerConfigFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME);
SignerConfig secondSigner = getSignerConfigFromResources(SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
SignerConfig thirdSigner = getSignerConfigFromResources(THIRD_RSA_2048_SIGNER_RESOURCE_NAME);
List<SignerConfig> expectedSigners = Arrays.asList(firstSigner, secondSigner, thirdSigner);
DataSource apkDataSource = Resources.toDataSource(getClass(), "v1v2v3-with-rsa-2048-lineage-3-signers.apk");
SigningCertificateLineage lineageFromApk = SigningCertificateLineage.readFromApkDataSource(apkDataSource);
assertLineageContainsExpectedSigners(lineageFromApk, expectedSigners);
}
use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.
the class SigningCertificateLineageTest method createLineageWithSignersFromResources.
/**
* Creates a new {@code SigningCertificateLineage} with the specified signers from the
* resources. {@code mSigners} will be updated with the
* {@code SigningCertificateLineage.SignerConfig} for each signer added to the lineage.
*/
private SigningCertificateLineage createLineageWithSignersFromResources(String oldSignerResourceName, String newSignerResourceName) throws Exception {
SignerConfig oldSignerConfig = Resources.toLineageSignerConfig(getClass(), oldSignerResourceName);
mSigners.add(oldSignerConfig);
SignerConfig newSignerConfig = Resources.toLineageSignerConfig(getClass(), newSignerResourceName);
mSigners.add(newSignerConfig);
return new SigningCertificateLineage.Builder(oldSignerConfig, newSignerConfig).build();
}
use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.
the class SigningCertificateLineageTest method updateLineageWithSignerFromResources.
/**
* Updates the specified {@code SigningCertificateLineage} with the signer from the resources.
* Requires that the {@code mSigners} list contains the previous signers in the lineage since
* the most recent signer must be specified when adding a new signer to the lineage.
*/
private SigningCertificateLineage updateLineageWithSignerFromResources(SigningCertificateLineage lineage, String newSignerResourceName) throws Exception {
// To add a new Signer to an existing lineage the config of the last signer must be
// specified. If this class was used to create the lineage then the last signer should
// be in the mSigners list.
assertTrue("The mSigners list did not contain the expected signers to update the lineage", mSigners.size() >= 2);
SignerConfig oldSignerConfig = mSigners.get(mSigners.size() - 1);
SignerConfig newSignerConfig = Resources.toLineageSignerConfig(getClass(), newSignerResourceName);
mSigners.add(newSignerConfig);
return lineage.spawnDescendant(oldSignerConfig, newSignerConfig);
}
use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.
the class SigningCertificateLineageTest method testUpdatedCapabilitiesInLineageWrittenToFile.
@Test
public void testUpdatedCapabilitiesInLineageWrittenToFile() throws Exception {
SigningCertificateLineage lineage = createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
SignerConfig oldSignerConfig = mSigners.get(0);
List<Boolean> expectedCapabilityValues = Arrays.asList(false, false, false, false, false);
SignerCapabilities newCapabilities = buildSignerCapabilities(expectedCapabilityValues);
lineage.updateSignerCapabilities(oldSignerConfig, newCapabilities);
File lineageFile = File.createTempFile(getClass().getSimpleName(), ".bin");
lineageFile.deleteOnExit();
lineage.writeToFile(lineageFile);
lineage = SigningCertificateLineage.readFromFile(lineageFile);
SignerCapabilities updatedCapabilities = lineage.getSignerCapabilities(oldSignerConfig);
assertExpectedCapabilityValues(updatedCapabilities, expectedCapabilityValues);
}
use of com.android.apksig.SigningCertificateLineage.SignerConfig in project apksig by venshine.
the class SigningCertificateLineageTest method testUpdatedCapabilitiesInLineage.
@Test
public void testUpdatedCapabilitiesInLineage() throws Exception {
SigningCertificateLineage lineage = createLineageWithSignersFromResources(FIRST_RSA_2048_SIGNER_RESOURCE_NAME, SECOND_RSA_2048_SIGNER_RESOURCE_NAME);
SignerConfig oldSignerConfig = mSigners.get(0);
List<Boolean> expectedCapabilityValues = Arrays.asList(false, false, false, false, false);
SignerCapabilities newCapabilities = buildSignerCapabilities(expectedCapabilityValues);
lineage.updateSignerCapabilities(oldSignerConfig, newCapabilities);
SignerCapabilities updatedCapabilities = lineage.getSignerCapabilities(oldSignerConfig);
assertExpectedCapabilityValues(updatedCapabilities, expectedCapabilityValues);
}
Aggregations