In preparation for SSO support, the recommendation for creating and removing sessions has changed. This post explains the recommended approach and API

New Session management model

With Progress Data Objects Version 4.4.1 or later, the best practices for managing sessions has been updated in preparation for SSO support.

 

When a user logs in, call getSession( ) for each unique URI. This function combines the features of:

  • Preparing the JSDOSession class constructor and instantiating the instance.

  • Calling the login( ) method on the instance to establish a JSDO session.

  • Calling the addCatalog( ) method on the instance to load a single Data Service Catalog.

     

  // On login

 function callGetSession() {

        var promise,

             jsdosession;

       

        try {

                promise = progress.data.getSession({

                        name: "mySession",

                        authenticationModel: jsdoSettings.authenticationModel,

                        serviceURI: jsdoSettings.serviceURI,

                        catalogURI: jsdoSettings.catalogURI,

                        username: "restuser",

                        password: "password"

                    });

                promise.done( function( jsdosession, result ) {

                    myjsdosession = jsdosession;

                    console.log("Success on getSession().");

                   

                    // create a JSDO

                     jsdo = new progress.data.JSDO({

                                name: 'MyCustomerBE'

                     });

               });

                promise.fail( function( result, info ) {

                    console.log("Failure from getSession()");

              });

       }

        catch(ex) {

              console.log("Exception: " + ex.message);

        }

}

 

 

On logout, you simply need to call InvalidateAllSessions( ) once. This function combines the features of:

  • Finding all JSDOSession running instances

  • Calling the invalidate ( ) method on each instance which in turn calls the logout ( ) method on each instance.

     

// On logout

  function doInvalidate() {

        try {   

            progress.data.invalidateAllSessions().done(function (result, info) {

                console.log("invalidateAllSessions succeeded");

            });

        }

        catch(ex) {

            console.log("GOT Exception from invalidateAllSession(): " + ex.message );

        }    

  }   

 


 

New functions

 

invalidateAllSessions stand-alone function

Note: Applies to Progress Data Objects Version 4.4.1 or later.

A stand-alone function that invalidates all current progress.data.JSDOSession instances. This function combines the features of:

  • Finding all JSDOSession running instances

  • Calling the invalidate ( ) method on each instance which in turn calls the logout ( ) method on each instance

Any calls made to progress.data.JSDOSession.ping(), isAuthorized(), addCatalog(), login() and progress.data.JSDO will throw an error if they are called.

Furthermore, if a JSDO instance was associated earlier with a JSDOSession that has been invalidated, any JSDO methods that communicate with the server will throw an error as well.

Note: In order to invoke this function successfully, jQuery Promises must be supported in your development environment. Otherwise, the function throws an exception.

Note: This method does not support proxy servers (servers that function as a security service).

Return type: jQuery Promise

Applies to: The progress.data namespace

 

Syntax

progress.data.invalidateAllSessions ( )

 


 

invalidate( ) method (JSDOSession class)

Note: Applies to Progress Data Objects Version 4.4.1 or later.

Terminates the session and reinitializes most of the state information maintained by the object.

This method throws an error if the method arguments are invalid or if the underlying communication layer throws an error.

On a successful invalidate, the JSDOSession object sets its connected property to false. If the logout fails, the object leaves its connected property set to true, unless the failure happened because the app cannot access the server.

Once invalidate( ) is executed, no further communication (other than a login( ) call) can occur between the web app and the server using this JSDOSession object. However, any catalogs loaded in the object remain available to create and maintain JSDOs, though these JSDOs cannot make requests to the server until a new login session is established for the object (including for anonymous access).

This method is always executed asynchronously and returns results in callbacks that you register using methods of a Promise object returned as the method value.

 

Applies to: progress.data.JSDOSession class

Syntax

invalidate ( )

Promise method signatures

jQuery Promise objects define methods that register a callback function with a specific signature. The callback signatures depend on the method that returns the Promise. Following are the signatures of callbacks registered by methods in any Promise object that invalidate( ) returns.

Syntax:

promise.done( function ( session , result , info ) )
promise.fail( function ( session , result , info ) )
promise.always( function ( session , result , info ) )