use of com.biglybt.core.security.SEKeyDetails in project BiglyBT by BiglySoftware.
the class AEJarBuilder method buildFromResources2.
private static long buildFromResources2(OutputStream os, ClassLoader class_loader, String resource_prefix, String[] resource_names, String sign_alias) throws IOException {
if (sign_alias != null) {
ByteArrayOutputStream baos = new ByteArrayOutputStream(65536);
long tim = buildFromResourcesSupport(new JarOutputStream(baos), class_loader, resource_prefix, resource_names);
try {
// leave this check in here as we might as well check for the alias
SEKeyDetails kd = SESecurityManager.getKeyDetails(sign_alias);
if (kd == null) {
Logger.log(new LogAlert(LogAlert.UNREPEATABLE, LogAlert.AT_ERROR, "Certificate alias '" + sign_alias + "' not found, jar signing fails"));
throw (new Exception("Certificate alias '" + sign_alias + "' not found "));
}
// WUJarSigner signer = new WUJarSigner(sign_alias, (PrivateKey)kd.getKey(), kd.getCertificateChain());
AEJarSigner2 signer = new AEJarSigner2(sign_alias, SESecurityManager.getKeystoreName(), SESecurityManager.getKeystorePassword());
signer.signJarStream(new ByteArrayInputStream(baos.toByteArray()), os);
return (tim);
} catch (Throwable e) {
Debug.printStackTrace(e);
throw (new IOException(e.getMessage()));
}
} else {
JarOutputStream jos;
if (os instanceof JarOutputStream) {
jos = (JarOutputStream) os;
} else {
jos = new JarOutputStream(os);
}
return (buildFromResourcesSupport(jos, class_loader, resource_prefix, resource_names));
}
}
use of com.biglybt.core.security.SEKeyDetails in project BiglyBT by BiglySoftware.
the class SESecurityManagerImpl method getKeyDetails.
public SEKeyDetails getKeyDetails(String alias) throws Exception {
// Create the key manager factory used to extract the server key
KeyStore key_store = loadKeyStore();
final Key key = key_store.getKey(alias, SESecurityManager.SSL_PASSWORD.toCharArray());
if (key == null) {
return (null);
}
java.security.cert.Certificate[] chain = key_store.getCertificateChain(alias);
final X509Certificate[] res = new X509Certificate[chain.length];
for (int i = 0; i < chain.length; i++) {
if (!(chain[i] instanceof X509Certificate)) {
throw (new Exception("Certificate chain must be comprised of X509Certificate entries"));
}
res[i] = (X509Certificate) chain[i];
}
return (new SEKeyDetails() {
@Override
public Key getKey() {
return (key);
}
@Override
public X509Certificate[] getCertificateChain() {
return (res);
}
});
}
Aggregations