Using the IOM Server |
To use this method, you must provide the client program with instructions for connecting to the
LDAP directory, the logical name of the information you want to search for, and the context within
the directory for performing the search.
To provide this information, you can create an instance of java.util.Hashtable
containing the appropriate properties.
For a complete list of the properties you can provide, refer to the documentation for the
class javax.naming.Context
.
Note that the property names are string constants on the javax.naming.Context
interface instead of literal strings.
The following five properties are required:
javax.naming.Context.INITIAL_CONTEXT_FACTORY
com.sun.jndi.ldap.LdapCtxFactory
.
javax.naming.Context.PROVIDER_URL
ldap://host:port
.
javax.naming.Context.SECURITY_AUTHENTICATION
none
, simple
, or
strong
.
javax.naming.Context.SECURITY_PRINCIPAL
javax.naming.Context.SECURITY_AUTHENTICATION
is none
.
javax.naming.Context.SECURITY_CREDENTIALS
javax.naming.Context.SECURITY_PRINCIPAL
. This property is
not required if the value for
javax.naming.Context.SECURITY_AUTHENTICATION
is none
.
The last two statements in the example show how to dispose of a workspace object reference when you are done with it. For details on this procedure, see Returning a Workspace to the Workspace Factory.
import java.io.PrintWriter; import java.util.Hashtable; import javax.naming.Context; import com.sas.iom.WorkspaceConnector; import com.sas.iom.WorkspaceFactory; import com.sas.iom.SAS.IWorkspace; Hashtable ldapProperties = new Hashtable(); ldapProperties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); ldapProperties.put(Context.PROVIDER_URL,"ldap://host:port"); ldapProperties.put(Context.SECURITY_AUTHENTICATION,"simple"); ldapProperties.put(Context.SECURITY_PRINCIPAL,distinguished name); ldapProperties.put(Context.SECURITY_CREDENTIALS,password); PrintWriter logWriter = new PrintWriter(System.out); WorkspaceFactory wFactory = new WorkspaceFactory(ldapProperties,ldap search context,logical name,false,false,logWriter); WorkspaceConnector connector = wFactory.getWorkspaceConnector(0L); IWorkspace workspace = connector.getWorkspace(); < insert workspace usage code here > wFactory.shutdown(); connector.close();
javax.naming.directory.DirContext
.
import java.io.PrintWriter; import java.util.Hashtable; import javax.naming.Context; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; import com.sas.iom.WorkspaceConnector; import com.sas.iom.WorkspaceFactory; import com.sas.iom.SAS.IWorkspace; Hashtable ldapProperties = new Hashtable(); ldapProperties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); ldapProperties.put(Context.PROVIDER_URL,"ldap://host:port"); ldapProperties.put(Context.SECURITY_AUTHENTICATION,"simple"); ldapProperties.put(Context.SECURITY_PRINCIPAL,distinguished name); ldapProperties.put(Context.SECURITY_CREDENTIALS,password); DirContext ldapDirectory = new InitialDirContext(ldapProperties); < insert LDAP directory usage code here > PrintWriter logWriter = new PrintWriter(System.out); WorkspaceFactory wFactory = new WorkspaceFactory(ldapDirectory,ldap search context, logical name,false,false,logWriter); WorkspaceConnector connector = wFactory.getWorkspaceConnector(0L); IWorkspace workspace = connector.getWorkspace(); < insert workspace usage code here > wFactory.shutdown(); connector.close(); ldapDirectory.close();
There are two reasons that an LDAP server administrator might choose to partition a connection pool into more than one puddle:
shutdown()
.
These access control features are available only when the Java Workspace Factory is using
an LDAP server.
When the Java Workspace Factory is constructed, the access control features can be either enabled or disabled. If they are enabled, then all further calls to Java Workspace Factory methods must contain the valid distinguished name and password of a person object that is present on the LDAP directory. The Java Workspace Factory authenticates the distinguished name and password by using them to bind to the LDAP directory that it used to construct the factory.
In performing the authentication, the Java Workspace Factory follows one of two procedures, depending on whether the call is a request for a workspace object or an attempt to shut the factory down.
sasAllowedClientDN
attributes for all sasLogin
objects that have
the appropriate logical name.
The caller is authorized to use a puddle only if the caller's distinguished name either:
sasAllowedClientDN
attribute; orsasAllowedClientDN
attribute.shutdown()
or destroy ()
, then the Java Workspace factory authorizes
the caller by binding to the LDAP directory server under the provided credentials and searching
for all the sasLogin
objects that have the appropriate logical name.
If the search returns the same set of sasLogin
objects that was returned when the
factory was constructed, then the call is authorized.
import java.io.PrintWriter; import java.util.Hashtable; import javax.naming.Context; import com.sas.iom.WorkspaceConnector; import com.sas.iom.WorkspaceFactory; import com.sas.iom.SAS.IWorkspace; Hashtable ldapProperties = new Hashtable(); ldapProperties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory"); ldapProperties.put(Context.PROVIDER_URL,"ldap://host:port"); ldapProperties.put(Context.SECURITY_AUTHENTICATION,"simple"); ldapProperties.put(Context.SECURITY_PRINCIPAL,administrator 1 distinguished name); ldapProperties.put(Context.SECURITY_CREDENTIALS,administrator 1 password); WorkspaceFactory wFactory = new WorkspaceFactory(ldapProperties,ldap search context,logical name,true,true,null); WorkspaceConnector connector = wFactory.getWorkspaceConnector(user distinguished name,user password,0L); IWorkspace workspace = connector.getWorkspace(); < insert workspace usage code here > wFactory.shutdown(administrator 2 distinguished name,administrator 2 password); connector.close();
Using the IOM Server |