org.mailster.crypto
Class MailsterKeyStoreFactory
java.lang.Object
org.mailster.crypto.MailsterKeyStoreFactory
public class MailsterKeyStoreFactory
- extends java.lang.Object
---
Mailster (C) 2007-2009 De Oliveira Edouard
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 675 Mass
Ave, Cambridge, MA 02139, USA.
See Mailster
Web Site
---
MailsterKeyStoreFactory.java - The factory that generates the certificates
used in Mailster.
- Version:
- $Revision: 1.16 $, $Date: 2009/03/24 00:56:42 $
- Author:
- Edouard De Oliveira
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LOG
private static final org.slf4j.Logger LOG
- Log object for this class.
KEYSTORE_FILENAME
private static final java.lang.String KEYSTORE_FILENAME
- See Also:
- Constant Field Values
SSL_CERT_FILENAME
private static final java.lang.String SSL_CERT_FILENAME
- See Also:
- Constant Field Values
CLI_KEYSTORE_FILENAME
private static final java.lang.String CLI_KEYSTORE_FILENAME
- See Also:
- Constant Field Values
KEYSTORE_FULL_PATH
private static final java.lang.String KEYSTORE_FULL_PATH
SSL_CERT_FULL_PATH
private static final java.lang.String SSL_CERT_FULL_PATH
CLI_KEYSTORE_FULL_PATH
private static final java.lang.String CLI_KEYSTORE_FULL_PATH
DN_ORGANISATION
private static final java.lang.String DN_ORGANISATION
- See Also:
- Constant Field Values
DN_ORGANISATION_UNIT
private static final java.lang.String DN_ORGANISATION_UNIT
- See Also:
- Constant Field Values
DN_COUNTRY
private static final java.lang.String DN_COUNTRY
- See Also:
- Constant Field Values
DN_ROOT
private static final java.lang.String DN_ROOT
- See Also:
- Constant Field Values
ROOT_CA_ALIAS
private static final java.lang.String ROOT_CA_ALIAS
- See Also:
- Constant Field Values
INTERMEDIATE_CA_ALIAS
private static final java.lang.String INTERMEDIATE_CA_ALIAS
- See Also:
- Constant Field Values
MAILSTER_SSL_ALIAS
private static final java.lang.String MAILSTER_SSL_ALIAS
- See Also:
- Constant Field Values
DUMMY_SSL_CLIENT_ALIAS
private static final java.lang.String DUMMY_SSL_CLIENT_ALIAS
- See Also:
- Constant Field Values
TED_CERT_ALIAS
public static final java.lang.String TED_CERT_ALIAS
- See Also:
- Constant Field Values
KEYSTORE_PASSWORD
protected static final char[] KEYSTORE_PASSWORD
_instance
private static MailsterKeyStoreFactory _instance
store
private java.security.KeyStore store
params
private java.security.cert.PKIXParameters params
storeLoaded
private boolean storeLoaded
permissionDenied
private boolean permissionDenied
errorMessage
private java.lang.String errorMessage
sessionAnchors
private java.util.Set<java.security.cert.TrustAnchor> sessionAnchors
MailsterKeyStoreFactory
private MailsterKeyStoreFactory()
getInstance
public static MailsterKeyStoreFactory getInstance()
isStoreLoaded
public boolean isStoreLoaded()
isPermissionDenied
public boolean isPermissionDenied()
getFullPath
private static java.lang.String getFullPath(java.lang.String fileName)
regenerate
public void regenerate()
throws java.lang.Exception
- Throws:
java.lang.Exception
main
public static void main(java.lang.String[] args)
checkPermission
public boolean checkPermission()
throws java.security.NoSuchAlgorithmException,
java.security.NoSuchProviderException,
javax.crypto.NoSuchPaddingException,
java.security.InvalidAlgorithmParameterException,
java.security.spec.InvalidKeySpecException
- Throws:
java.security.NoSuchAlgorithmException
java.security.NoSuchProviderException
javax.crypto.NoSuchPaddingException
java.security.InvalidAlgorithmParameterException
java.security.spec.InvalidKeySpecException
setErrorMessage
private void setErrorMessage(java.lang.String msg)
loadDefaultKeyStore
private java.security.KeyStore loadDefaultKeyStore()
getErrorMessage
public java.lang.String getErrorMessage()
getCryptoStrength
private int getCryptoStrength()
createDefaultKeyStore
private java.security.KeyStore createDefaultKeyStore()
generateSSLServerCertificate
private void generateSSLServerCertificate(java.security.KeyStore store,
javax.security.auth.x500.X500PrivateCredential rootCredential)
throws java.lang.Exception
- Throws:
java.lang.Exception
generateDummySSLClientCertificate
private void generateDummySSLClientCertificate(java.security.KeyStore ks)
throws java.lang.Exception
- Throws:
java.lang.Exception
importJDKTrustedCertificates
private void importJDKTrustedCertificates(java.security.KeyStore ks)
getPKIXParameters
protected java.security.cert.PKIXParameters getPKIXParameters(char[] password)
throws java.security.KeyStoreException,
java.security.InvalidAlgorithmParameterException
- Throws:
java.security.KeyStoreException
java.security.InvalidAlgorithmParameterException
getRootCertificate
public java.security.cert.X509Certificate getRootCertificate()
throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
getCertificateChain
public java.security.cert.Certificate[] getCertificateChain(java.lang.String alias)
throws java.security.KeyStoreException
- Throws:
java.security.KeyStoreException
getKeyStore
public java.security.KeyStore getKeyStore()
getKeyStoreOutputStream
protected java.io.OutputStream getKeyStoreOutputStream()
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
loadKeyStore
public static java.security.KeyStore loadKeyStore(java.lang.String storeType,
java.lang.String storePath,
char[] pwd)