Package com.atlassian.bamboo.grpc.util
Class GrpcCertificateUtils
- java.lang.Object
-
- com.atlassian.bamboo.grpc.util.GrpcCertificateUtils
-
public class GrpcCertificateUtils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.grpc.ChannelCredentials
generateClientCredentials(String sharedHome, String localHome, String hostname)
static KeyPair
generateKeyPair()
static X509Certificate
generateLocalCert(PrivateKey caKey, KeyPair localNodeKeyPair, X509Certificate rootCa, String hostname)
static X509Certificate
generateRootCa(KeyPair keyPair)
static io.grpc.ServerCredentials
generateServerCredentials(String sharedHome, String localHome, String hostname)
static X509Certificate
getCertificateFromFile(File file)
static PrivateKey
getKeyFromFile(File file)
static void
regenerateCaIfNeeded(String sharedHome)
static void
saveCertificateToFile(X509Certificate certificate, File file)
static void
saveKeyToFile(PrivateKey privateKey, File file)
static InputStream
toInputStream(X509Certificate certificate)
static InputStream
toInputStream(PrivateKey privateKey)
-
-
-
Method Detail
-
generateKeyPair
public static KeyPair generateKeyPair()
-
generateRootCa
public static X509Certificate generateRootCa(KeyPair keyPair) throws org.bouncycastle.operator.OperatorCreationException, NoSuchAlgorithmException, org.bouncycastle.cert.CertIOException, CertificateException
- Throws:
org.bouncycastle.operator.OperatorCreationException
NoSuchAlgorithmException
org.bouncycastle.cert.CertIOException
CertificateException
-
saveCertificateToFile
public static void saveCertificateToFile(X509Certificate certificate, File file) throws IOException
- Throws:
IOException
-
toInputStream
public static InputStream toInputStream(X509Certificate certificate) throws CertificateEncodingException, IOException
-
toInputStream
public static InputStream toInputStream(PrivateKey privateKey) throws CertificateEncodingException, IOException
-
saveKeyToFile
public static void saveKeyToFile(PrivateKey privateKey, File file) throws IOException
- Throws:
IOException
-
getKeyFromFile
public static PrivateKey getKeyFromFile(File file) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException
-
getCertificateFromFile
public static X509Certificate getCertificateFromFile(File file) throws IOException, CertificateException
- Throws:
IOException
CertificateException
-
generateLocalCert
public static X509Certificate generateLocalCert(PrivateKey caKey, KeyPair localNodeKeyPair, X509Certificate rootCa, String hostname) throws org.bouncycastle.operator.OperatorCreationException, NoSuchAlgorithmException, org.bouncycastle.cert.CertIOException, CertificateException
- Throws:
org.bouncycastle.operator.OperatorCreationException
NoSuchAlgorithmException
org.bouncycastle.cert.CertIOException
CertificateException
-
regenerateCaIfNeeded
public static void regenerateCaIfNeeded(String sharedHome) throws CertificateException, NoSuchAlgorithmException, IOException, org.bouncycastle.operator.OperatorCreationException, InterruptedException
- Throws:
CertificateException
NoSuchAlgorithmException
IOException
org.bouncycastle.operator.OperatorCreationException
InterruptedException
-
generateServerCredentials
public static io.grpc.ServerCredentials generateServerCredentials(String sharedHome, String localHome, String hostname) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, CertificateException, org.bouncycastle.operator.OperatorCreationException
- Throws:
IOException
NoSuchAlgorithmException
InvalidKeySpecException
CertificateException
org.bouncycastle.operator.OperatorCreationException
-
generateClientCredentials
public static io.grpc.ChannelCredentials generateClientCredentials(String sharedHome, String localHome, String hostname) throws IOException, CertificateException, NoSuchAlgorithmException, org.bouncycastle.operator.OperatorCreationException, InvalidKeySpecException
- Throws:
IOException
CertificateException
NoSuchAlgorithmException
org.bouncycastle.operator.OperatorCreationException
InvalidKeySpecException
-
-