|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.i2p.crypto.KeyStoreUtil
public class KeyStoreUtil
Keystore utilities, consolidated from various places.
Field Summary | |
---|---|
static String |
DEFAULT_KEYSTORE_PASSWORD
|
Constructor Summary | |
---|---|
KeyStoreUtil()
|
Method Summary | |
---|---|
static boolean |
addCert(File file,
String alias,
KeyStore ks)
Load an X509 Cert from a file and add it to the trusted set of certificates in the key store |
static int |
addCerts(File dir,
KeyStore ks)
Load all X509 Certs from a directory and add them to the trusted set of certificates in the key store |
static int |
countCerts(KeyStore ks)
Count all X509 Certs in a key store |
static boolean |
createKeys(File ks,
String alias,
String cname,
String ou,
String keyPW)
Create a keypair and store it in the keystore at ks, creating it if necessary. |
static boolean |
createKeys(File ks,
String ksPW,
String alias,
String cname,
String ou,
int validDays,
String keyAlg,
int keySize,
String keyPW)
Create a keypair and store it in the keystore at ks, creating it if necessary. |
static KeyStore |
createKeyStore(File ksFile,
String password)
Create a new KeyStore object, and load it from ksFile if it is non-null and it exists. |
static boolean |
exportCert(File ks,
String ksPW,
String alias,
File certFile)
Pull the cert back OUT of the keystore and save it in Base64-encoded X.509 format so the clients can get to it. |
static Certificate |
getCert(File ks,
String ksPW,
String alias)
Get a cert out of a keystore |
static PrivateKey |
getPrivateKey(File ks,
String ksPW,
String alias,
String keyPW)
Get a private key out of a keystore |
static KeyStore |
loadSystemKeyStore()
Loads certs from location of javax.net.ssl.keyStore property, else from $JAVA_HOME/lib/security/jssacacerts, else from $JAVA_HOME/lib/security/cacerts. |
static void |
main(String[] args)
|
static String |
randomString()
48 char b32 string (30 bytes of entropy) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_KEYSTORE_PASSWORD
Constructor Detail |
---|
public KeyStoreUtil()
Method Detail |
---|
public static KeyStore createKeyStore(File ksFile, String password) throws GeneralSecurityException, IOException
ksFile
- may be nullpassword
- may be null
GeneralSecurityException
IOException
public static KeyStore loadSystemKeyStore()
public static int countCerts(KeyStore ks)
public static int addCerts(File dir, KeyStore ks)
public static boolean addCert(File file, String alias, KeyStore ks)
public static String randomString()
public static boolean createKeys(File ks, String alias, String cname, String ou, String keyPW)
ks
- path to the keystorealias
- the name of the keycname
- e.g. randomstuff.console.i2p.netou
- e.g. consolekeyPW
- the key password, must be at least 6 characters
public static boolean createKeys(File ks, String ksPW, String alias, String cname, String ou, int validDays, String keyAlg, int keySize, String keyPW)
ks
- path to the keystoreksPW
- the keystore passwordalias
- the name of the keycname
- e.g. randomstuff.console.i2p.netou
- e.g. consolevalidDays
- e.g. 3652 (10 years)keyAlg
- e.g. DSA , RSA, ECkeySize
- e.g. 1024keyPW
- the key password, must be at least 6 characters
public static PrivateKey getPrivateKey(File ks, String ksPW, String alias, String keyPW) throws GeneralSecurityException, IOException
ks
- path to the keystoreksPW
- the keystore password, may be nullalias
- the name of the keykeyPW
- the key password, must be at least 6 characters
GeneralSecurityException
IOException
public static Certificate getCert(File ks, String ksPW, String alias) throws GeneralSecurityException, IOException
ks
- path to the keystoreksPW
- the keystore password, may be nullalias
- the name of the key
GeneralSecurityException
IOException
public static boolean exportCert(File ks, String ksPW, String alias, File certFile)
ks
- path to the keystoreksPW
- the keystore password, may be nullalias
- the name of the keycertFile
- output
public static void main(String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |