Package org.apache.solr.util
Class CryptoKeys
- java.lang.Object
- 
- org.apache.solr.util.CryptoKeys
 
- 
 public final class CryptoKeys extends Object A utility class with helpers for various signature and certificate tasks
- 
- 
Nested Class SummaryNested Classes Modifier and Type Class Description static classCryptoKeys.RSAKeyPair
 - 
Constructor SummaryConstructors Constructor Description CryptoKeys(Map<String,byte[]> trustedKeys)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static 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.Stringverify(String sig, InputStream is)Stringverify(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)
 
- 
- 
- 
Method Detail- 
verifypublic String verify(String sig, ByteBuffer data) Try with all signatures and return the name of the signature that matched
 - 
verifypublic String verify(String sig, InputStream is) 
 - 
getX509PublicKeypublic static PublicKey getX509PublicKey(byte[] buf) throws InvalidKeySpecException Create PublicKey from a .DER file- Throws:
- InvalidKeySpecException
 
 - 
verifypublic 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 this
- sig- the signature
- data- The data tha is signed
- Throws:
- InvalidKeyException
- SignatureException
 
 - 
verifypublic static boolean verify(PublicKey publicKey, byte[] sig, InputStream is) throws InvalidKeyException, SignatureException, IOException 
 - 
decryptRSApublic static byte[] decryptRSA(byte[] buffer, PublicKey pubKey) throws InvalidKeyException, BadPaddingException, IllegalBlockSizeException
 - 
verifySha256public static boolean verifySha256(byte[] data, byte[] sig, PublicKey key) throws SignatureException, InvalidKeyException
 - 
parseX509Certspublic static Collection<X509Certificate> parseX509Certs(InputStream certsStream) 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
 
 
- 
 
-