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 the 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 that were created and initialized using the progress.data.getSession( ) stand-alone function. This function combines the features of:

  • Finding all existing JSDOSession instances created using the getSession( ) stand-alone function.
  • Calling the invalidate( ) method on each instance, which in turn calls the logout( ) method on the instance.

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

After invalidateAllSessions( ) executes, any call made to the addCatalog( ), isAuthorized( ), login( ), or ping( ) method on an existing JSDOSession instance, or any attempt to instantiate a progress.data.JSDO, throws an exception. In addition, calls to any method on an existing JSDO instance that communicates with the server associated with an invalidated JSDOSession throws an exception as well.

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

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 login session managed by the current JSDOSession object and permanently disables the object, rendering it unable to start a new login session.

This method throws an error if the underlying communication layer throws an error.

On a successful invalidate, the JSDOSession object sets its connected property to false. If the invalidate fails to logout the session because it cannot access the server, the object still sets its connected property to false because it is no longer available to manage any login session.

Once invalidate( ) is executed, no further communication can occur between the mobile app and the server using this JSDOSession object. Thus, any call made to its addCatalog( ), isAuthorized( ), login( ), or ping( ) method, or any attempt to instantiate a progress.data.JSDO associated with this JSDOSession object, throws an exception. In addition, any calls to methods on an existing JSDO instance that communicate with the server associated with this JSDOSession throw an exception as well.

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.

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

Return type: jQuery Promise

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 ) )