Connecting with Directly Supplied Server Attributes

Overview of Connecting with Directly Supplied Server Attributes

In order to make a connection to an IOM server, you must give the Java Connection Factory specific information about the server and about the desired connection. The quickest and simplest method of providing this information is to place it directly into the client program when you create the BridgeServer object. The following attributes can be provided:
host
specifies the IP address of the machine where the IOM server or object spawner is running. This attribute is required.
port
specifies the TCP port that the IOM server or object spawner is listening on for connections. This attribute is required.
encryptionPolicy
specifies whether IOM Bridge for Java should attempt to negotiate with the server over which encryption algorithm to use and what to do if the negotiations fail. This attribute is optional. Possible values are as follows:
none
specifies not to use encryption. This is the default.
optional
specifies to attempt to use encryption but, if algorithm negotiation fails, continue with an unencrypted connection.
required
specifies to attempt to use encryption but, if algorithm negotiation fails, fail the connection.
encryptionAlgorithms
specifies the list of algorithms that you are willing to use in order of preference. Values in the list should be separated by commas and chosen from SASPROPRIETARY, RC2, RC4, DES, or TRIPLEDES. This attribute is optional. If no value is specified, then one of the server's preferred algorithms is used. It is ignored entirely if the value for encryptionPolicy is none.
Note: If you do not have a license for SAS/SECURE software, then only the SASPROPRIETARY algorithm is available.
encryptionContent
specifies which messages should be encrypted if encryption is used. This attribute is optional, and it is ignored entirely if the value for encryptionPolicy is none. Possible values are as follows:
all
encrypts all messages. This is the default.
authentication
encrypts only messages that contain user name and password information.

Example of Connecting with Directly Supplied Server Attributes

The Java code in this example demonstrates how to create a BridgeServer object to provide information to the Java Connection Factory and obtain a connection. For an example showing how to use a connection, see Java Connection Factory Language Service Example.
The last two statements in this example show how to dispose of a connection. For details about this procedure, see Returning Connections to the Java Connection Factory .
import com.sas.iom.SAS.IWorkspace;
import com.sas.iom.SAS.IWorkspaceHelper;
import com.sas.services.connection.BridgeServer;
import com.sas.services.connection.ConnectionFactoryAdminInterface;
import com.sas.services.connection.ConnectionFactoryConfiguration;
import com.sas.services.connection.ConnectionFactoryInterface;
import com.sas.services.connection.ConnectionFactoryManager;
import com.sas.services.connection.ConnectionInterface;
import com.sas.services.connection.ManualConnectionFactoryConfiguration;
import com.sas.services.connection.Server;

// identify the IOM server
String classID = Server.CLSID_SAS;
String host = "rnd.fyi.sas.com";
int port = 5310;
Server server = new BridgeServer(classID,host,port);

// make a connection factory configuration with the server
ConnectionFactoryConfiguration cxfConfig =
   new ManualConnectionFactoryConfiguration(server);

// get a connection factory manager
ConnectionFactoryManager cxfManager = new ConnectionFactoryManager();

// get a connection factory that matches the configuration
ConnectionFactoryInterface cxf = cxfManager.getFactory(cxfConfig);

// get the administrator interface
ConnectionFactoryAdminInterface admin = cxf.getAdminInterface();

// get a connection
String userName = "abcserv";
String password = "abcpass";
ConnectionInterface cx = cxf.getConnection(userName,password);
org.omg.CORBA.Object obj = cx.getObject();
IWorkspace iWorkspace = IWorkspaceHelper.narrow(obj);

< insert iWorkspace workspace usage code here >

cx.close();
// tell the factory that it can destroy unused connections
admin.shutdown();
Note: To make the previous example more readable, we have removed most of the code structuring elements. The example will not compile as it is shown.