Skip Headers
Oracle® Database Lite Developer's Guide
10g (10.2.0)
Part No. B15920-01
  Go To Table Of Contents
Contents
Go To Index
Index

Previous
Previous
Next
Next
 

17 Oracle Database Lite Security

The following sections detail security issues for Oracle Database Lite:

17.1 Authenticating Users With Your Own User Management System

You can provide an external authenticator for the Mobile Server to authenticate users with passwords as well as their access privileges to applications. For example, in an enterprise environment, you may have your user data, such as employee information, stored in a LDAP-based directory service. The Mobile Server can retrieve the user information from the LDAP directory—or from any custom User Management System—if configured with your own implementation of an external authenticator. The Mobile Server links the external user information to the Mobile Server repository.

17.1.1 Implementing Your External Authenticator

In order to use an external authenticator, you must implement the oracle.lite.provider.Authenticator JAVA interface and configure the implementation in the webtogo.ora file.


Note:

Sample code for an external authenticator can be found in <ORACLE_HOME>\Mobile\Server\samples\devmgr\java\SampleAuthenticator.java

Implement the following methods in your external authenticator. The Mobile Server invokes each of these methods as appropriately.

The Initialization Method for the External Authenticator

Mobile Server invokes the initialize method before calling any other method of provider class. This method will be called only once when the provider is initialized.

Method: void initialize (String metaData) throws Exception
Parameter: String metaData (Reserved for future use)

The Destruction Method for the External Authenticator

Mobile Server invokes the destroy method when the system shutdowns. Provider implementation should implement all the cleanup code in this method.

Method: void destroy() throws Exception
Parameter: None

The Authentication Method for the External Authenticator

Authenticate a user and return a session handle. The returned session handle is passed to the logOff method when the user logs off from the system. Note that the logOff method may not be called for each successful authenticate method call. Some of the Mobile Server clients may use the authenticate method to verify the user credential and not for logging on to the system.

Method: Object authenticate (String uid, String pwd) throws SecurityException
Parameter: User Id (or User Name) and password string
Return: Session handle or null

The User Instantiation Method for the External Authenticator

If the user has not been instantiated in the Mobile Server repository, then the Mobile Server invokes the getInitializationScripts method—after authenticating the user—to retrieve the initialization scripts for the user. The Mobile Server uses the initialization scripts to instantiate the user in the Mobile Server and assign access rights to applications and data. See Section 17.1.3, "User Initialization Scripts" for more information.

Method: StringBuffer getInitilizationScripts (Object sid)
Parameter: Session handle returned by 'authenticate' method
Return: 'StringBuffer' containing User's initialization scripts

Retrieve the User Name or the User Global Unique ID

Return the user name or GUID (Globally Unique Id) of the user if there is one. Usually, LDAP-based User Management systems maintain a GUID for each user. In case your authentication mechanism does not support GUID, then the getUserGUID method returns NULL.

Method: String getFullName (Object sid)
Parameter: Session handle returned by 'authenticate' method
Return: User's full name

Method: String getUserGUID (Object sid)
Parameter: Session handle returned by 'authenticate' method
Return: User's GUID or null

Log Off User

Log off the User from the back-end system. Note that the logOff method may not be called for each successful authenticate method call. Some of the Mobile Server clients may use the authenticate method to verify the user credential and not for logging on to the system.

Method: void logOff (Object sid) throws SecurityException
Parameter: Session handle returned by 'authenticate' method

Change User Password

Method: void changePassword (Object sid, String pwd) throws SecurityException
Parameter: Session handle returned by the authenticate method and new password string

17.1.2 Registering External Authenticator

To register your external authenticator, modify the webtogo.ora file and set your external Authenticator JAVA class name in the EXTERNAL_AUTHENTICATION section, as follows:

[EXTERNAL_AUTHENTICATION]
CLASS  = SampleAuthenticator
EXPIRATION = 1800

The Mobile Server caches the user instantiated through the external authenticator for a period of time in order to improve efficiency. The default expiration time for the cached user object is 30 minutes (or 1800 seconds). Customize this value by setting a new value for the EXPIRATION parameter.

17.1.3 User Initialization Scripts

Mobile Server invokes the getInitilizationScripts method to retrieve the user initialization script that instantiates user-specific objects in the Mobile Repository. The external authenticator can perform the following actions during the initialization process:

  1. Assign access rights to applications

  2. Set data subscription parameters.

  3. Optionally, add the user to a user group.

The syntax of the initialization script is based on the INI format. The first section in the script is as follows.

[MAIN]
VERSION=2

The following example performs these actions for a user whose id is USER1.

  1. Assigning access rights to applications.

    Assign access rights to Application1 and Application2 for USER1, where Application1 has two publication items and three subscription parameters.

    # List the applications we want access to
    #
    [ACL]
    Application1
    Application2
    # List Access details for 'Application1'
    #
    [ACL.Application1]
    NAME=USER1
    TYPE=USER
    DATA=LOCATION, ITEMS
    # List Access details for 'Application2'
    #
    [ACL.Application2]
    NAME=USER1
    TYPE=USER
    
    
  2. Setting data subscription parameters.

    [SUBSCRIPTION.USER1.Application1.LOCATION]
    NAME=ZIP, USR_ID
    VALUE=12345, USER1
    [SUBSCRIPTION.USER1.Application1.ITEMS]
    NAME=WEIGHT
    VALUE=20
    
    
  3. Adding a User to a User Group

    [GROUP]
    User's Group
    [GROUP.User's Group]
    USER=USER1
    

17.2 Providing Your Own Encryption Module for the Client Oracle Lite Database

The database on the Mobile client—also known as the Oracle Lite database—uses Advanced Encryption Standard (AES) for encrypting the database. However, you can provide your own encryption module for the client database. The following sections describe how to implement and plug-in your own encryption module.

17.2.1 Encryption Module APIs

Oracle Database Lite invokes your encryption APIs when performing encryption duties, instead of the internal AES encryption module. Thus, you must develop and include the following APIs in your encryption module:


Note:

All of the functions in this section are in Windows format. Adjust appropriately if developing on a UNIX environment.

17.2.1.1 Initializing the Encryption Module

Implement the encCreateCtxt function to initialize the external encryption module. Oracle Database Lite invokes this function when initializing encryption. This function returns an encryption context handle to Oracle Database Lite, which it passes back on all subsequent API calls. The context handle is displayed as a void*, so that you can make it any type of structure you desire.

__declspec(dllexport) void* encCreateCtxt()

17.2.1.2 Delete Encryption Context

When Oracle Database Lite is finished with the encryption module, it invokes the encDeleteCtxt function to delete the encryption context—which was created with the encCreateCtxt function.

__declspec(dllexport) void encDeleteCtxt(voie * ctx);

17.2.1.3 Create the Encryption Key

Oracle Database Lite invokes your encCreateKey function to create the encryption key within the encryption context, as follows:

__declspec(dllexport) void encCreateKey (void* ctx, const unisgned char* key, int len, int dir);

Where the input parameters are as follows:

  • ctx—The encryption context, which is created in the encCreateCtxt function.

  • key—Pointer to the key to be created.

  • len—Length of the encryption key.

  • dir—Encryption direction or type, where 1: encryption, 2: decryption, 3: both encryption and decryption.

17.2.1.4 Encrypt Data

Oracle Database Lite invokes your encEncryptData function to encrypt the data that is to be sent, as follows:

__declspec(dllexport) void encEncryptData (void* ctx, const unisgned char* data, int len, unsigned char* out);

Where the input parameters are as follows:

  • ctx—The encryption context, which is created in the encCreateCtxt function.

  • data—Pointer to the data to be encrypted.

  • len—Length of the data in bytes.

  • out—Output buffer.

This function returns the number of bytes copied to the output buffer.

17.2.1.5 Decrypt Data

Oracle Database Lite invokes your encDecryptData function to decrypt the data that it receives. This function copies the result to the output buffer.

__declspec(dllexport) void encDecryptData (void* ctx, const unisgned char* data, int len, unsigned char* out);

Where the input parameters are as follows:

  • ctx—The encryption context, which is created in the encCreateCtxt function.

  • data—Pointer to the data to be decrypted.

  • len—Length of the data in bytes.

  • out—Output buffer.

This function returns the number of bytes copied to the output buffer.

17.2.2 Plug-In Custom Encryption Module

Once implemented, you can plug-in your custom encryption module by adding the [All Databases] section to the POLITE.INI configuration file. You must either implement your encryption module into a DLL for the Windows environment or into a Shared Object (.SO) for the UNIX environment.

For example, if you created the encryption module as a DLL called my_enc.dll, which is located in the C:\my_dir directory, then you would add this module as the default encryption module in the POLITE.INI configuration file, as follows:

[All Databases]
EXTERNAL_ENCRYPTION_DLL=C:\my_dir\my_enc.dll