/** * 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 constsAuthenticationUrl : string = 'https://your_server/your_application/authenticate.html'; constsDirectoryUrl : 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... constlMetadataManager: 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 constlInfiniteEngine: 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 constlCache: InfiniteCacheInterface = InfiniteCacheFactory.CreateInfiniteCache();
// what to do to authenticate (authenticate function may be bound to a div `click` or called straight away) letauthenticate : () =>void = undefined;
// Success callback when DataSession is ready letonDMULoaded : (_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 constlDirectorySession: 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 constsURL = lDirectorySession.getPopupBasedAuthenticationUrl(sAuthenticationUrl); if (typeofsURL === '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 constlConnectionData: ConnectionData = <ConnectionData>pEvent.attachments;
// Get the list of projects => do something as you like constlProjectList = lConnectionData.projects; for (constlProjectIdinlProjectList) { // iterate but get the first project constlBuildList = lProjectList[lProjectId].builds; for (constlBuildinlBuildList) { // iterate but get the first build // create a datasession that uses the cache with the first item constlDataSession = (<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; } } };
This factory is used to create the MetadataManagerInterface.
The MetadataManagerInterface is the central point to connect to a 3djuump infinite build.
Connecting to a 3djuump infinite build involves :
At any time, the MetadataManagerInterface can only be connected to a single DirectorySessionInterface, DataSessionInterface and InfiniteEngineInterface, but the same MetadataManagerInterface may be used to connect to a new DataSessionInterface after the preceding has been closed.
Please refer to Authentication Samples.
See
MetadataManagerInterface