com.google.api.client.auth.security
Class PrivateKeys

java.lang.Object
  extended by com.google.api.client.auth.security.PrivateKeys

public class PrivateKeys
extends Object

Utility methods for private keys.

Since:
1.7
Author:
Yaniv Inbar

Method Summary
static PrivateKey loadFromKeyStore(InputStream keyStream, String storePass, String alias, String keyPass)
          Retrieves the private key from the specified key store stream using default key store.
static PrivateKey loadFromKeyStore(KeyStore keyStore, InputStream keyStream, String storePass, String alias, String keyPass)
          Retrieves the private key from the specified key store stream and specified key store.
static PrivateKey loadFromP12File(File p12File, String storePass, String alias, String keyPass)
          Reads a PKCS#12 format private key from a given file.
static PrivateKey loadFromPk8File(File file)
          Reads a PKCS#8 format private key from a given file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadFromKeyStore

public static PrivateKey loadFromKeyStore(InputStream keyStream,
                                          String storePass,
                                          String alias,
                                          String keyPass)
                                   throws IOException,
                                          GeneralSecurityException
Retrieves the private key from the specified key store stream using default key store.

Parameters:
keyStream - input stream to the key store file (closed at the end of this method in a finally block)
storePass - password protecting the key store file
alias - alias under which the private key is stored
keyPass - password protecting the private key
Returns:
the private key from the specified key store
Throws:
IOException
GeneralSecurityException

loadFromKeyStore

public static PrivateKey loadFromKeyStore(KeyStore keyStore,
                                          InputStream keyStream,
                                          String storePass,
                                          String alias,
                                          String keyPass)
                                   throws IOException,
                                          GeneralSecurityException
Retrieves the private key from the specified key store stream and specified key store.

Parameters:
keyStore - key store
keyStream - input stream to the key store file (closed at the end of this method in a finally block)
storePass - password protecting the key store file
alias - alias under which the private key is stored
keyPass - password protecting the private key
Returns:
the private key from the specified key store
Throws:
IOException
GeneralSecurityException

loadFromPk8File

public static PrivateKey loadFromPk8File(File file)
                                  throws IOException,
                                         GeneralSecurityException
Reads a PKCS#8 format private key from a given file.

Throws:
IOException
GeneralSecurityException

loadFromP12File

public static PrivateKey loadFromP12File(File p12File,
                                         String storePass,
                                         String alias,
                                         String keyPass)
                                  throws GeneralSecurityException,
                                         IOException
Reads a PKCS#12 format private key from a given file.

Parameters:
p12File - p12 file
storePass - password protecting the key store file
alias - alias under which the private key is stored
keyPass - password protecting the private key
Returns:
loaded private key
Throws:
GeneralSecurityException
IOException


Copyright © 2011-2012 Google. All Rights Reserved.