|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.appserv.management.client.TrustStoreTrustManager
public class TrustStoreTrustManager
This X509TrustManager implementation supports a trust-store file and allows adding new certificates to it. It is designed to allow a subclass to override a variety of protected methods including those of TrustManager:
For convenience, if setPrompt( true ) is called, then when a new Certificate is encountered, askShouldAddToTrustStore( c ) prompts the user via System.in as to whether to accept this new Certificate as trusted. Subclasses can of course override this behavior any any desired way.
Field Summary | |
---|---|
static String |
TRUSTSTORE_FILE_SPROP
Standard system property denoting the trust-store. |
static String |
TRUSTSTORE_PASSWORD_SPROP
Standard system property denoting the trust-store password. |
Constructor Summary | |
---|---|
TrustStoreTrustManager(File trustStoreFile,
char[] trustStorePassword)
calls this( trustStoreFile,"JKS", trustStorePassword ) |
|
TrustStoreTrustManager(File trustStoreFile,
String keyStoreType,
char[] trustStorePassword)
Create a new instance with the specified File and password The trustStoreFile must exist. |
Method Summary | |
---|---|
protected void |
addCertificateToTrustStore(Certificate c)
Add the Certificate to the trust-store, using the alias returned by getCertificateAlias( c ). |
protected void |
addCertificateToTrustStore(String alias,
Certificate c)
Add the Certificate with the specified alias to the trust-store. |
protected boolean |
askShouldAddToTrustStore(Certificate c)
Prompts via System.in to ask whether the Certificate should be added. |
protected void |
certificateNotInTrustStore(Certificate c)
The Certificate is not found in the trust-store. |
protected void |
checkCertificate(X509Certificate[] chain)
|
void |
checkClientTrusted(X509Certificate[] chain,
String authType)
|
void |
checkServerTrusted(X509Certificate[] chain,
String authType)
|
X509Certificate[] |
getAcceptedIssuers()
By default, no issuers are trusted. |
protected String |
getCertificateAlias(Certificate c)
Return an alias for a Certificate to be added to the TrustStore. |
static TrustStoreTrustManager |
getSystemInstance()
Create an instance using the system trust-store as returned by getSystemTrustStoreFile(). |
static File |
getSystemTrustStoreFile()
Use System.getProperty( "javax.net.ssl.trustStore" ) to find a trust-store. |
static char[] |
getSystemTrustStorePassword()
Use System.getProperty( "javax.net.ssl.trustStorePassword" ) to find the trust-store password. |
protected KeyStore |
getTrustStore()
Get the KeyStore containing the Certificates to be trusted. |
File |
getTrustStoreFile()
Return the trust-store that was initially passed in. |
protected char[] |
getTrustStorePassword()
Subclass may choose to override this method to get the password from any desired source. |
void |
setPrompt(boolean prompt)
If set to true, then when a new Certificate is encountered, the user will be prompted via System.in as to whether it should be trusted. |
protected boolean |
shouldAddToTrustStore(Certificate c)
Subclass may wish to override this routine and call defaultShouldAddToTrustStore( c ); |
String |
toString()
|
protected void |
writeStore()
Write the store to disk. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String TRUSTSTORE_FILE_SPROP
public static final String TRUSTSTORE_PASSWORD_SPROP
Constructor Detail |
---|
public TrustStoreTrustManager(File trustStoreFile, String keyStoreType, char[] trustStorePassword)
trustStoreFile
- (not required to exist)keyStoreType
- keystore (truststore) type, eg "JKS"trustStorePassword
- (may be null)public TrustStoreTrustManager(File trustStoreFile, char[] trustStorePassword)
Method Detail |
---|
public void setPrompt(boolean prompt)
prompt
- public static TrustStoreTrustManager getSystemInstance()
public static File getSystemTrustStoreFile()
public static char[] getSystemTrustStorePassword()
public final File getTrustStoreFile()
protected char[] getTrustStorePassword()
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException
checkClientTrusted
in interface X509TrustManager
CertificateException
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException
checkServerTrusted
in interface X509TrustManager
CertificateException
public X509Certificate[] getAcceptedIssuers()
getAcceptedIssuers
in interface X509TrustManager
protected boolean askShouldAddToTrustStore(Certificate c) throws IOException
c
-
IOException
protected boolean shouldAddToTrustStore(Certificate c) throws IOException
c
-
IOException
protected String getCertificateAlias(Certificate c)
c
-
protected void addCertificateToTrustStore(String alias, Certificate c) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
alias
- c
-
IOException
KeyStoreException
NoSuchAlgorithmException
CertificateException
protected void addCertificateToTrustStore(Certificate c) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
c
-
IOException
KeyStoreException
NoSuchAlgorithmException
CertificateException
protected void writeStore() throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
IOException
KeyStoreException
NoSuchAlgorithmException
CertificateException
protected void certificateNotInTrustStore(Certificate c) throws IOException, KeyStoreException, NoSuchAlgorithmException, CertificateException
c
-
IOException
KeyStoreException
NoSuchAlgorithmException
CertificateException
protected KeyStore getTrustStore() throws IOException, CertificateException, NoSuchAlgorithmException, KeyStoreException, FileNotFoundException
IOException
CertificateException
NoSuchAlgorithmException
KeyStoreException
FileNotFoundException
protected void checkCertificate(X509Certificate[] chain) throws RuntimeException, CertificateException
chain
-
RuntimeException
CertificateException
public String toString()
toString
in class Object
|
Java EE 5 SDK | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 2006 Sun Microsystems, Inc. All rights reserved.