try (FileInputStream fis = new FileInputStream(certsFile);
BufferedInputStream bis = new BufferedInputStream(fis)) {
ArrayList certs1 = new ArrayList();
ArrayList certs2 = new ArrayList();
// read the first cert
Certificate cert = cf.generateCertificate(bis);
certs1.add(cert);
certs2.add(cert);
// read the second cert
cert = cf.generateCertificate(bis);
certs2.add(cert);
URL location = certsFile.toURI().toURL();
CodeSource cs0 = new CodeSource(location, (Certificate[]) null);
CodeSource cs1 = new CodeSource(location,
(Certificate[]) certs1.toArray(new Certificate[certs1.size()]));
CodeSource cs2 = new CodeSource(location,
(Certificate[]) certs2.toArray(new Certificate[certs2.size()]));
if (!cs0.implies(cs1) || !cs1.implies(cs2)) { thrownew Exception("The implies method is not working correctly");
} if (cs0.equals(cs1) || cs1.equals(cs0)
|| cs2.equals(cs1) || cs1.equals(cs2)) { thrownew Exception("The equals method is not working correctly");
} if (verifySigner(cs0.getCodeSigners(), null)) { thrownew RuntimeException("CodeSource.getCodeSigners() should be null");
} if (!((verifySigner(cs1.getCodeSigners(), certs1))
&& (verifySigner(cs2.getCodeSigners(), certs2)))) { thrownew RuntimeException("Mismatched CodeSigners certificate");
}
}
}
privatestaticboolean verifySigner(CodeSigner[] css, List certs) { if (css == null || certs == null) { returnfalse;
} if (css.length < 1 || certs.size() < 1) { returnfalse;
} boolean result = true; for (CodeSigner cs : css) {
result &= cs.getSignerCertPath().getCertificates().equals(certs);
} return result;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.