The Tobj
module contains TUXEDO related interfaces to perform client-side transaction management and security authentication functions.
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
This operation returns the current TUXEDO authentication level. It is a wrapper for the ATMI function tpchkauth()
.
This operation logs the user on to the TUXEDO system. logon()
is a wrapper of the ATMI function tpinit()
.
Upon successful logon This operation logs off from the TUXEDO system.
The SecAuthSuccess(1)
is passed back, otherwise SecAuthFailure(2)
is passed.
logoff()
CurrentContext
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
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.
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
Returns the current context pseudo-object.
This is a wrapper function for the ATMI function tuxgetenv()
.
This is a wrapper function for the ATMI function tuxputenv()
.
This is a wrapper function for the ATMI function tuxreadenv()
.
This is a wrapper function for the ATMI function tpstrerror()
. Refer to the TUXEDO Reference Manual for details about ATMI functions.
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