Class DirectorySessionFactory

The DirectorySessionFactory factory allows to create a DirectorySessionInterface to authenticate onto a 3djuump Infinite directory.

It also provides also a way to decode authentication hashes that are retrieved on the authentication hashes in case of popup based authentication. The authentication system is based on OpenID Connect layer.

The directory session will try to connect to the given Host.

/** 
* Sample to illustrate the creation of a DirectorySessionInterface.
*/
import { DirectorySessionFactory, DirectorySessionInterface } from 'generated_files/documentation/appinfiniteapi';

// the url of the directory (https://mydirectory:443/directory)
let sDirectoryUrl : string;
// authenticate url
const sAuthenticationUrl : string = 'https://your_server/your_application/authenticate.html';

// create a directory session
const lDirectorySession: DirectorySessionInterface = DirectorySessionFactory.CreateDirectorySession(sDirectoryUrl);

lDirectorySession.getPopupBasedAuthenticationUrl(sAuthenticationUrl);
// etc ...

Please refer to Authentication Samples for more explanations about Sessions.
Factories

Constructors

Methods

  • Creates a directory session from an URL.

    Parameters

    • pDirectoryHost: string
      in
      The url of 3djuump Infinite directory (https://host:443/directory).

    Returns DirectorySessionInterface

    The directory session object, that will try the authentication upon calling the authenticate functions.

  • Decodes the hash content and sends the token to the caller of DirectorySessionInterface.getPopupBasedAuthenticationUrl in case of popup based authentications.

    This will trigger the DirectorySessionInterfaceSignal.LoginSuccess signal on the tab that called DirectorySessionInterface.getPopupBasedAuthenticationUrl.

    This function makes use of the LocalStorage of the browser.

    /** 
    * Sample to illustrate the use of the authentication in the popup based authentication.
    */
    import { DirectorySessionFactory } from 'generated_files/documentation/appinfiniteapi';

    if (window.location.hash)
    {
    // try to decode the authentication hash.
    if (DirectorySessionFactory.DecodeAuthenticationHash(window.location.hash))
    {
    // everything is fine, the other tab is notified
    // just need to close the tab
    window.close();
    }
    else {
    // output some debug error message.
    console.log('Error: unable to decode hash content of authentication');
    // display error
    const lError: HTMLElement = document.getElementById('error');
    lError.textContent = 'Unable to decode hash content of authentication';
    }
    }
    else
    {
    // we have no hash => go back to main page
    // get the url content
    const lPath = window.location.pathname;
    const lOffset : number = lPath.lastIndexOf('/');
    // replace 'authentication.html' by main page 'index.html'
    if (lOffset >= 0)
    {
    // create new location
    const sLocation = window.location.origin + lPath.substring(0, lOffset) + '/index.html';
    // ang go
    window.location.href = sLocation;
    }
    }

    Please see Authentication Samples for more explanations about Sessions.

    Parameters

    • pHash: string
      in
      The hash to decode (usually window.location.hash).

    Returns boolean

    true if the hash was correctly decoded.