public class HttpDirectoryClient extends java.lang.Object implements LdapDirectory
HttpDirectoryClient class works with the
HttpDirectoryServlet class to send requests to an LDAP
Directory through an HTTP tunnel.
This class implements the LdapDirectory interface,
so you can use the HttpDirectoryClient class
wherever you would normally use LdapDirectory to communicate
with the Directory. The following code fragments show first how to
use the LdapDirectory class to connect to the Directory,
and then how to use an HTTP tunnel to the Directory.
Using LdapDirectory:
LdapDirectory dir = new JNDIDirectory("47.97.235.29", 309);
Using HttpDirectoryClient:
LdapDirectory dir = new HttpDirectoryClient("http://wothdmontg.entrust.com:80/servlet/mainDirectory", 0);
In this example, the Web server is on the wothdmontg.entrust.com
computer and the DirectoryServlet class resides in the server's
servlet folder. The Web server is configured so that the URL
refers to the DirectoryServlet servlet. The IP address and port
number of the Directory are specified in the servlet's parameters. Refer to
the Javadoc reference for
.
HttpDirectoryServlet
HttpDirectoryServlet| Modifier and Type | Field and Description |
|---|---|
protected java.util.Vector<java.lang.String> |
m_httpHeaders |
protected int |
m_port |
protected java.lang.String |
m_proxyIP |
protected int |
m_proxyPort |
protected java.net.URL |
m_url |
| Constructor and Description |
|---|
HttpDirectoryClient(HttpDirectoryClient httpDirectoryClient)
Copy constructor.
|
HttpDirectoryClient(java.lang.String urlString,
int port)
Create an HttpDirectoryClient.
|
HttpDirectoryClient(java.lang.String urlString,
int port,
boolean checkConnectivity)
Create an HttpDirectoryClient.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addHttpHeader(java.lang.String name,
java.lang.String value)
Adds additional HTTP header information.
|
byte[][] |
getAttr(java.lang.String dn,
java.lang.String attributeToFind)
Implements the
getAttr method of the LdapDirectory
interface. |
X509CRL[] |
getCRLs(java.lang.String distributionPoint,
boolean wantARL)
Implements the
getCRLs() method of the LdapDirectory
interface. |
boolean |
isAvailable()
Determines whether the remote servlet is available.
|
void |
setClientCredentials(java.security.cert.X509Certificate verificationCertificate,
java.security.cert.X509Certificate caCertificate,
java.security.PrivateKey signingKey)
This method does nothing.
|
void |
setWebProxy(java.lang.String ipAddress,
int port)
Sets the Web proxy.
|
protected java.net.URL m_url
protected int m_port
protected java.lang.String m_proxyIP
protected int m_proxyPort
protected java.util.Vector<java.lang.String> m_httpHeaders
public HttpDirectoryClient(java.lang.String urlString,
int port)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
urlString - the URL of the server hosting the servlet that will process the Directory
search requests.port - the port number to connect to on the server. This is ignored if urlString
specifies the port.java.net.MalformedURLException - if urlString is not a valid URL.java.net.UnknownHostException - if the host specified in urlString cannot be contacted.java.io.IOException - if there is an IO problem after connecting to the host.public HttpDirectoryClient(java.lang.String urlString,
int port,
boolean checkConnectivity)
throws java.net.MalformedURLException,
java.net.UnknownHostException,
java.io.IOException
urlString - the URL of the server hosting the servlet that will process the Directory
search requests.port - the port number to connect to on the server. This is ignored if urlString
specifies the port.checkConnectivity - whether or not the ability to connect to the server should be tested in the constructor.java.net.MalformedURLException - if urlString is not a valid URL.java.net.UnknownHostException - if the host specified in urlString cannot be contacted.java.io.IOException - if there is an IO problem after connecting to the host.public HttpDirectoryClient(HttpDirectoryClient httpDirectoryClient)
HttpDirectoryClient object using existing parameters.httpDirectoryClient - a com.entrust.toolkit.util.HttpDirectoryClient object.public boolean isAvailable()
If this method returns true, it is not a guarantee
that the servlet can communicate with the Directory.
isAvailable in interface LdapDirectorytrue if the remote servlet is
available.public byte[][] getAttr(java.lang.String dn,
java.lang.String attributeToFind)
throws javax.naming.NamingException
getAttr method of the LdapDirectory
interface.
This method sends an HTML GET request to the proxy servlet,
requesting a Directory search. The search specifies a particular attribute
at a particular Directory entry, which is specified by a distinguished name (DN).
The getAttr method reads the servlet's response and returns the
attribute as an array of byte arrays.
Given a DN and a desired attribute (using X.509 names such as userCertificate, dn, cn, email, and so on), this method returns a byte array containing the attributes certificate, CRL, DN, and email address.
The following code fragment is an example of typical usage. In this case each element of the result is a byte array representation of one of the user's certificates.
getAttr( "cn=Roger Ramjet, o=Lompoc, c=US", "userCertificate" );
getAttr in interface LdapDirectorydn - the distinguished nameattributeToFind - the attribute to findbyte array.javax.naming.NamingException - thrown if the search failspublic X509CRL[] getCRLs(java.lang.String distributionPoint, boolean wantARL) throws javax.naming.NamingException, java.security.cert.CRLException
getCRLs() method of the LdapDirectory
interface.
This method sends an HTML GET request to the proxy servlet,
requesting a Directory search for CRLs or ARLs at a particular distribution point.
It reads the servlet's response and returns an array of CRLs or ARLs.
getCRLs in interface LdapDirectorydistributionPoint - the DN as defined in a certificatewantARL - a boolean flag indicating that an ARL is requiredjavax.naming.NamingException - thrown if the search failsjava.security.cert.CRLException - thrown for other errorspublic void setClientCredentials(java.security.cert.X509Certificate verificationCertificate,
java.security.cert.X509Certificate caCertificate,
java.security.PrivateKey signingKey)
setClientCredentials in interface LdapDirectoryverificationCertificate - a verification certificatecaCertificate - the CA certificate that issued verificationCertificatesigningKey - the private signing key that signs messages verified by verificationCertificatepublic void setWebProxy(java.lang.String ipAddress,
int port)
throws java.net.UnknownHostException,
java.io.IOException
ipAddress - the IP address of the Web proxyport - the port number of the proxyjava.net.UnknownHostException - if the specified IP address cannot be contacted.java.io.IOException - if an IO error occurs after connecting to the proxy.public void addHttpHeader(java.lang.String name,
java.lang.String value)
This method does not check the validity of the HTTP request
header. The host and accept fields
are ignored these headers are reserved for the tunneling
request.
name - the header namevalue - the header value