use of java.security.CodeSigner in project jdk8u_jdk by JetBrains.
the class SignatureFileVerifier method getSigners.
/**
* Given the PKCS7 block and SignerInfo[], create an array of
* CodeSigner objects. We do this only *once* for a given
* signature block file.
*/
private CodeSigner[] getSigners(SignerInfo[] infos, PKCS7 block) throws IOException, NoSuchAlgorithmException, SignatureException, CertificateException {
ArrayList<CodeSigner> signers = null;
for (int i = 0; i < infos.length; i++) {
SignerInfo info = infos[i];
ArrayList<X509Certificate> chain = info.getCertificateChain(block);
CertPath certChain = certificateFactory.generateCertPath(chain);
if (signers == null) {
signers = new ArrayList<>();
}
// Append the new code signer
signers.add(new CodeSigner(certChain, info.getTimestamp()));
if (debug != null) {
debug.println("Signature Block Certificate: " + chain.get(0));
}
}
if (signers != null) {
return signers.toArray(new CodeSigner[signers.size()]);
} else {
return null;
}
}
use of java.security.CodeSigner in project jboss-modules by jboss-modules.
the class JarFileResourceLoader method createCodeSource.
// this MUST only be called after the input stream is fully read (see MODULES-201)
private CodeSource createCodeSource(final JarEntry entry) {
final CodeSigner[] entryCodeSigners = entry.getCodeSigners();
final CodeSigners codeSigners = entryCodeSigners == null || entryCodeSigners.length == 0 ? EMPTY_CODE_SIGNERS : new CodeSigners(entryCodeSigners);
CodeSource codeSource = codeSources.get(codeSigners);
if (codeSource == null) {
codeSources.put(codeSigners, codeSource = new CodeSource(rootUrl, entryCodeSigners));
}
return codeSource;
}
use of java.security.CodeSigner in project btrace by btraceio.
the class FileClient method loadWithSecurity.
private byte[] loadWithSecurity(String path) throws IOException {
URL scriptUrl = URLClassLoader.getSystemResource(path);
if (scriptUrl.getProtocol().equals("jar")) {
String jarPath = scriptUrl.getPath().substring(5, scriptUrl.getPath().indexOf("!"));
JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"));
Enumeration<JarEntry> ens = jar.entries();
while (ens.hasMoreElements()) {
JarEntry en = ens.nextElement();
if (!en.isDirectory()) {
if (en.toString().equals(path)) {
byte[] data = readAll(jar.getInputStream(en), en.getSize());
CodeSigner[] signers = en.getCodeSigners();
canLoadPack = signers != null && signers.length != 0;
return data;
}
}
}
}
return null;
}
use of java.security.CodeSigner in project j2objc by google.
the class CodeSignerTest method testHashCode.
/**
* Tests CodeSigner.hashCode()
*/
public void testHashCode() {
CodeSigner cs1 = new CodeSigner(cpath, ts);
CodeSigner cs2 = new CodeSigner(cpath, ts);
CodeSigner cs3 = new CodeSigner(cpath, null);
assertTrue(cs1.hashCode() == cs2.hashCode());
assertTrue(cs2.hashCode() != cs3.hashCode());
}
use of java.security.CodeSigner in project j2objc by google.
the class CodeSignerTest method testToString.
/**
* Tests CodeSigner.toString()
*/
public void testToString() {
assertTrue(new CodeSigner(cpath, null).toString().contains(""));
assertTrue(new CodeSigner(cpath, ts).toString().contains(""));
assertTrue(new CodeSigner(cpath, null).toString().contains("Signer"));
assertTrue(new CodeSigner(cpath, ts).toString().contains(ts.toString()));
}
Aggregations