Tobj Module

The Tobj module contains TUXEDO related interfaces to perform client-side transaction management and security authentication functions.

PrincipalAuthenticator

The PrincipalAuthenticator of the Tobj module provides an easy way to log on and log off the TUXEDO system.

Listing 4-3 Definition for Active Expert PrincipalAuthenticator Interface
interface PrincipalAuthenticator
{
typedef unsigned long AuthType;
AuthType get_auth_type();
long logon(
in string user_name,
in string client_name,
in string system_password,
in string user_password,
in sequence<octet> user_data)
void logoff();
}

The next code listing shows the methods of PrincipalAuthenticator in Visual Basic syntax.

Listing 4-4 PrincipalAuthenticator in Visual Basic Syntax
Public Function get_auth_type(Optional ByRef exceptionInfo As VARIANT)  As Tobj_AuthType
Public Sub logoff(Optional ByRef exceptionInfo As VARIANT)
Public Function logon(
ByVal user_name As String,
ByVal client_name As String,
ByVal system_password As String,
ByVal user_password As String,
ByVal user_data As VARIANT,
Optional ByRef exceptionInfo As VARIANT) As Security_AuthenticationStatus

get_auth_type()

This operation returns the current TUXEDO authentication level. It is a wrapper for the ATMI function tpchkauth().

logon()

This operation logs the user on to the TUXEDO system. logon() is a wrapper of the ATMI function tpinit().

Table 4-2 logon() Parameters

Parameter Description

user_name

TUXEDO user name

client_name

TUXEDO client name

system_password

TUXEDO application password

user_password

TUXEDO user password

user_data

Binary data (safearray of bytes), used instead of the user_password.

If user_data is empty, the user_password is passed to the TUXEDO security service. Otherwise the user_password parameter is ignored (refer to the description of tpinit() in the TUXEDO Reference Manual for a more detailed explanation of the TUXEDO security parameters). If user_password and user_data are both set, and the authentication level is TPAPPAUTH, a BAD_PARAM system exception is raised.

Upon successful logon SecAuthSuccess(1) is passed back, otherwise SecAuthFailure(2) is passed.

logoff()

This operation logs off from the TUXEDO system.

CurrentContext

The CurrentContext interface encapsulates the implicit context associated with the Tobj module. CurrentContext provides operations to retrieve the Current pseudo-objects of the CosTransactions module.

Listing 4-5 Definition of the CurrentContext Interface
interface CurrentContext{
CosTransactions::Current resolve_initial_references
(in string id);
}

The following code listing shows the methods of CurrentContext in Visual Basic syntax.

Listing 4-6 CurrentContext in Visual Basic Syntax
Public Function resolve_initial_references (id as string) 
As DICosTransactions_Current

resolve_initial_references()

Returns the Current pseudo-object from the CosTransactions module. An input string parameter of TransactionCurrent is required. A null value is returned if the Current object cannot be located.

Session

The only interface that can be created from the environmental modules is Tobj::Session. Instances of all the other interfaces defined in the environmental modules are retrieved using methods of Session and other objects.

In the Active Expert, there can be only one Session object active per client process at a time. If the Active Expert client attempts to create a second instance, the same instance is returned. This design is to reflect the fact that ATMI does not allow multiple sessions per client process.

Session is a subclass of Tobj::PrincipalAuthenticator, so the authentication operations defined in PrincipalAuthenticator can be called on instances of Session (note that PrincipalAuthenticator cannot be created).

The Session pseudo-object is also used to get access to Current pseudo-objects from the CosTransactions module by returning the CurrentContext object.

Listing 4-7 Definition for the Session Object Interface
interface Session : PrincipalAuthenticator
{
CurrentContext get_current_context()
string get_env_var (in string name)
int set_env_var (in string name, in string value)
int read_env (in string file, in string label)
string get_error_text(in long minor_code);
}

The Visual Basic definition of Session is shown in the following code listing. (This example includes the inherited methods from the PrincipalAuthenticator subclass.)

Listing 4-8 Session Definition
Public Function get_current_context(Optional ByRef exceptionInfo As VARIANT)  
As DITobj_CurrentContext
Public Function get_env_var(ByVal name As String, Optional ByRef exceptionInfo
As VARIANT) As String
Public Function get_error_text( ByVal minor_code As Long, Optional ByRef
exceptionInfo As VARIANT) As String
Public Function read_env(ByVal file As String, ByVal label As String, Optional
ByRef exceptionInfo As VARIANT) As Long
Public Function set_env_var(ByVal name As String, _
ByVal value As String, Optional ByRef exceptionInfo As VARIANT) As Long

get_current_context()

Returns the current context pseudo-object.

get_env_var()

This is a wrapper function for the ATMI function tuxgetenv().

set_env_var()

This is a wrapper function for the ATMI function tuxputenv().

read_env ()

This is a wrapper function for the ATMI function tuxreadenv().

get_error_text()

This is a wrapper function for the ATMI function tpstrerror(). Refer to the TUXEDO Reference Manual for details about ATMI functions.

Example

The following Visual Basic code example shows the usage of interfaces in the Tobj module.

Listing 4-9 Visual Basic Code Using Interfaces in Tobj Module
Dim session As Object
Dim SecCurrent As Object
Dim UserData(0) As Byte

Const TUXEDO = 1
Const SecAuthFailure = 2

Private Sub Form_Load()
Set session = CreateObject("Tobj.Session")
End Sub

Private Sub Command1_Click()
session.set_env_var("WSENVFILE", "c:\tuxedo.ini")
session.set_env_var("WSAPP", "BANK")
ret = session.logon("Pal", "MyGroup", "MySystemPassword", "MyPassword",
UserData)
If ret = SecAuthFailure Then
MsgBox "Logon failed"
End If
End Sub

Private Sub Command2_Click()
session.logoff
End Sub