Package org.apache.solr.util
Class CryptoKeys
java.lang.Object
org.apache.solr.util.CryptoKeys
A utility class with helpers for various signature and certificate tasks
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decryptRSA(byte[] buffer, PublicKey pubKey) static PublicKeydeserializeX509PublicKey(String pubKey) static StringextractCertificateFromPem(String pemContents) Given a file, will try tostatic PublicKeygetX509PublicKey(byte[] buf) Create PublicKey from a .DER filestatic Collection<X509Certificate> parseX509Certs(InputStream certsStream) Tries for find X509 certificates in the input stream in DER or PEM format.verify(String sig, InputStream is) verify(String sig, ByteBuffer data) Try with all signatures and return the name of the signature that matchedstatic booleanverify(PublicKey publicKey, byte[] sig, InputStream is) static booleanverify(PublicKey publicKey, byte[] sig, ByteBuffer data) Verify the signature of a filestatic booleanverifySha256(byte[] data, byte[] sig, PublicKey key)
-
Constructor Details
-
CryptoKeys
- Throws:
Exception
-
-
Method Details
-
verify
Try with all signatures and return the name of the signature that matched -
verify
-
getX509PublicKey
Create PublicKey from a .DER file- Throws:
InvalidKeySpecException
-
verify
public static boolean verify(PublicKey publicKey, byte[] sig, ByteBuffer data) throws InvalidKeyException, SignatureException Verify the signature of a file- Parameters:
publicKey- the public key used to sign thissig- the signaturedata- The data tha is signed- Throws:
InvalidKeyExceptionSignatureException
-
verify
public static boolean verify(PublicKey publicKey, byte[] sig, InputStream is) throws InvalidKeyException, SignatureException, IOException -
deserializeX509PublicKey
-
decryptRSA
public static byte[] decryptRSA(byte[] buffer, PublicKey pubKey) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException -
verifySha256
public static boolean verifySha256(byte[] data, byte[] sig, PublicKey key) throws SignatureException, InvalidKeyException -
parseX509Certs
Tries for find X509 certificates in the input stream in DER or PEM format. Supports multiple certs in same stream if multiple PEM certs are concatenated.- Parameters:
certsStream- input stream with the contents of either PEM (plaintext) or DER (binary) certs- Returns:
- collection of found certificates, else throws exception
-
extractCertificateFromPem
Given a file, will try to- Parameters:
pemContents- the raw string content of the PEM file- Returns:
- the certificate content between BEGIN and END markers
-