Class JSSSocketFactory
- java.lang.Object
-
- netscape.ldap.factory.JSSSocketFactory
-
- All Implemented Interfaces:
java.io.Serializable,LDAPSocketFactory,LDAPTLSSocketFactory,org.mozilla.jss.ssl.SSLCertificateApprovalCallback
public class JSSSocketFactory extends java.lang.Object implements java.io.Serializable, LDAPTLSSocketFactory, org.mozilla.jss.ssl.SSLCertificateApprovalCallback
Creates an SSL socket connection to a server, using the Netscape/Mozilla JSS package. This class implements theLDAPSocketFactoryinterface.By default, the factory uses "secmod.db", "key*.db" and "cert*.db" databases in the current directory. If you need to override this default setting, then you should use the constructor
JSSSocketFactory(certdbDir).- Version:
- 1.1
- See Also:
LDAPSocketFactory,LDAPConnection(netscape.ldap.LDAPSocketFactory), Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JSSSocketFactory()Constructs a newJSSSocketFactory, initializing the JSS security system if it has not already been initialized.JSSSocketFactory(java.lang.String certdbDir)Constructs a newJSSSocketFactory, initializing the JSS security system if it has not already been initialized.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapprove(org.mozilla.jss.crypto.X509Certificate serverCert, org.mozilla.jss.ssl.SSLCertificateApprovalCallback.ValidityStatus status)The default implementation of the SSLCertificateApprovalCallback interface.static voidinitialize(java.lang.String certdbDir)Initialize the JSS security subsystem.java.net.SocketmakeSocket(java.lang.String host, int port)Creates an SSL socketjava.net.SocketmakeSocket(java.net.Socket s)Creates an SSL socket layered over an existing socket.
-
-
-
Constructor Detail
-
JSSSocketFactory
public JSSSocketFactory() throws LDAPExceptionConstructs a newJSSSocketFactory, initializing the JSS security system if it has not already been initialized.The current directory is assumed to be the certificate database directory.
- Throws:
LDAPException- on initialization error- See Also:
JSSSocketFactory(java.lang.String)
-
JSSSocketFactory
public JSSSocketFactory(java.lang.String certdbDir) throws LDAPExceptionConstructs a newJSSSocketFactory, initializing the JSS security system if it has not already been initialized.- Parameters:
certdbDir- The full path, relative or absolute, of the certificate database directory- Throws:
LDAPException- on initialization error
-
-
Method Detail
-
initialize
public static void initialize(java.lang.String certdbDir) throws LDAPExceptionInitialize the JSS security subsystem.This method allows you to override the current directory as the default certificate database directory. The directory is expected to contain
secmod.db,key*.dbandcert*.dbfiles as the security module database, key database and certificate database respectively.The method may be called only once, before the first instance of
JSSSocketFactoryis created. When creating the first instance, the constructor will automatically initialize the JSS security subsystem using the defaults, unless it is already initialized.- Parameters:
certdbDir- The full path, relative or absolute, of the certificate database directory.- Throws:
LDAPException- on initialization error- See Also:
JSSSocketFactory(String)
-
makeSocket
public java.net.Socket makeSocket(java.lang.String host, int port) throws LDAPExceptionCreates an SSL socket- Specified by:
makeSocketin interfaceLDAPSocketFactory- Parameters:
host- Host name or IP address of SSL serverport- Port numbers of SSL server- Returns:
- A socket for an encrypted session
- Throws:
LDAPException- on error creating socket- See Also:
LDAPSSLSocketFactory.makeSocket(java.lang.String,int)
-
approve
public boolean approve(org.mozilla.jss.crypto.X509Certificate serverCert, org.mozilla.jss.ssl.SSLCertificateApprovalCallback.ValidityStatus status)The default implementation of the SSLCertificateApprovalCallback interface.This default implementation always returns true. If you need to verify the server certificate validity, then you should override this method.
- Specified by:
approvein interfaceorg.mozilla.jss.ssl.SSLCertificateApprovalCallback- Parameters:
serverCert- X509 Certificatestatus- The validity of the server certificate- Returns:
true, by default we trust the certificate
-
makeSocket
public java.net.Socket makeSocket(java.net.Socket s) throws LDAPExceptionCreates an SSL socket layered over an existing socket. Used for the startTLS implementation (RFC2830).- Specified by:
makeSocketin interfaceLDAPTLSSocketFactory- Parameters:
s- An existing non-SSL socket- Returns:
- A SSL socket layered over the input socket
- Throws:
LDAPException- on error creating socket- Since:
- LDAPJDK 4.17
- See Also:
LDAPConnection.startTLS()
-
-