Package com.atlassian.bamboo.grpc.util
Class GrpcCertificateUtils
java.lang.Object
com.atlassian.bamboo.grpc.util.GrpcCertificateUtils
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic String
decodePassword
(String encryptedValue) static io.grpc.ChannelCredentials
generateClientCredentials
(GrpcCertificateUtils.RootCa rootCa, String sharedHome, String localHome, String hostname) static KeyPair
static X509Certificate
generateLocalCert
(PrivateKey caKey, KeyPair localNodeKeyPair, X509Certificate rootCa, String hostname) static X509Certificate
generateRootCa
(KeyPair keyPair) static io.grpc.ServerCredentials
generateServerCredentials
(GrpcCertificateUtils.RootCa rootCa, String sharedHome, String localHome, String hostname) static Pair<X509Certificate,
PrivateKey> getCertAndKeyFromPemFile
(File file, String keyPassword) static X509Certificate
getCertificateFromFile
(File file) static PrivateKey
getKeyFromFile
(File file) static GrpcCertificateUtils.RootCa
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 Details
-
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
- Throws:
IOException
-
toInputStream
public static InputStream toInputStream(X509Certificate certificate) throws CertificateEncodingException, IOException -
toInputStream
public static InputStream toInputStream(PrivateKey privateKey) throws CertificateEncodingException, IOException -
saveKeyToFile
- Throws:
IOException
-
getKeyFromFile
public static PrivateKey getKeyFromFile(File file) throws IOException, NoSuchAlgorithmException, InvalidKeySpecException, CertificateException, org.bouncycastle.operator.OperatorCreationException, org.bouncycastle.pkcs.PKCSException - Throws:
IOException
NoSuchAlgorithmException
InvalidKeySpecException
CertificateException
org.bouncycastle.operator.OperatorCreationException
org.bouncycastle.pkcs.PKCSException
-
getCertificateFromFile
public static X509Certificate getCertificateFromFile(File file) throws IOException, CertificateException, org.bouncycastle.operator.OperatorCreationException, org.bouncycastle.pkcs.PKCSException - Throws:
IOException
CertificateException
org.bouncycastle.operator.OperatorCreationException
org.bouncycastle.pkcs.PKCSException
-
getCertAndKeyFromPemFile
public static Pair<X509Certificate,PrivateKey> getCertAndKeyFromPemFile(File file, String keyPassword) throws IOException, CertificateException, org.bouncycastle.pkcs.PKCSException, org.bouncycastle.operator.OperatorCreationException - Throws:
IOException
CertificateException
org.bouncycastle.pkcs.PKCSException
org.bouncycastle.operator.OperatorCreationException
-
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
-
decodePassword
-
regenerateCaIfNeeded
public static GrpcCertificateUtils.RootCa 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(GrpcCertificateUtils.RootCa rootCa, 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(GrpcCertificateUtils.RootCa rootCa, String sharedHome, String localHome, String hostname) throws IOException, CertificateException, NoSuchAlgorithmException, org.bouncycastle.operator.OperatorCreationException, InvalidKeySpecException - Throws:
IOException
CertificateException
NoSuchAlgorithmException
org.bouncycastle.operator.OperatorCreationException
InvalidKeySpecException
-