### *** This class provides Binary Compatibility only, not Source Compatibility ***

Package com.sas.services.connection

# Class XMLConfigurationBuilder

java.lang.Object
com.sas.services.connection.XMLConfigurationBuilder

@SASScope("ALL") @BinaryCompatibilityOnly public final class XMLConfigurationBuilder extends Object
Converts XML configuration files produced by the Integration Technologies Configuration tool (ITConfig) into a `ManualConnectionFactoryConfiguration` object. ITConfig produces a server information XML file that describes connection parameters for an IOM server or a cluster of servers. Typically the server information XML file describes connection parameters for a SAS Metadata Server.

The server information XML file may also describe one or more credentials that can be used to connect to the IOM server. Alternately, ITConfig can produce a user information XML file that describes one or more credentials that can be used to connect to an IOM Server. Typically, the server information XML file and user information XML file each describe no more than one credential. In all cases, no more than one credential per authentication domain is allowed.

This class extracts the connection parameters for the IOM server and, if specified, the credentials that can be used to connect to the server.

Since:
  9.2

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `XMLConfigurationBuilder(File serverInfoFile)`
  Construct a `ConfigurationBuilder` object with a server information XML file.
  `XMLConfigurationBuilder(File serverInfoFile, File userInfoFile)`
  Construct a `ConfigurationBuilder` object with a server information XML file and a user information XML file.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ManualConnectionFactoryConfiguration`
  `getConfiguration()`
  Get the `ManualConnectionFactoryConfiguration` object created from the server information XML file.
  `Credential`
  `getCredentialForDomain(String domain)`
  Get the credential for a desired domain created from the user information XML file or from user information in the server information XML file.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### XMLConfigurationBuilder

    public XMLConfigurationBuilder(File serverInfoFile) throws ConnectionFactoryException
    Construct a `ConfigurationBuilder` object with a server information XML file.
    Parameters:
      `serverInfoFile` - a server information XML file produced by ITConfig
    Throws:
      `ConnectionFactoryException` - if there is a problem accessing or processing the server information XML file
      `NullPointerException` - if serverInfoFile is `null`

  - ### XMLConfigurationBuilder

    public XMLConfigurationBuilder(File serverInfoFile, File userInfoFile) throws ConnectionFactoryException
    Construct a `ConfigurationBuilder` object with a server information XML file and a user information XML file. If both the server information XML file and the user information XML file contain a credential for the same authentication domain, the one from the user information XML file will take precedence.
    Parameters:
      `serverInfoFile` - a server information XML file produced by ITConfig
      `userInfoFile` - a user information XML file produced by ITConfig
    Throws:
      `ConnectionFactoryException` - if there is a problem accessing or processing the server information XML file or the user information XML file
      `NullPointerException` - if serverInfoFile is `null`

- ## Method Details

  - ### getConfiguration

    public ManualConnectionFactoryConfiguration getConfiguration()
    Get the `ManualConnectionFactoryConfiguration` object created from the server information XML file.
    Returns:
      the `ManualConnectionFactoryConfiguration` object created from the server information XML file.

  - ### getCredentialForDomain

    public Credential getCredentialForDomain(String domain)
    Get the credential for a desired domain created from the user information XML file or from user information in the server information XML file.

    This code shows an example of how to determine which domain to ask for:

         ConfigurationBuilder builder = new ConfigurationBuilder(...);
         ManualConnectionFactoryConfiguration cxfConfig = builder.getConfiguration();
         Cluster[] clusterArr = cxfConfig.getClusterArray();
         String domain = clusterArr[0].getDomain();
         Credential cred = builder.getCredentialForDomain(domain);

    Here is a different example:

         ConfigurationBuilder builder = new ConfigurationBuilder(...);
         ManualConnectionFactoryConfiguration cxfConfig = builder.getConfiguration();
         ConnectionFactoryManager cxfManager = new ConnectionFactoryManager();
         ConnectionFactoryInterface cxf = cxfManager.getFactory(cxfConfig);
         List domainLst = cxf.getDomains();
         String domain = (String)domainLst.get(0);
         Credential cred = builder.getCredentialForDomain(domain);
         ConnectionInterface cx = cxf.getConnection(cred);

    Parameters:
      `domain` - the desired domain for the credential
    Returns:
      the credential for a desired domain or `null` if no credential was specified for that domain