|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcodec.pkcs.bin.ExtKeyTool
public class ExtKeyTool
Extension utility for use alongside Sun's keytool program. Performs useful functions not found in original.
| Nested Class Summary | |
|---|---|
private class |
ExtKeyTool.ByteContainer
Auto-enlarging container for bytes. |
protected class |
ExtKeyTool.ExtKeyToolException
Signals that an error was encounted while using ExtKeyTool functions. |
protected class |
ExtKeyTool.InvalidCertificateChainException
Signals that an error occurred while trying to constuct a certificate chain. |
| Field Summary | |
|---|---|
protected static boolean |
debug_
|
| Constructor Summary | |
|---|---|
ExtKeyTool()
|
|
| Method Summary | |
|---|---|
void |
exportKey(String provider,
PrintStream outStream,
InputStream keyStoreStream,
String storeType,
char[] keyStorePassword,
String keyAlias,
char[] keyPassword,
boolean rfc)
Retrieves a private key from a java keystore and writes it to an PrintStream |
ByteArrayOutputStream |
importKey(String provider,
String keyAlgorithm,
InputStream keyStream,
InputStream chainStream,
InputStream keyStoreInStream,
String storeType,
String keyAlias,
char[] keyStorePassword,
char[] keyPassword)
Given a java keystore, private key, and matching certificate chain; creates a new keystore containing the union of these objects |
protected String |
initProvider(Properties arguments)
Ensures that providers specified on the command line are in fact loaded into the current environment. |
protected boolean |
isMatchingKey(String algorithm,
PublicKey pubKey,
PrivateKey privKey)
Boolean indication of whether a given private key and public key form a valid keypair. |
protected X509Certificate[] |
linkChain(String keyAlgorithm,
X509Certificate[] untestedCerts,
PrivateKey privKey)
Converts an array of certificates into an ordered chain. |
protected KeyStore |
loadKeyStore(String provider,
InputStream keyStoreStream,
String storeType,
char[] keyStorePassword)
Creates and initializes a java KeyStore |
protected static void |
log(String str)
|
static void |
main(String[] args)
|
private static Properties |
parseArguments(String[] args)
Tries to decipher command line arguments. |
private static void |
printUsage(PrintStream out)
|
protected PrivateKey |
readPrivateKey(String provider,
InputStream keyStream,
String algorithm)
Attempts to unmarshall a private key from a given stream. |
protected char[] |
resolveKeyPass(String keyPass,
char[] storePass)
Decides what password to use for storing/retrieving keys from the keystore. |
protected File |
resolveKeyStore(String keyStoreLocation)
Determines the location of the keystore to use when performing the action |
private void |
run(Properties arguments)
Based on on a set of properties, executes ExtKeyTool actions. |
protected void |
walkChain(X509Certificate[] chainSource,
ArrayList chainDest)
Given an ArrayList containing a base certificate and an array of unordered certificates, populates the ArrayList with an ordered certificate chain, based on subject and issuer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static boolean debug_
| Constructor Detail |
|---|
public ExtKeyTool()
| Method Detail |
|---|
protected static void log(String str)
protected KeyStore loadKeyStore(String provider,
InputStream keyStoreStream,
String storeType,
char[] keyStorePassword)
throws ExtKeyTool.ExtKeyToolException
KeyStore
provider - name of the jce provider to use in loading the keystorekeyStoreStream - stream used to retrieve the keystorestoreType - the type of the keystorekeyStorePassword - password used to verify the integrity of the keystore
ExtKeyTool.ExtKeyToolException - if a problem is encountered loading the keystore
public void exportKey(String provider,
PrintStream outStream,
InputStream keyStoreStream,
String storeType,
char[] keyStorePassword,
String keyAlias,
char[] keyPassword,
boolean rfc)
throws ExtKeyTool.ExtKeyToolException
PrintStream
provider - name of the jce provider to use in retrieving the keyoutStream - stream that should be used to output the retrieved keykeyStoreStream - stream used to retrieve the keystorestoreType - the type of the keystorekeyStorePassword - password used to verify the integrity of the keystorekeyAlias - the alias under which the key is storedkeyPassword - the password for recovering the keyrfc - boolean indicator of whether the key should be Base64 encoded
before being written to the stream
ExtKeyTool.ExtKeyToolException - if there a problem retrieving or writing the key
protected boolean isMatchingKey(String algorithm,
PublicKey pubKey,
PrivateKey privKey)
pubKey - the public keyprivKey - the private key
protected PrivateKey readPrivateKey(String provider,
InputStream keyStream,
String algorithm)
throws ExtKeyTool.ExtKeyToolException
keyStream - the InputStream suppying the keyalgorithm - the key algorithm
ExtKeyTool.ExtKeyToolException - if there a problem unmarshalling the key
protected X509Certificate[] linkChain(String keyAlgorithm,
X509Certificate[] untestedCerts,
PrivateKey privKey)
throws ExtKeyTool.InvalidCertificateChainException
untestedCerts - array of certificatesprivKey - the private key used to determine the first
cert in the chain
ExtKeyTool.InvalidCertificateChainException - thrown if a chain
cannot be constructed from the specified elements
protected void walkChain(X509Certificate[] chainSource,
ArrayList chainDest)
throws ExtKeyTool.InvalidCertificateChainException
chainSource - array of certificates to pull fromchainDest - ArrayList containing base certificate
ExtKeyTool.InvalidCertificateChainException - thrown
if a chain cannot be constructed from the specified elements
public ByteArrayOutputStream importKey(String provider,
String keyAlgorithm,
InputStream keyStream,
InputStream chainStream,
InputStream keyStoreInStream,
String storeType,
String keyAlias,
char[] keyStorePassword,
char[] keyPassword)
throws ExtKeyTool.ExtKeyToolException
provider - the name of the jce provider to usekeyAlgorithm - the algorithm of the key to be added, defaults to
RSA if nullkeyStream - strema used to retrieve the private key, can
contain a PEM encoded
or pkcs8 encoded keychainStream - stream used to retrieve certificates, can
contain a series of
PEM encoded certs or a pkcs7 chainkeyStoreInStream - stream used to retrieve the initial keystorestoreType - the type of the keystorekeyAlias - the alias under which the key/chain should be savedkeyStorePassword - password used to verify the integrity of the old
keystore and
save the new keystorekeyPassword - the password for saving the key
ExtKeyTool.ExtKeyToolException - if there a problem importing the key
private static Properties parseArguments(String[] args)
throws IllegalArgumentException
IllegalArgumentException - if arguments are not properly formattedprotected String initProvider(Properties arguments)
public static void main(String[] args)
private void run(Properties arguments)
throws ExtKeyTool.ExtKeyToolException
ExtKeyTool actions.
arguments - runtime parameters specified on the command line
ExtKeyTool.ExtKeyToolException
protected File resolveKeyStore(String keyStoreLocation)
throws ExtKeyTool.ExtKeyToolException,
FileNotFoundException
File representation of the selected keystore
ExtKeyTool.ExtKeyToolException
FileNotFoundException
protected char[] resolveKeyPass(String keyPass,
char[] storePass)
private static void printUsage(PrintStream out)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||