public class DiscoveryHelper
extends java.lang.Object
The first step in discovering information is to create a discovery handle. Discovery handle specifies the source from which information will be discovered.
DiscoveryHelper disco = new DiscoveryHelper(DiscoveryHelper.DNS_DISCOVER);
The argument passed "DiscoveryHelper.DNS_DISCOVER" specifies the source. Currently following sources are supported :- DNS_DISCOVER
,CFGFILE_DISCOVER
,AUTO_DISCOVER
, OID_DISCOVER
Each source may require some inputs to be specified for discovery of information.
// Set the property for the DNS_DN
disco.setProperty(DiscoveryHelper.DNS_DN,"dc=us,dc=fiction,dc=com");
// Set the property for the DNS_DISCOVER_METHOD
disco.setProperty(DiscoveryHelper.DNS_DISCOVER_METHOD
,DiscoveryHelper.USE_INPUT_DN_METHOD);
// Set the property for the SSLMODE
disco.setProperty(DiscoveryHelper.SSLMODE,DiscoveryHelper.SSL_FALSE);
Now the information can be discovered.// Call the discover method
int ret = disco.discover(reshdl);
The various error codes that can be returned by discover() method are :-LDAP_SUCCESS
, LDAP_NO_INFO_OBTAINED
,LDAP_LOOKUP_ERROR
,LDAP_DNS_ADDR_NOT_FOUND
, LDAP_FILE_NOT_FOUND
, LDAP_FILE_PARSE_ERROR
, LDAP_PARAM_ERROR
ArrayList result = (ArrayList)reshdl.get(DiscoveryHelper.DIR_SERVERS);
if (result != null)
{
if (result.size() == 0) return;
System.out.println("The hostnames are :-");
for (int i = 0; i < result.size();i++)
{
String host = (String)result.get(i);
System.out.println((i+1)+".\t\""+host+"\"");
}
}
Modifier and Type | Field and Description |
---|---|
static java.lang.Integer |
ALTDIR_SERVERS |
static int |
AUTO_DISCOVER
This source will first try to locate and parse configuration file.
|
static int |
CFGFILE_DISCOVER
This source will parse the configuration file (ldap.ora) and return the value of parameters present in it.
|
static java.lang.Integer |
CFGFL_PATH |
static java.lang.Integer |
DEF_ADMIN_CTXT |
static java.lang.Integer |
DETAILED_ERROR_INFO |
static java.lang.Integer |
DIR_SERVER_CONN_SEC |
static java.lang.Integer |
DIR_SERVER_TYPE |
static java.lang.Integer |
DIR_SERVERS |
int |
discoveryType |
static int |
DNS_DISCOVER
This source will discover hostname information from DNS server.
|
static java.lang.String |
DNS_DISCOVER_METHOD
This property specifies the method to be used for dns discovery.
|
static java.lang.String |
DNS_DN
This property specifies the dn required for dns discovery
|
static java.lang.String |
GEN_DETAILED_ERR_RPT
This property specifies whether detailed error information is required for AUTO discovery
|
static java.lang.String |
HOSTINFO
This property specifies the host:port information required for OID discovery
|
static int |
LDAP_DNS_ADDR_NOT_FOUND |
static int |
LDAP_FILE_NOT_FOUND |
static int |
LDAP_FILE_PARSE_ERROR |
static int |
LDAP_LOOKUP_ERROR |
static int |
LDAP_NO_INFO_OBTAINED |
static int |
LDAP_PARAM_ERROR |
static int |
LDAP_SUCCESS |
static java.lang.Integer |
NONSSL_PORT |
static int |
OID_DISCOVER
This source will discover information from OID server.
|
static java.lang.Integer |
ORCLCOMMCTXMAP |
static java.lang.String |
SSL_FALSE |
static java.lang.Integer |
SSL_PORT |
static java.lang.String |
SSL_TRUE |
static java.lang.String |
SSLMODE
This property specifies whether ssl based or non-ssl based server information is to be discovered.
|
static java.lang.String |
USE_ALL_METHODS
This method tries all the above mentioned methods in succession stopping when any of these methods succeeds in DNS lookup.
|
static java.lang.String |
USE_DFLT_LOOKUP_METHOD
This discover method specifies that default domain name should be used for DNS lookup
|
static java.lang.String |
USE_INPUT_DN_METHOD
This discover method specifies that dn(distinguished name) be used to obtain domain name required for DNS lookup.
|
static java.lang.String |
USE_MC_DOMAIN_METHOD
This discover method specifies that domain component of client machine is to used for obtaining domain name required for DNS lookup.
|
Constructor and Description |
---|
DiscoveryHelper(int type)
Create an instance to discover information from a specified source.
|
Modifier and Type | Method and Description |
---|---|
int |
discover(java.util.HashMap reshdl)
Discover the information from the source.
|
java.util.ArrayList |
getMultiValProperty(java.lang.String property)
Get all property values.
|
java.lang.String |
getProperty(java.lang.String property)
Get the property value.
|
int |
releaseContext()
Release global context
|
java.lang.Object |
setMultiValProperty(java.lang.String property, java.util.ArrayList lst)
Set multiple values for a property.
|
java.lang.Object |
setProperty(java.lang.String property, java.lang.String value)
Set the property value.
|
public int discoveryType
public static final int DNS_DISCOVER
DNS_DN
, DNS_DISCOVER_METHOD
, SSLMODE
DIR_SERVERS
public static final int CFGFILE_DISCOVER
SSLMODE
DIR_SERVERS
, DEF_ADMIN_CTXT
, DIR_SERVER_TYPE
public static final int AUTO_DISCOVER
SSLMODE
, GEN_DETAILED_ERR_RPT
DIR_SERVERS
, DEF_ADMIN_CTXT
, DIR_SERVER_TYPE
ALTDIR_SERVERS
, ORCLCOMMCTXMAP
, DIR_SERVER_CONN_SEC
, DETAILED_ERROR_INFO
public static final int OID_DISCOVER
HOSTINFO
, SSLMODE
NONSSL_PORT
, SSL_PORT
, DEF_ADMIN_CTXT
, ORCLCOMMCTXMAP
public static final java.lang.Integer DEF_ADMIN_CTXT
public static final java.lang.Integer DIR_SERVERS
public static final java.lang.Integer DIR_SERVER_TYPE
public static final java.lang.Integer ALTDIR_SERVERS
public static final java.lang.Integer ORCLCOMMCTXMAP
public static final java.lang.Integer DIR_SERVER_CONN_SEC
public static final java.lang.Integer CFGFL_PATH
public static final java.lang.Integer SSL_PORT
public static final java.lang.Integer NONSSL_PORT
public static final java.lang.Integer DETAILED_ERROR_INFO
public static final java.lang.String SSL_FALSE
public static final java.lang.String SSL_TRUE
public static final java.lang.String DNS_DN
public static final java.lang.String DNS_DISCOVER_METHOD
USE_INPUT_DN_METHOD
, USE_MC_DOMAIN_METHOD
, USE_DFLT_LOOKUP_METHOD
, USE_ALL_METHODS
public static final java.lang.String SSLMODE
SSL_FALSE
, SSL_TRUE
public static final java.lang.String HOSTINFO
public static final java.lang.String GEN_DETAILED_ERR_RPT
public static final java.lang.String USE_INPUT_DN_METHOD
public static final java.lang.String USE_MC_DOMAIN_METHOD
public static final java.lang.String USE_DFLT_LOOKUP_METHOD
public static final java.lang.String USE_ALL_METHODS
public static final int LDAP_NO_INFO_OBTAINED
public static final int LDAP_LOOKUP_ERROR
public static final int LDAP_DNS_ADDR_NOT_FOUND
public static final int LDAP_FILE_NOT_FOUND
public static final int LDAP_FILE_PARSE_ERROR
public static final int LDAP_PARAM_ERROR
public static final int LDAP_SUCCESS
public DiscoveryHelper(int type)
type
- discovery information source. It can have following values :- DNS_DISCOVER
, CFGFILE_DISCOVER
, AUTO_DISCOVER
public int discover(java.util.HashMap reshdl)
reshdl
- Result map. It contains the result type and result array name-value pairs.public int releaseContext()
public java.lang.Object setProperty(java.lang.String property, java.lang.String value)
setMultiValProperty(java.lang.String, java.util.ArrayList)
property
- Property whose value is to be set.value
- value to be assigned to the property.public java.lang.Object setMultiValProperty(java.lang.String property, java.util.ArrayList lst)
property
- Property whose value is to be set.lst
- ArrayList of String values to be assigned to the property.public java.lang.String getProperty(java.lang.String property)
property
- Property whose value is to be obtained.public java.util.ArrayList getMultiValProperty(java.lang.String property)
property
- Property whose value is to be obtained.