use of java.security.CodeSigner in project ignite by apache.
the class GridUriDeploymentJarVerifier method getCertificates.
/**
* Gets all JAR file entry certificates.
* Method scans entry for signers and than collects all their certificates.
*
* @param entry JAR file entry.
* @return Array of certificates which corresponds to the entry.
*/
private static Certificate[] getCertificates(JarEntry entry) {
Certificate[] certs = null;
CodeSigner[] signers = entry.getCodeSigners();
// Extract the certificates in each code signer's cert chain.
if (signers != null) {
List<Certificate> certChains = new ArrayList<>();
for (CodeSigner signer : signers) certChains.addAll(signer.getSignerCertPath().getCertificates());
// Convert into a Certificate[]
return certChains.toArray(new Certificate[certChains.size()]);
}
return certs;
}
use of java.security.CodeSigner in project robovm by robovm.
the class CodeSignerTest method testEqualsObject.
/**
* Test various assertions about equals()
*/
public final void testEqualsObject() {
CodeSigner one = new CodeSigner(cpath, ts);
CodeSigner two = new CodeSigner(cpath, ts);
CodeSigner three = new CodeSigner(cpath, null);
CertPath cpath2 = TestCertUtils.genCertPath(5, 3);
CodeSigner four = new CodeSigner(cpath2, null);
assertTrue(one.equals(one));
assertTrue(one.equals(two));
assertTrue(two.equals(one));
assertFalse(one.equals(three));
assertFalse(three.equals(one));
assertTrue(three.equals(three));
// different CertPaths
assertFalse(three.equals(four));
// special cases
assertFalse(one.equals(null));
assertFalse(one.equals(new Object()));
}
use of java.security.CodeSigner in project robovm by robovm.
the class CodeSignerTest method testCodeSigner_01.
/**
* timestamp can be null
*/
public final void testCodeSigner_01() {
try {
CodeSigner cs = new CodeSigner(cpath, null);
assertNotNull(cs);
} catch (Exception e) {
fail("Unexpected exception");
}
}
use of java.security.CodeSigner in project quasar by puniverse.
the class QuasarURLClassLoader method instrument.
private Resource instrument(final String className, final Resource res) {
final ClassLoader parent = this;
return new Resource() {
private byte[] instrumented;
@Override
public synchronized byte[] getBytes() throws IOException {
if (instrumented == null) {
final byte[] bytes;
ByteBuffer bb = res.getByteBuffer();
if (bb != null) {
final int size = bb.remaining();
bytes = new byte[size];
bb.get(bytes);
} else
bytes = res.getBytes();
try {
this.instrumented = instrumentor.instrumentClass(parent, className, bytes);
} catch (Exception ex) {
if (MethodDatabase.isProblematicClass(className))
instrumentor.log(LogLevel.INFO, "Skipping problematic class instrumentation %s - %s %s", className, ex, Arrays.toString(ex.getStackTrace()));
else
instrumentor.error("Unable to instrument " + className, ex);
instrumented = bytes;
}
}
return instrumented;
}
@Override
public ByteBuffer getByteBuffer() throws IOException {
return null;
}
@Override
public InputStream getInputStream() throws IOException {
throw new AssertionError();
}
@Override
public String getName() {
return res.getName();
}
@Override
public URL getURL() {
return res.getURL();
}
@Override
public URL getCodeSourceURL() {
return res.getCodeSourceURL();
}
@Override
public int getContentLength() throws IOException {
return res.getContentLength();
}
@Override
public Manifest getManifest() throws IOException {
return res.getManifest();
}
@Override
public Certificate[] getCertificates() {
return res.getCertificates();
}
@Override
public CodeSigner[] getCodeSigners() {
return res.getCodeSigners();
}
};
}
use of java.security.CodeSigner in project quasar by puniverse.
the class QuasarURLClassLoaderHelper method instrument.
private Resource instrument(final String className, final Resource res) {
return new Resource() {
private byte[] instrumented;
@Override
public synchronized byte[] getBytes() throws IOException {
if (instrumented == null) {
final byte[] bytes;
ByteBuffer bb = res.getByteBuffer();
if (bb != null) {
final int size = bb.remaining();
bytes = new byte[size];
bb.get(bytes);
} else
bytes = res.getBytes();
try {
this.instrumented = instrumentor.instrumentClass(cl, className, bytes);
} catch (Exception ex) {
if (MethodDatabase.isProblematicClass(className))
instrumentor.log(LogLevel.INFO, "Skipping problematic class instrumentation %s - %s %s", className, ex, Arrays.toString(ex.getStackTrace()));
else
instrumentor.error("Unable to instrument " + className, ex);
instrumented = bytes;
}
}
return instrumented;
}
@Override
public ByteBuffer getByteBuffer() throws IOException {
return null;
}
@Override
public InputStream getInputStream() throws IOException {
throw new AssertionError();
}
@Override
public String getName() {
return res.getName();
}
@Override
public URL getURL() {
return res.getURL();
}
@Override
public URL getCodeSourceURL() {
return res.getCodeSourceURL();
}
@Override
public int getContentLength() throws IOException {
return res.getContentLength();
}
@Override
public Manifest getManifest() throws IOException {
return res.getManifest();
}
@Override
public Certificate[] getCertificates() {
return res.getCertificates();
}
@Override
public CodeSigner[] getCodeSigners() {
return res.getCodeSigners();
}
};
}
Aggregations