com.wrq.vhi.sconfig
Interface IAADSConnection


public interface IAADSConnection

Interface class for connecting to a VHI AADS and for managing certificates. Use the ServerConfig.newAADSConnection() methods to create instances of this interface.


Method Summary
 boolean compareCertificate(SCCertificate scc, java.lang.String fingerprint)
          Calculate a fingerprint for a certificate and compare it to a fingerprint string.
 void connect()
          Make a connection to an AADS server for the potential purpose of obtaining a list of servers and/or domains.
 boolean deleteCertificate(java.lang.String AADSName)
          Remove a certificate from our local keystore map.
 void disconnect()
          disconnect from the AADS server, if we are connected.
 java.lang.String getAADSName()
          Get the name of the AADS for this instance.
 SCCertificate getCertificate(java.lang.String AADSName)
          Get a certificate from our local keystore map.
 SCCertificate getCertificateFromAADS(java.lang.String AADSName)
          Obtain a current certificate directly from an AADS.
 void loadKeystore(java.lang.String keystoreFile)
          Read our AADS keystore map from a local disk file.
 void saveKeystore(java.lang.String keystoreFile)
          Write our AADS keystore map to a local disk file.
 void storeCertificate(SCCertificate scc)
          Add an AADS certificate to our local keystore map.
 

Method Detail

getCertificateFromAADS

SCCertificate getCertificateFromAADS(java.lang.String AADSName)
                                     throws SCException
Obtain a current certificate directly from an AADS. For optimal security, the following is recommended: Do not use this method to obtain fresh certificates from AADS's each time the maintenance API is used. This method is intended to be invoked once for each new AADS installation and used to build a local keystore map. Once the keystore map is built, it should be saved to a local disk file and reused. After a keystore map file is established, it should be loaded from disk when an instance of this object is constructed or by calling the loadKeystore() method. The keystore map is a static member of the AADSConnection class and only needs to be loaded once in order for all instances to access it.

Parameters:
AADSName - Name of AADS.
Returns:
Certificate container object.
Throws:
SCException - if there is a failure getting the certificate from the AADS.

compareCertificate

boolean compareCertificate(SCCertificate scc,
                           java.lang.String fingerprint)
Calculate a fingerprint for a certificate and compare it to a fingerprint string. An algorithm is applied to the certificate data to generate a fingerprint string of the same form as displayed in VHI setup and various VHI components when registering with an AADS. This string is then compared with a reference fingerprint to see if the strings match.

Parameters:
scc - Reference to a certificate.
fingerprint - Reference to a fingerprint string of the form: C4:9C:C0:B5:8B:A4:B7:84:FC:4F:EB:79:72:5B:03:99:C9:E0:D9:D1
Returns:
flag indicating that calculated fingerprint string matches the string provided.
Throws:
java.lang.IllegalArgumentException - is thrown if arguments are not valid.

storeCertificate

void storeCertificate(SCCertificate scc)
Add an AADS certificate to our local keystore map. Note: Adding a certificate to the local keystore map does not automatically write those changes to a local keystore file on disk. This method is used to build a keystore map, using the return values from the getCertificateFromAADS() method. Once certificates have been acquired for all of the AADS servers of interest, the keystore map can be saved to a local disk file.

Parameters:
scc - Reference to the certificate to be stored.

getCertificate

SCCertificate getCertificate(java.lang.String AADSName)
Get a certificate from our local keystore map. This method is used to obtain a certificate from our local keystore map. This map will have been populated either by loading a keystore map file from disk, or by calling the storeCertificate() method. This method is used internally to obtain certificates for authentication.

Parameters:
AADSName - Name of the AADS server for which the certificate is to be obtained.
Returns:
Reference to an SCCertificate container, or null if the there is no certificate for the named AADS in the local keystore.

deleteCertificate

boolean deleteCertificate(java.lang.String AADSName)
Remove a certificate from our local keystore map. Note: Removing a certificate from the local keystore map does not automatically write changes to a local keystore file on disk.

Parameters:
AADSName - Name of the AADS server for which the certificate is to be removed.
Returns:
Flag indicating that the certificate was found and removed from the local keystore.

loadKeystore

void loadKeystore(java.lang.String keystoreFile)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException,
                         java.io.FileNotFoundException
Read our AADS keystore map from a local disk file. The keystore map is a file containing zero or more AADS certificates.

Parameters:
keystoreFile - Name of the local disk file from which the keystore information is to be read.
Throws:
java.io.IOException - if there is an error opening or reading the file.
java.io.FileNotFoundException - if there is an error opening the keystore file.
java.lang.ClassNotFoundException - if the keystore file contents are not recognized to be valid.

saveKeystore

void saveKeystore(java.lang.String keystoreFile)
                  throws java.io.IOException
Write our AADS keystore map to a local disk file.

Parameters:
keystoreFile - Name of the local disk file to which the keystore information is to be written.
Throws:
java.io.IOException - if there is an error opening or writing the file.

connect

void connect()
             throws SCException
Make a connection to an AADS server for the potential purpose of obtaining a list of servers and/or domains. If this instance is already connected to an AADS server, the current session is disconnected first.

Throws:
SCException - is thrown if the certificate for the specified AADS is not present, or there is an error connecting to the AADS server.

disconnect

void disconnect()
disconnect from the AADS server, if we are connected.


getAADSName

java.lang.String getAADSName()
Get the name of the AADS for this instance.

Returns:
Name of the AADS to which this instance is assigned.