/** * Return certificates for signed bundle, otherwise null. * * @return An array of certificates or null. */ public ArrayList getCertificateChains(boolean onlyTrusted) { if (checkCerts) { Certificate[] c = archive.getCertificates(); checkCerts = false; if (c != null) { ArrayList failed = new ArrayList(); untrustedCerts = Util.getCertificateChains(c, failed); if (!failed.isEmpty()) { // NYI, log Bundle archive has invalid certificates untrustedCerts = null; } } } ArrayList res = trustedCerts; if (!onlyTrusted && untrustedCerts != null) { if (res == null) { res = untrustedCerts; } else { res = new ArrayList(trustedCerts.size() + untrustedCerts.size()); res.addAll(trustedCerts); res.addAll(untrustedCerts); } } return res; }
/** Mark certificate chain as trusted. */ public void trustCertificateChain(List trustedChain) { if (trustedCerts == null) { trustedCerts = new ArrayList(untrustedCerts.size()); } trustedCerts.add(trustedChain); untrustedCerts.remove(trustedChain); if (untrustedCerts.isEmpty()) { untrustedCerts = null; } }