Interface DirectorySessionInterface

The DirectorySessionInterface is in charge of the authentication of a user to the 3djuump infinite architecture, and the initiation of a connection to a 3djuump infinite proxy.

The DirectorySessionInterface is the formalization of the session to a 3djuump infinite directory.

The 3djuump infinite architecture does not feature an internal authentication procedure, but delegates the authentication to an external authentication server by the use of an openid connect protocol.

There is at the moment only 2 ways to authenticate to the 3djuump infinite directory, by the use of a popup window (getPopupBasedAuthenticationUrl, DecodeAuthenticationHash) or a same page authentication (getSamePageAuthenticationUrl, setTokenFromHash).

  1. With the popup based authentication. The user will see a new tab opened to the authentication server, asking for a user/password, and at the end a redirection to a custom authentication page (e.g. authenticate.html) with a script that calls DecodeAuthenticationHash (see the main page for more information). Depending on your openid configuration, this procedure may be silent for the end-user, with the use of SSO and automatic login. The user may then need to close the authentication tab (or perhaps closed automatically). It is your responsibility to open a new tab (see the code below).
/** 
* Sample to illustrate the popup based authentication mechanism.
*/
import {
InfiniteFactory, MetadataManagerFactory, InfiniteCacheFactory, DirectorySessionFactory,
InfiniteEngineInterface, MetadataManagerInterface, InfiniteCacheInterface, DirectorySessionInterface,
InfiniteEvent, ConnectionData,
DataSessionInterfaceSignal, DirectorySessionInterfaceSignal,
} from 'generated/documentation/appinfiniteapi';

// authentication url as defined in the directory
// authenticate.html must include your authentication script
const sAuthenticationUrl : string = 'https://your_server/your_application/authenticate.html';
const sDirectoryUrl : string = 'https://my_directory:443/directory';

// Create a metadata manager interface
// the MetadataManagerInterface is the central point of your application
// It handles the creation of sets of geometries, search functions etc...
const lMetadataManager: MetadataManagerInterface = MetadataManagerFactory.CreateMetadataManager();

// Create a 3D engine to handle the rendering of the DMU. The engine is optional if you
// just want to search data in the DMU, but required to display 3D data.
// you need to provide a div inside your html file, or create one div programmatically
const lInfiniteEngine: InfiniteEngineInterface = InfiniteFactory.CreateInfiniteEngine(lMetadataManager);
// bind the engine to the given div that will be used for rendering
lInfiniteEngine.setView(<HTMLElement>document.getElementById('rendering'));
// Create a cache to avoid requesting heavy data from the server if data has been retrieved already
const lCache: InfiniteCacheInterface = InfiniteCacheFactory.CreateInfiniteCache();

// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
let authenticate : () => void = undefined;

// Success callback on login
let onLoginSuccess : (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void = undefined;

// Success callback when DataSession is ready
let onDMULoaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void = undefined;

// *****************************************************************************
// ******************************* Authentication ******************************
// *****************************************************************************
// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
authenticate = () : void =>
{
// connect to directory with address sDirectoryAddress, in the folder "/directory" through https. The default port is unchanged (443)
// bind the session to the MetadataManagerInterface
const lDirectorySession: DirectorySessionInterface = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);

// do something when we are connected !!!! => onLoginSuccess
lDirectorySession.addEventListener(DirectorySessionInterfaceSignal.LoginSuccess, onLoginSuccess);

// retrieve the url to contact to begin authentication with popup
// that also starts the authentication procedure
const sURL = lDirectorySession.getPopupBasedAuthenticationUrl(sAuthenticationUrl);
if (typeof sURL === 'string') {
if (sURL !== '' && sURL.indexOf('authenticate') >= 0)
{
// popup based authentication
window.open(sURL);
}
}
}

// Success callback on login
onLoginSuccess = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// Get the Connection Data to get the build lists
const lConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;

// Get the list of projects => do something as you like
const lProjectList = lConnectionData.projects;
for (const lProjectId in lProjectList)
{
// iterate but get the first project
const lBuildList = lProjectList[lProjectId].builds;
for (const lBuild in lBuildList)
{
// iterate but get the first build
// create a datasession that uses the cache with the first item
const lDataSession = (<DirectorySessionInterface>(pEvent.emitter)).createDataSession(lBuild, lCache);
if (lDataSession)
{
// be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
// and go !!! => open the data session
lDataSession.openDataSession();
}
return;
}
}
};

// Success callback when DataSession is ready
onDMULoaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// do something !!!
// create filters
// change visibility
// etc ....
}

authenticate();

2. With the same page authentication. The user will see multiple redirections (the number depending on your openid connect server and its configuration) from the current tab and will be finally redirected to the start page of your application. The last redirect will be done with a hash parameter that contains authentication information. The developer may need to store url parameters in the browser storage to be redirected to the final url (see the main page for more information). The authentication procedure is initiated with [getSamePageAuthenticationUrl](DirectorySessionInterface.html#getSamePageAuthenticationUrl) which should return the redirection url to visit, and then [setTokenFromHash](DirectorySessionInterface.html#setTokenFromHash) on the last redirect. The [setTokenFromHash](DirectorySessionInterface.html#setTokenFromHash) will normally send [LoginSuccess](../enums/DirectorySessionInterfaceSignal.html#LoginSuccess) asynchronously.
/** 
* Sample to illustrate the same page authentication mechanism.
*/
import {
InfiniteFactory, MetadataManagerFactory, InfiniteCacheFactory, DirectorySessionFactory,
InfiniteEngineInterface, MetadataManagerInterface, InfiniteCacheInterface, DirectorySessionInterface,
InfiniteEvent, ConnectionData,
DataSessionInterfaceSignal, DirectorySessionInterfaceSignal,
} from 'generated/documentation/appinfiniteapi';

// the current page (without url parameters) should be registered as authentication url in the directory
const sDirectoryUrl : string = 'https://my_directory:443/directory';

// Create a metadata manager interface
// the MetadataManagerInterface is the central point of your application
// It handles the creation of sets of geometries, search functions etc...
const lMetadataManager: MetadataManagerInterface = MetadataManagerFactory.CreateMetadataManager();
let lInfiniteEngine: InfiniteEngineInterface | undefined = undefined;
let lCache: InfiniteCacheInterface | undefined = undefined;
// bind the session to the MetadataManagerInterface
let lDirectorySession: DirectorySessionInterface | undefined = undefined;

// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
let authenticate : () => void = undefined;

// Checks if the url has an hash in order to authenticate
let checkHash : () => void = undefined;

// Success callback on login
let onLoginSuccess : (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// Success callback when DataSession is ready
let onDMULoaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

// *****************************************************************************
// ******************************* Authentication ******************************
// *****************************************************************************
// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
authenticate = () : void =>
{
// if we have a hash, do not request a new authentication
if (window.location.hash.length > 0)
{
// perhaps some GUI code there
return;
}
// connect to directory with address sDirectoryAddress, in the folder "/directory" through https. The default port is unchanged (443)
// bind the session to the MetadataManagerInterface
lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);

// redirect url is the current url without query parameters
// the directory needs a full url (with query parameters if needed), so we recommend to
// register the url without parameters, use this url as authentication, store the url parameters if present
// and then redirect to the "final url" (see checkHash)
const sRedirectUrl : string = window.location.origin + window.location.pathname;
if (window.location.href.indexOf('?') >= 0)
{
// store the url with query parameters in session storage
// we will finally redirect to this url
window.sessionStorage.setItem('redirecturl', window.location.href.split('#')[0]);
}
const sURL = lDirectorySession.getSamePageAuthenticationUrl(sRedirectUrl);
if (typeof sURL === 'string')
{
// navigate to the given url for authentication
window.location.href = sURL;
}
else
{
console.log('Error not expected !!! ' + sURL);
window.sessionStorage.removeItem('redirecturl');
}
}

// Checks if the url has an hash in order to authenticate
checkHash = () : void =>
{
const lHash : string = window.location.hash;
if (lHash.length === 0)
{
// do not bother if no hash
return;
}
// we may here put some GUI code

// here we can check if the url has query parameters
const lSessionItem : string | null = window.sessionStorage.getItem('redirecturl');
if (lSessionItem)
{
// we have a redirect url
// remove it from storage in order to avoid infinite redirections
window.sessionStorage.removeItem('redirecturl');
// navigate to this url with hash
window.location.replace(lSessionItem + lHash);
}
else
{
// remove hash with some fancy methods
if (window.history.replaceState)
{
const uri : string = window.location.toString();
const cleanUri : string = uri.substring(0, uri.indexOf('#'));
window.history.replaceState({}, document.title, cleanUri);
}
else
{
window.location.hash = '';
}

// bind the session to the MetadataManagerInterface
lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);
// do something when we are connected !!!! => onLoginSuccess
lDirectorySession.addEventListener(DirectorySessionInterfaceSignal.LoginSuccess, onLoginSuccess);
// and end authentication
lDirectorySession.setTokenFromHash(lHash);
}
}

// Success callback on login
onLoginSuccess = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// Create a 3D engine to handle the rendering of the DMU. The engine is optional if you
// just want to search data in the DMU, but required to display 3D data.
// you need to provide a div inside your html file, or create one div programmatically
lInfiniteEngine = InfiniteFactory.CreateInfiniteEngine(lMetadataManager);
// bind the engine to the given div that will be used for rendering
lInfiniteEngine.setView(<HTMLElement>document.getElementById('rendering'));
// Create a cache to avoid requesting heavy data from the server if data has been retrieved already
lCache = InfiniteCacheFactory.CreateInfiniteCache();
// Get the Connection Data to get the build lists
const lConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;

// Get the list of projects => do something as you like
const lProjectList = lConnectionData.projects;
for (const lProjectId in lProjectList)
{
// iterate but get the first project
const lBuildList = lProjectList[lProjectId].builds;
for (const lBuild in lBuildList)
{
// iterate but get the first build
// create a datasession that uses the cache with the first item
const lDataSession = (<DirectorySessionInterface>(pEvent.emitter)).createDataSession(lBuild, lCache);
if (lDataSession)
{
// be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
// and go !!! => open the data session
lDataSession.openDataSession();
}
return;
}
}
};

// Success callback when DataSession is ready
onDMULoaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
{
// do something !!!
// create filters
// change visibility
// etc ....
}

// we may launch an authentication procedure (or from a button)
authenticate();

// check hash if we should validate the authentication
checkHash();

Upon a successful connection, user access rights are retrieved asynchronously with the connection to the [LoginSuccess](../enums/DirectorySessionInterfaceSignal.html#LoginSuccess) signal. User access rights are formalized with the [ConnectionData](ConnectionData.html) object, that contains the list of tags, teams attached to this user, and also the available builds/projects for this user. You can force the refreshing of this information with a call to [refreshAccessRightsInfo](DirectorySessionInterface.html#refreshAccessRightsInfo).

The DirectorySessionInterface is the factory to a DataSessionInterface that allows to choose a specific proxy to connect to, and begin downloading / initializing data.

/** 
* Sample to illustrate the use of the the choice of a proxy for the open data procedure (DataSessionInterface).
*/
import {
tChooseProxyCallback, ProxyChoiceInterface, tSetProxyCallback, InfiniteCacheInterface,
DirectorySessionInterface, DataSessionInterface, DataSessionInterfaceSignal, tListenerCallback
} from 'generated/documentation/appinfiniteapi';

// lDirectorySession has been created previously, the user is now logged in and knows the 3djuump infinite available builds.
let lDirectorySession : DirectorySessionInterface;
// lInfiniteCache may has been created previously (not required)
let lInfiniteCache : InfiniteCacheInterface | undefined;
// the build id to connect to
let lBuildId : string;
// the callback that will be called when the DMU has finished loading
let myDMULoadedCallback : tListenerCallback;

// very simple callback, choose the first available proxy
const lChooseProxyCallback : tChooseProxyCallback = (pProxies: Array<ProxyChoiceInterface>, pFinishLoadingCallback : tSetProxyCallback) : void =>
{
let i : number;
const lLength : number = pProxies.length;
// output all proxies
for (i = 0; i < lLength; ++i)
{
console.log(pProxies[0].getLabel());
}
// DO NOT forget to call pFinishLoadingCallback, if not, the DMU loading process will never finish
// and with the url of the chosen proxy
pFinishLoadingCallback(pProxies[0].getUrl());
}

// connect the data session to the build, the proxy choice is asynchronous, and will
// trigger lChooseProxyCallback when the dev chooses a proxy
const lDataSession : DataSessionInterface | undefined = lDirectorySession.createDataSession(lBuildId, lInfiniteCache, lChooseProxyCallback);
if (!lDataSession)
{
console.log('something weird happened, the directory session cannot create a data session');
console.log('Perhaps the directory session is already closed, or closing, or the login procedure failed');
}
else
{
// we sure want to be notified when the DMU has finished loading
lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, myDMULoadedCallback);

// and GO => open the data session
if (!lDataSession.openDataSession())
{
console.log('something weird happened, this session has already been used, this is not a freshly created one');
}

// and wait for myDMULoadedCallback to be called
}

Please see [DataSessionInterface](DataSessionInterface.html) for more explanations about sessions.
Sessions

See

Hierarchy

Methods

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal. It is possible to add an object that will be included in the callback to avoid creating too many closures.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.
    • pObject: undefined | Object
      in
      The optional object the callback will be called with when the given event fires.

    Returns string

  • Adds a listener to an event type.

    When an event of the type pType fires, the callback pListener will be called. This function returns a unique string id that may be used in removeEventListenerById to allow simple listener removal.

    Returns

    The id of the inserted callback (actually an UUID).

    Parameters

    • pType: string
      in
      The type of the event pListener will be called upon.
    • pListener: tListenerCallback
      in
      The listener function that fires when the given event type occurs.

    Returns string

  • Asynchronous - Sends a close request concerning the current authentication session on the directory.

    This will also revoke all the DataSessionInterface that were created from this directory session. The DataSessionClosed signal may be sent after a while on the given DataSessionInterface, since DataSessionInterface objects are autonomous and will discover the closing of their session on their own.

    If pForceAuthentication is set to true, SSO configuration will be flushed, forcing the user to reconnect on the next call to getPopupBasedAuthenticationUrl or getSamePageAuthenticationUrl. If pForceAuthentication is set to false, SSO configuration will be kept leading to, depending on your openid configuration, a silent and automatic connection on the next call to getPopupBasedAuthenticationUrl or getSamePageAuthenticationUrl.

    If the user is not authenticated, this function does nothing and the waiting time is 0.

    When the directory session is effectively closed, the promise is resolved.

    Returns

    A promise.

    Parameters

    • pForceAuthentication: boolean
      in
      If true the next call to [getPopupBasedAuthenticationUrl](DirectorySessionInterface.html#getPopupBasedAuthenticationUrl) or [getSamePageAuthenticationUrl](DirectorySessionInterface.html#getSamePageAuthenticationUrl) will ask the user to re-authenticate.

    Returns Promise<void>

  • Sends a close request concerning the current authentication session on the directory.

    This will also revoke all the DataSessionInterface that were created from this directory session. The DataSessionClosed signal may be sent after a while on the given DataSessionInterface, since DataSessionInterface objects are autonomous and will discover the closing of their session on their own.

    If pForceAuthentication is set to true, SSO configuration will be flushed, forcing the user to reconnect on the next call to getPopupBasedAuthenticationUrl or getSamePageAuthenticationUrl. If pForceAuthentication is set to false, SSO configuration will be kept leading to, depending on your openid configuration, a silent and automatic connection on the next call to getPopupBasedAuthenticationUrl or getSamePageAuthenticationUrl.

    If the user is not authenticated, this function does nothing.

    See

    DataSessionInterface

    Parameters

    • pForceAuthentication: boolean
      in
      If true the next call to [getPopupBasedAuthenticationUrl](DirectorySessionInterface.html#getPopupBasedAuthenticationUrl) or [getSamePageAuthenticationUrl](DirectorySessionInterface.html#getSamePageAuthenticationUrl) will ask the user to re-authenticate.

    Returns void

  • Creates a data session concerning the given build id, with the given cache and the choose proxy callback.

    open data session sequence
    Please refer to [DataSessionInterface](DataSessionInterface.html) for more information about sessions.

    Returns

    The newly data session or undefined if the DirectorySessionInterface is not authenticated to the directory.

    See

    DataSessionInterface

    Parameters

    • pBuildId: string
      in
      The build id to connect to.
    • pCache: undefined | InfiniteCacheInterface
      in
      The optional cache to use to speed up data retrieving (if relevant), may be undefined.
    • pCallback: undefined | tChooseProxyCallback
      in
      The choose proxy callback to use to elect a specific proxy.

    Returns undefined | DataSessionInterface

  • Creates a data session concerning the given build id, with the given cache.

    open data session sequence
    The first proxy will be elected for the connection since no tChooseProxyCallback has been specified.

    Returns

    The newly data session or undefined if the DirectorySessionInterface is not authenticated to the directory.

    See

    DataSessionInterface

    Parameters

    • pBuildId: string
      in
      The build id to connect to.
    • pCache: undefined | InfiniteCacheInterface
      in
      The optional cache to use to speed up data retrieving (if relevant), may be undefined.

    Returns undefined | DataSessionInterface

  • Gets the URL to the 3djuump infinite directory API.

    It is https://pDirectoryHost:pDirectoryPort/pDirectoryPath/ which was set by the factory CreateDirectorySession.

    Returns

    The URL string of the directory API.

    Returns string

  • Gets the infinite token of the current directory session authentication.

    Any http request to the directory should have the header x-infinite-bearer : <DirectorySessionInterface.getAuthenticationBearer()>.

    If the directory session is not connected, returns an empty string.

    Returns

    The infinite token.

    Returns string

  • Gets the Bearer of the current http directory session authentication.

    Any http request to the directory should have the header Authorization : Bearer <DirectorySessionInterface.getHttpBearer()>.

    If the directory session is not connected, returns an empty string.

    Returns

    The Bearer of the http authentication.

    Returns string

  • Opens a new authentication session on the directory with the pop up mechanism, asking the user to authenticate.

    A new tab is not opened by this function, the user will have to call window.open(getPopupBasedAuthenticationUrl()). Depending on your openid connect configuration, this may be a silent procedure for the user. This function makes use of the localStorage of the browser internally.

    This function may return a string if successful, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession if an internal error occurred (unlikely) and EmptyCallbackURI if pRedirectURI is an empty string.

    /** 
    * Sample to illustrate the popup based authentication mechanism.
    */
    import {
    InfiniteFactory, MetadataManagerFactory, InfiniteCacheFactory, DirectorySessionFactory,
    InfiniteEngineInterface, MetadataManagerInterface, InfiniteCacheInterface, DirectorySessionInterface,
    InfiniteEvent, ConnectionData,
    DataSessionInterfaceSignal, DirectorySessionInterfaceSignal,
    } from 'generated/documentation/appinfiniteapi';

    // authentication url as defined in the directory
    // authenticate.html must include your authentication script
    const sAuthenticationUrl : string = 'https://your_server/your_application/authenticate.html';
    const sDirectoryUrl : string = 'https://my_directory:443/directory';

    // Create a metadata manager interface
    // the MetadataManagerInterface is the central point of your application
    // It handles the creation of sets of geometries, search functions etc...
    const lMetadataManager: MetadataManagerInterface = MetadataManagerFactory.CreateMetadataManager();

    // Create a 3D engine to handle the rendering of the DMU. The engine is optional if you
    // just want to search data in the DMU, but required to display 3D data.
    // you need to provide a div inside your html file, or create one div programmatically
    const lInfiniteEngine: InfiniteEngineInterface = InfiniteFactory.CreateInfiniteEngine(lMetadataManager);
    // bind the engine to the given div that will be used for rendering
    lInfiniteEngine.setView(<HTMLElement>document.getElementById('rendering'));
    // Create a cache to avoid requesting heavy data from the server if data has been retrieved already
    const lCache: InfiniteCacheInterface = InfiniteCacheFactory.CreateInfiniteCache();

    // what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
    let authenticate : () => void = undefined;

    // Success callback on login
    let onLoginSuccess : (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void = undefined;

    // Success callback when DataSession is ready
    let onDMULoaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void = undefined;

    // *****************************************************************************
    // ******************************* Authentication ******************************
    // *****************************************************************************
    // what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
    authenticate = () : void =>
    {
    // connect to directory with address sDirectoryAddress, in the folder "/directory" through https. The default port is unchanged (443)
    // bind the session to the MetadataManagerInterface
    const lDirectorySession: DirectorySessionInterface = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);

    // do something when we are connected !!!! => onLoginSuccess
    lDirectorySession.addEventListener(DirectorySessionInterfaceSignal.LoginSuccess, onLoginSuccess);

    // retrieve the url to contact to begin authentication with popup
    // that also starts the authentication procedure
    const sURL = lDirectorySession.getPopupBasedAuthenticationUrl(sAuthenticationUrl);
    if (typeof sURL === 'string') {
    if (sURL !== '' && sURL.indexOf('authenticate') >= 0)
    {
    // popup based authentication
    window.open(sURL);
    }
    }
    }

    // Success callback on login
    onLoginSuccess = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
    {
    // Get the Connection Data to get the build lists
    const lConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;

    // Get the list of projects => do something as you like
    const lProjectList = lConnectionData.projects;
    for (const lProjectId in lProjectList)
    {
    // iterate but get the first project
    const lBuildList = lProjectList[lProjectId].builds;
    for (const lBuild in lBuildList)
    {
    // iterate but get the first build
    // create a datasession that uses the cache with the first item
    const lDataSession = (<DirectorySessionInterface>(pEvent.emitter)).createDataSession(lBuild, lCache);
    if (lDataSession)
    {
    // be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
    lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
    // and go !!! => open the data session
    lDataSession.openDataSession();
    }
    return;
    }
    }
    };

    // Success callback when DataSession is ready
    onDMULoaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
    {
    // do something !!!
    // create filters
    // change visibility
    // etc ....
    }

    authenticate();

    See the main page for more information.

    Returns

    The authentication URL to visit to start the authentication procedure if successful, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession if an internal error occurred and EmptyCallbackURI if pRedirectURI is an empty string.

    Parameters

    • pRedirectURI: string
      in
      The redirect url where the authentication server should redirect on the completion of the authentication procedure (successful or not). An empty string will result in an error.
    • Optional pAppClaims: string[]
      in
      An array of application claims that may be used to validate queries on third party servers. Third party servers may validate some requests and look for the application claims to satisfy or reject the request.
    • Optional pNeedExtendedBearer: boolean
      in
      If set to `true`, the access token will contain additional information (subid, teams, etc ...) (defaults to false).

    Returns string | AuthenticationGetURLResult

  • Opens a new authentication session on the directory with the same page mechanism, asking the user to authenticate.

    Depending on your openid connect configuration, this may be a silent procedure for the user.

    This function may return a string if successful, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession if an internal error occurred (unlikely) and EmptyCallbackURI if pRedirectURI is an empty string.

    /** 
    * Sample to illustrate the same page authentication mechanism.
    */
    import {
    InfiniteFactory, MetadataManagerFactory, InfiniteCacheFactory, DirectorySessionFactory,
    InfiniteEngineInterface, MetadataManagerInterface, InfiniteCacheInterface, DirectorySessionInterface,
    InfiniteEvent, ConnectionData,
    DataSessionInterfaceSignal, DirectorySessionInterfaceSignal,
    } from 'generated/documentation/appinfiniteapi';

    // the current page (without url parameters) should be registered as authentication url in the directory
    const sDirectoryUrl : string = 'https://my_directory:443/directory';

    // Create a metadata manager interface
    // the MetadataManagerInterface is the central point of your application
    // It handles the creation of sets of geometries, search functions etc...
    const lMetadataManager: MetadataManagerInterface = MetadataManagerFactory.CreateMetadataManager();
    let lInfiniteEngine: InfiniteEngineInterface | undefined = undefined;
    let lCache: InfiniteCacheInterface | undefined = undefined;
    // bind the session to the MetadataManagerInterface
    let lDirectorySession: DirectorySessionInterface | undefined = undefined;

    // what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
    let authenticate : () => void = undefined;

    // Checks if the url has an hash in order to authenticate
    let checkHash : () => void = undefined;

    // Success callback on login
    let onLoginSuccess : (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

    // Success callback when DataSession is ready
    let onDMULoaded : (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) => void;

    // *****************************************************************************
    // ******************************* Authentication ******************************
    // *****************************************************************************
    // what to do to authenticate (authenticate function may be bound to a div `click` or called straight away)
    authenticate = () : void =>
    {
    // if we have a hash, do not request a new authentication
    if (window.location.hash.length > 0)
    {
    // perhaps some GUI code there
    return;
    }
    // connect to directory with address sDirectoryAddress, in the folder "/directory" through https. The default port is unchanged (443)
    // bind the session to the MetadataManagerInterface
    lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);

    // redirect url is the current url without query parameters
    // the directory needs a full url (with query parameters if needed), so we recommend to
    // register the url without parameters, use this url as authentication, store the url parameters if present
    // and then redirect to the "final url" (see checkHash)
    const sRedirectUrl : string = window.location.origin + window.location.pathname;
    if (window.location.href.indexOf('?') >= 0)
    {
    // store the url with query parameters in session storage
    // we will finally redirect to this url
    window.sessionStorage.setItem('redirecturl', window.location.href.split('#')[0]);
    }
    const sURL = lDirectorySession.getSamePageAuthenticationUrl(sRedirectUrl);
    if (typeof sURL === 'string')
    {
    // navigate to the given url for authentication
    window.location.href = sURL;
    }
    else
    {
    console.log('Error not expected !!! ' + sURL);
    window.sessionStorage.removeItem('redirecturl');
    }
    }

    // Checks if the url has an hash in order to authenticate
    checkHash = () : void =>
    {
    const lHash : string = window.location.hash;
    if (lHash.length === 0)
    {
    // do not bother if no hash
    return;
    }
    // we may here put some GUI code

    // here we can check if the url has query parameters
    const lSessionItem : string | null = window.sessionStorage.getItem('redirecturl');
    if (lSessionItem)
    {
    // we have a redirect url
    // remove it from storage in order to avoid infinite redirections
    window.sessionStorage.removeItem('redirecturl');
    // navigate to this url with hash
    window.location.replace(lSessionItem + lHash);
    }
    else
    {
    // remove hash with some fancy methods
    if (window.history.replaceState)
    {
    const uri : string = window.location.toString();
    const cleanUri : string = uri.substring(0, uri.indexOf('#'));
    window.history.replaceState({}, document.title, cleanUri);
    }
    else
    {
    window.location.hash = '';
    }

    // bind the session to the MetadataManagerInterface
    lDirectorySession = DirectorySessionFactory.CreateDirectorySession(lMetadataManager, sDirectoryUrl);
    // do something when we are connected !!!! => onLoginSuccess
    lDirectorySession.addEventListener(DirectorySessionInterfaceSignal.LoginSuccess, onLoginSuccess);
    // and end authentication
    lDirectorySession.setTokenFromHash(lHash);
    }
    }

    // Success callback on login
    onLoginSuccess = (pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
    {
    // Create a 3D engine to handle the rendering of the DMU. The engine is optional if you
    // just want to search data in the DMU, but required to display 3D data.
    // you need to provide a div inside your html file, or create one div programmatically
    lInfiniteEngine = InfiniteFactory.CreateInfiniteEngine(lMetadataManager);
    // bind the engine to the given div that will be used for rendering
    lInfiniteEngine.setView(<HTMLElement>document.getElementById('rendering'));
    // Create a cache to avoid requesting heavy data from the server if data has been retrieved already
    lCache = InfiniteCacheFactory.CreateInfiniteCache();
    // Get the Connection Data to get the build lists
    const lConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;

    // Get the list of projects => do something as you like
    const lProjectList = lConnectionData.projects;
    for (const lProjectId in lProjectList)
    {
    // iterate but get the first project
    const lBuildList = lProjectList[lProjectId].builds;
    for (const lBuild in lBuildList)
    {
    // iterate but get the first build
    // create a datasession that uses the cache with the first item
    const lDataSession = (<DirectorySessionInterface>(pEvent.emitter)).createDataSession(lBuild, lCache);
    if (lDataSession)
    {
    // be ready to do something when build is ready (i.e. all init data has been parsed and server is ready)
    lDataSession.addEventListener(DataSessionInterfaceSignal.DMULoadingSuccess, onDMULoaded);
    // and go !!! => open the data session
    lDataSession.openDataSession();
    }
    return;
    }
    }
    };

    // Success callback when DataSession is ready
    onDMULoaded = (_pEvent: InfiniteEvent, _pCallbackData: Object | undefined) : void =>
    {
    // do something !!!
    // create filters
    // change visibility
    // etc ....
    }

    // we may launch an authentication procedure (or from a button)
    authenticate();

    // check hash if we should validate the authentication
    checkHash();

    See the main page for more information.

    Returns

    The authentication URL to visit to start the authentication procedure if successful, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession if an internal error occurred and EmptyCallbackURI if pRedirectURI is an empty string.

    Parameters

    • pRedirectURI: string
      in
      The redirect url where the authentication server should redirect on the completion of the authentication procedure (successful or not). An empty string will result in an error.
    • Optional pAppClaims: string[]
      in
      An array of application claims that may be used to validate queries on third party servers. Third party servers may validate some requests and look for the application claims to satisfy or reject the request.
    • Optional pNeedExtendedBearer: boolean
      in
      If set to `true`, the access token will contain additional information (subid, teams, etc ...) (defaults to false).

    Returns string | AuthenticationGetURLResult

  • Gets a copy of the user information (name, initials and picture URL).

    If the authentication has not been performed, all fields are set to empty strings.

    Returns

    The UserData containing the name (string) the initials (string) and the picture url (string) of the logged-in user.

    See

    UserData

    Returns UserData

  • Tells if the EventDispatcher has such a callback registered for the given event type.

    Returns

    true if such a listener is installed for the given type of event.

    Parameters

    • pType: string
      in
      The type of the event to test.
    • pListener: tListenerCallback
      in
      The listener function that gets tested.

    Returns boolean

  • Tells if the user is authenticated.

    Returns

    true if the user is authenticated.

    Returns boolean

  • Requests an asynchronous refresh of the access rights on the current directory session (build list, projects, report info, tags, teams).

    Access rights information is available after a successful login (from attachments of LoginSuccess) but they can be updated during the session life.

    The asynchronous request will trigger the signals AccessRightsRefreshed or AccessRightsRefreshFailed according to the request resolution.

    Returns

    false if the user is not logged-in.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    • pObject: undefined | Object

      The listener object that was used when addEventListener was called.

    Returns boolean

  • Removes a listener from an event type.

    If no such listener is found, then the function returns false and does nothing. You must use the exact parameters that were used in addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pType: string
      in
      The type of the listener that gets removed.
    • pListener: tListenerCallback

      The listener function that gets removed.

    Returns boolean

  • Removes a listener by its id.

    If no such listener is found, then the function returns false and does nothing. You must use the return value of addEventListener to actually remove the listener.

    Returns

    true if the callback was removed else false.

    Parameters

    • pId: string
      in
      The id returned by the call to [addEventListener](DirectorySessionInterface.html#addEventListener) that you want to remove.

    Returns boolean