...
Select the SSO provider for your Parent and Child apps. For example, ARX.
Note The procedure is explained by using a sample property file called ARXTicketValidationStatus.properties file as the ARX SSO provider.
This property file contains the following details:
Code Block language bash #Mon Jun 12 11:54:34 IST 2017 STATUS=SUCCESS SHOULDLOGINTOARX=true USERPIN=canvas ARMORTICKET=919874-RO9NL LOGINID=terrim
The SSO provider selected by you will replace this dummy properties file.
- Read the services offered by the SSO provider and select the services that you want for your Parent and Child Apps.
- Create a custom authentication provider by implementing the Java Interface, IAuthenticationServiceProvider.
Mention the authentication provider to Canvas framework by providing a value for the AUTH_SERV_PROV_CLASS key in the securityconfig.properties file.
Here, CTAutoLoginAuthenticationProvider.java is the custom authentication provider file created for the ARX SSO.Code Block language bash # The following key indicates the default authentication provider that is to # be used during log-in, log-out or re-authentication purposes. AUTH_SERV_PROV_CLASS=com.intellectdesign.modelhouse.CTAutoLoginAuthenticationProvider
Note - Refer the CTAutoLoginAuthenticationProvider.java file in the Auto Log-on Feature zip folder for the sample implementation of the ARX SSO.
- You will be using a real SSO provider and therefore, you must properly read and understand the SSO services and consume it accordingly instead of reading and writing the dummy properties file.
- Few changes are required in the Parent and Child Apps' JavaScript files to retrieve and set the armor cookie. Sample codes with respect to the CTAutoLoginAuthenticationProvider.java file and the ARX SSO provider - ARXTicketValidationStatus.properties file is provided for your reference.
- In the Parent App's Hybrid.js file, add the following methods:
getArmorTicket() – This method retrieves the armor cookie from the Parent App for the Parent App server.
Code Block language js function getArmorTicket(armorSuccessCallBack) { cookieMaster.getCookieValue(localStorage.getItem("appUrl"),'ArmorTicket', function(cookie) { armorSuccessCallBack.apply(this, [cookie.cookieValue]); }, function(error) { if(error) { console.log('error: '+ error); } }); }
setArmorTicket() – This method sets the retrieved armor cookie to the Child App server.
Code Block language js function setArmorTicket() { var armorTicket = localStorage.getItem("ArmorTicket"); cookieMaster.setCookieValue(localStorage.getItem("appUrl"),'ArmorTicket', armorTicket, function() { console.log('Armor cookie has been set'); }, function(error) { console.log('Error setting cookie: '+ error); }); }
launchChildApp() – This method launches the Child App.
Code Block language js function launchChildApp() { if(!cbx.isEmpty(iportal.workspace.metadata.getCurrentWorkspaceId())) { localStorage.setItem("Parent_WSID", iportal.workspace.metadata.getCurrentWorkspaceId()); var strUrl ="http://172.19.32.28:9080/ctmodelhouse/"; localStorage.setItem("appUrl", strUrl); setArmorTicket(); window.location ="www/CTHome.html"; } }
- In the Child App's Hybrid.js, add the following methods:
getArmorTicket() - This method retrieves the armor cookie from the Child App for the Child App server.
Code Block language js function getArmorTicket(armorSuccessCallBack) { cookieMaster.getCookieValue(localStorage.getItem("appUrl"),'ArmorTicket', function(cookie) { armorSuccessCallBack.apply(this, [cookie.cookieValue]); }, function(error) { if(error) { console.log('error: '+ error); } }); }
setArmorTicket() - This method sets the retrieved armor cookie to the Parent App server.
Code Block language js function setArmorTicket() { var armorTicket = localStorage.getItem("ArmorTicket"); cookieMaster.setCookieValue(localStorage.getItem("appUrl"),'ArmorTicket', armorTicket, function() { console.log('Armor cookie has been set'); }, function(error) { console.log('Error setting cookie: '+ error); }); }
launchParentApp() - This method launches the Parent App.
Code Block language js function launchParentApp() { var strUrl ="http://172.19.32.38:9080/ctmodelhouse/"; localStorage.setItem("appUrl",strUrl); setArmorTicket(); window.location ="../../www/CTHome.html"; }
- In the Parent App's Hybrid.js file, add the following methods:
...