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.
The id of the inserted callback (actually an UUID).
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.
The id of the inserted callback (actually an UUID).
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.
A promise.
Asynchronous - Requests a 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 AsyncDirectorySessionRefreshAccessRightsReason of the AsyncDirectorySessionWaitForRefreshAccessRightsResult may be :
A promise with the result of the access rights reason.
Waits for the popup authentication to complete.
The AsyncDirectorySessionWaitForLoadedResultReason of the AsyncDirectorySessionWaitForLoadedResult may be :
A promise.
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.
Creates a data session concerning the given build id, with the given cache and the choose proxy callback.
The newly data session or undefined if the DirectorySessionInterface is not authenticated to the directory.
Creates a data session concerning the given build id, with the given cache.
The newly data session or undefined if the DirectorySessionInterface is not authenticated to the directory.
Gets rid of this object.
After this call, this object can no longer be used.
If the object is an InfiniteObjectDispatcherInterface, then the ObjectDisposed signal is emitted.
Further uses of the object (with the exception of isDisposed and getInfiniteObjectType) will log a message with LL_UsingDisposedObject.
Gets the URL to the 3djuump infinite directory API.
It is https://pDirectoryHost:pDirectoryPort/pDirectoryPath/ which was set by the factory CreateDirectorySession.
The URL string of the directory API.
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.
The infinite token.
Gets the current token hash that may be used to reconnect the directory in case of a page refresh, skipping authentication.
Such a hash may be stored within the storage api of the browser and used with setTokenFromHash.
If the DirectorySessionInterface is not connected, an empty string is returned. If the given DirectorySessionInterface is closed and the hash is used on another DirectorySessionInterface, the setTokenFromHash procedure will fail and LoginFailed will be called.
The current token hash.
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.
The Bearer of the http authentication.
Tells the type of the given interface.
The type of the given interface.
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();
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.
Optional pAppClaims: string[]Optional pNeedExtendedBearer: booleanOpens 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();
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.
Optional pAppClaims: string[]Optional pNeedExtendedBearer: booleanGets 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.
The UserData containing the name (string) the initials (string) and the picture url (string) of the logged-in user.
Tells if the EventDispatcher has such a callback registered for the given event type.
true if such a listener is installed for the given type of event.
Tells if this object has been gotten rid off.
true if dispose has been called on this object.
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.
false if the user is not logged-in.
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.
true if the callback was removed else false.
The listener function that gets removed.
The listener object that was used when addEventListener was called.
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.
true if the callback was removed else false.
The listener function that gets removed.
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.
true if the callback was removed else false.
Decodes the hash content and sets the decoded content as session information. If the session content is valid, the life of the session is resumed. This function will fire LoginSuccess or LoginFailed depending on the success of the procedure.
Please note that time information is included in the hash, preventing it from being used after some time. The validity period is set by the 3djuump infinite directory.
This function may return AuthenticationPending if the authentication mechanism is pending, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession is an internal error occurred and InvalidHash is the hash is invalid.
The result of the procedure AuthenticationPending if the authentication mechanism is pending, DoNotReAuthenticate if the DirectorySessionInterface is already connected, InvalidSession is an internal error occurred and InvalidHash is the hash is invalid.
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).
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).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.
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.
Please see [DataSessionInterface](DataSessionInterface.html) for more explanations about sessions.
See