public class LdapURLStreamHandlerFactory
extends java.lang.Object
implements java.net.URLStreamHandlerFactory
This LdapURLStreamHandlerFactory can be registered within the java.net
URL framework by calling:
URL.setURLStreamHandlerFactory(new LdapURLStreamHandlerFactory());The
setURLStreamHandlerFactory()
call can be executed only
once per Java VM invocation. In order to allow you to use additional
custom protocols this factory class allows you to register
URLStreamHandlers for them.
Alternatively you may register the IAIK ldap url stream handler by
using the java.protocol.handler.pkgs
system property:
System.getProperties().put("java.protocol.handler.pkgs", "iaik.x509.net");or -- if you are using JDK 1.2 or later -- you can specify the handler dynamically when creating an URL object, e.g.:
URL u = new URL(null, "ldap://...", new iaik.x509.net.ldap.Handler());In this case the handler will be used for the one particular URL object only. Thus you may have to create all your ldap URLs in this way. Also note that you do not need to create a new Handler object each time, you can use the same for all URLs.
LdapURLConnection
,
Handler
Constructor and Description |
---|
LdapURLStreamHandlerFactory()
Creates a new LdapURLStreamHandlerFactory().
|
Modifier and Type | Method and Description |
---|---|
void |
addHandler(java.lang.String protocol,
java.net.URLStreamHandler handler)
registers an additional URLStreamHandler.
|
java.net.URLStreamHandler |
createURLStreamHandler(java.lang.String protocol)
Gets a URLStreamHandler for the given protocol.
|
public LdapURLStreamHandlerFactory()
public java.net.URLStreamHandler createURLStreamHandler(java.lang.String protocol)
createURLStreamHandler
in interface java.net.URLStreamHandlerFactory
protocol
- the protocol ("ldap") for which a URLStreamHandler is
requestednull
if no handler for the given protocol is availablepublic void addHandler(java.lang.String protocol, java.net.URLStreamHandler handler)
protocol
- the protocol for which a URLStreamHandler shall
be registeredhandler
- the URLStreamHandler to be registered for the
given protocol