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, and is bound to a MetadataManagerInterface.

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

// MetadataManagerInterface has been created previously
let lMetadataManager: MetadataManagerInterface;
// 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(lMetadataManager, sDirectoryUrl);

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

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

See

DirectorySessionInterface

Hierarchy

  • DirectorySessionFactory

Constructors

Methods

  • Creates a directory session.

    Warning : creating a directory session from Host / Path / Port is now deprecated, please use the url signature.

    Returns

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

    Parameters

    • pMetadataManager: MetadataManagerInterface
      in
      The [MetadataManagerInterface](../interfaces/MetadataManagerInterface.html) the resulting [DirectorySessionInterface](../interfaces/DirectorySessionInterface.html) will be bound to.
    • pDirectoryUrlOrHost: string
      in
      The url of 3djuump Infinite directory (https://host:443/directory)
      deprecated
      the host of the 3djuump Infinite directory, be it a name or an ip address associated with pDirectoryPath and pDirectoryPort.
    • Optional pDirectoryPath: string
      deprecated
      The path to the directory api (defined by the directory configuration, defaults to "/directory").
    • Optional pDirectoryPort: number
      deprecated
      The port to the https directory api (defaults to 443).

    Returns DirectorySessionInterface

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

    This will trigger the LoginSuccess signal on the tab that called 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/documentation/appinfiniteapi';

    if (window.location.hash)
    {
    // try to decode the authentication hash.
    if (!DirectorySessionFactory.DecodeAuthenticationHash(window.location.hash))
    {
    // output some debug error message.
    console.log('Error: unable to decode hash content of authentication');
    // display error
    const lError: HTMLElement = <HTMLElement>document.getElementById('error');
    lError.textContent = 'Unable to decode hash content of authentication';
    }
    else {
    // everything is fine, the other tab is notified
    // just need to close the tab
    window.close();
    }
    }
    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.

    Returns

    true if the hash was correctly decoded.

    Parameters

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

    Returns boolean