Intellicus Enterprise Reporting and Business Insights 19.1

SSO for Host Application on PHP Platform

0 views June 1, 2020 0

Configurations Required

Configuring Host Application

In order to invoke methods at Intellicus end, the file intellicaSSO.php needs to be placed in host application’s library.

This file will be provided with intellicus setup.

Path for the file: <Install_Path>/APIs/SingleSignOn/PHP

Note: For Intellicus version earlier than 4.1, this php can be requested to Intellicus Support.

Host application needs to set Intellicus web application URL.

Configuring Intellicus

Intellicus application contains Integration.xml file for integration and dynamic user creation activities.

  • In Integration.xml, set business parameters required to pass (If any)
  • Set CREATE_USER for Dynamic User creation in Intellicus.

This xml file contains the information regarding integration like user role, dynamic category creation etc.

Path for Integration.xml:

<Intellicus_Install_path>/Jakarta/webapps/intellicus/WEB-INF

Note: Host application needs to give details in xml according to their requirements.

Corresponding to this integration xml file content, createUser() method in ReportControllerDetails.JSP at the Intellicus end should be defined.

Sample Integration xml and Controller jsp are provided with the Intellicus Setup.

Note: For Intellicus version earlier than 4.1, ReportController.jsp,ReportController.Detail.jsp,LaunchPortal.jsp  can be requested to Intellicus Support and should be placed at  <Intellicus_install_path>/Jakarta/webapps/intellicus

Implementation for Single Sign-On Request

Implementation code can be written inside any php or html file of Host application.

  1. Host application needs to add intellicaSSO.php in their application.

Host application file needs to include file intellicaSSO.php

include_once(“intellicaSSO.php”);

Make an object of SingleSignOn class for invoking the methods of this class.

Make an object of UserInfo class and set the user credentials using the setter methods provided by UserInfo class.

Pass this userInfo object to SingleSignOn class using the setUserInfo (userInfo) method.

public function setUserInfo($userInfo)

Parameters:

UserInfo:  Object reference of UserInfo class.

Set the IntellicusUrl.  Intellicus url can be read from property file.

If host application wants to set some hidden parameters, then invoke the setHiddenParameter ($paramName, $paramValue) for each hidden parameter.

These parameters can be read from property/xml file.

Method:

This method puts the hidden parameter into the array for hidden parameters.

public function setHiddenParameter($paramName,$paramValue)

Parameters:

paramName: Name of the business parameter

paramValue: Value of the business parameter.

Note: This method would be called before calling, the getIntellicusToken method. User can not change/update the parameters set through this method. If these parameters need to be changed, then host application need to request intellicusToken again in order to consider new value for these parameters.

Check for the Intellicus Token availability in session. If its not available in session then call the getIntellicusToken() method of SingleSignOn class.

Method:

This method calls Intellicus API and passes the user credentials and other hidden/business/request parameters to Intellicus.

public function getIntellicusToken()

Returns:

TokenString:  Received token from Intellicus

If host application gets the token from Intellicus, then it redirects the request to Intellicus redirectionAPI with token.

Host Application can set the name of redirectionAPI. Its default value is “LaunchPortal.jsp”.

Method:

This method sets the name of Intellicus jsp to which request is redirected.

public function setRedirectionAPI($redirectionAPI)

Parameters:

redirectionAPI: Name of the jsp at Intellicus end to which host application wants to redirect the request after user authentication

If host application wants to set some other business parameters, then invoke the setBusinessParameter ($ paramName, $paramValue) for each such parameter.

These parameters can be read from property, xml file.

Method:

This method puts the business parameter into the array for request parameters.

public function setBusinessParameter($paramName,$paramValue)

Parameters:

paramName:  Name of the request parameter.

paramValue: value of the request parameter.

Note: This method should be called before calling, the redirectToIntellicus method. Parameters set in this method can be updated without requesting new token.

After setting the name of the redirectionAPI, invoke the method for redirecting the request to Intellicus.

Method:

This method sets the name of Intellicus jsp to which request is redirected.

public function redirectToIntellicus($onSuccess,$ intellicusToken)

Parameters:

onSuccess:  Name of the requested Intellicus API.

intellicusToken: Token received from Intellicus after user authentication.

If host application does not get the token from intellicus i.e. if user authentication fails at Intellicus end, then host application can show their error page or error message based on the status message returned by the Intellicus.

Setter method for each UserInfo attributes
  1. Method to set the User id

public function setUserId ($userId)

Parameters:

userId:  User id.

  1. Method to set the User Password

public function setPassword ($password)

Parameters:

password:  password for the user.

  1. Method to set the User’s Organization id

public function setOrgID ($orgID)

Parameters:

orgID: organization id for the user.

  1. Method to set session id

public function setSessionId ($sessionId)

Parameters:

sessionId:  session id for the user.

  1. Method to set Security Descriptor

public function setSecurityDescriptor ($securityDescriptor)

Parameters:

securityDescriptor:  any specific information about the user.

  1. Method to set customer Id

public function setCustomerId ($customerId)

Parameters:

customerId:  customer id for the user.

  1. Method to set location

public function setLocation ($location)

Parameters:

location:  location for the user.

  1. Method to set locale

public function setLocaleForIntellicus ($locale)

Parameters:

locale:  locale for the user.

  1. Method to set database name

public function setDBName ($dbName)

Parameters:

dbName:  Database name for the user.

  1. Method to set TimeStamp

public function setTimeStamp($longTimeStamp)

Parameters:

longTimeStamp:  timestamp for the user.

  1. Method to set the User’s status(ACTIVE / SUSPENDED)

public function setStatus ($status)

Parameters:

status:  status of the user i.e. user is active or suspended.

  1. Method to set the user to Super Admin(“true”/”false”)

public function setIsSuperAdmin ($isSuperAdmin)

Parameters:

isSuperAdmin:  Whether user is Super admin or not.

  1. Method to set the user to Admin(“true”/”false”)

public function setIsAdmin ($isAdmin)

Parameters:

isAdmin:  Whether user is admin or not.

  1. Method to set role Id’s belonging to that user

public function setRoleIds ($roleIds)

Parameters:

roleIds:  Role that should be assigned to this user.

  1. Method to set User’s Description

public function setDescription ($description)

  1. Method to set System Privileges

public function setSystemPrivileges($systemPrivileges)

Parameters:

systemPrivileges:  system privileges for a user.

  1. Method to set blank password

public function setBlankPassword($blankPassword)

Parameters:

blankPassword:  it is true or false.

Note: Please refer IntellicusSSOEnduserRequest.php for end user request sample code.

Path: <Install_Path>SampleCodesSingleSignOnPHP

Note: Please refer IntellicusSSOLogout.php for logout sample code.

Path: <Install_Path>SampleCodesSingleSignOnPHP

Optional Settings

Controller API

This is the main controller for the integration of Intellicus with a host application.  It reads information from Integration.xml and sets hidden parameters (like domain ID and workspace ID) at Intellicus end.

Default name of this api is: ReportController.jsp and ReportControllerDetail.jsp

If required, name of this API can be changed.

To call this API using different name than default names, you need to use method given below.

Method:

This method sets the name of Intellicus jsp to which request is redirected.

public function setIntellicusControllerAPI ($intellicusControllerAPI)

Parameters:

intellicusControllerAPI: Name of the jsp at Intellicus which performs controlling activities for Intellicus.

This controller API is placed at:

<Intellicus_Install_path>Jakartawebappsintellicus

Redirection API

It is the API available at Intellicus end to which request is redirected to from host application to Intellicus.

Its default name is: LaunchPortal.jsp

If required, name of this API can be changed.

To call this API using different name than default names, you need to use method given below.

Method:

This method sets the name of Intellicus jsp to which request is redirected.

public function setRedirectionAPI($redirectionAPI)

Parameters:

redirectionAPI:  Name of the jsp at Intellicus end to which host application wants to redirect the request after user authentication

This redirection API is placed at:

<Intellicus_Install_path>Jakartawebappsintellicus

lbMode

Intellicus web application can be running on multiple web servers, so in such scenario a load balancer feature is used to decide which web server should serve the reporting request from Host application.

Host application need to specify whether reporting request is sent to load balancer or to a particular web server (in case if there is single web server for Intellicus application).

lbMode: This variable specifies whether to take reporting request to Load balancer or to particular Intellicus web server.

Its default value is: false

It means no load balancer is in picture.

Method:

This method sets the lbMode as true or false.

public function setLbMode($lbMode)

Parameters:

lbMode: boolean value.

lbRelativePath

This variable specifies the relative path for Load balancer. It is accessed only when lbMode is true.

Its default value is: /LoadBlancerServlet.

Method:

This method sets the lbMode as true or false.

public function setLbRelativePath($lbRelativePath)

Parameters:

lbRelativePath:  String for relative path.

intellicusExternalURL

Intellicus application would be accessed by Host web server (Internal IP) for getting the IntellicusToken.

But an End User can Access the Host application from some outer network.  As host application need to redirect the request for Intellicus HTTP APIs from browser, an External IP for Intellicus web application need to be specified.

intellicusExternalURL: This variable specifies the external URL for Intellicus web application.

Method:

This method is to set the External URL for Intellicus.

public function setIntellicusExternalURL($intellicusExternalURL)

Parameters:

intellicusExternalURL:  String for external URL.

Implementation for Logout

On logout from host application, session for the user is invalidated and user is redirected to home page of Host application. Now new user can login through same window.

As Host application and Intellicus web application are running on different web servers, so if Host application user logout from that application, it does not destroy the session in Intellicus for that user.

In order to destroy a session in Intellicus corresponding to a Host application end user, Host application need to invoke logout method of Intellicus as well.

So logout needs implementation for both host application as well as Intellicus.

Note: If on logout, Host appliaction is closing the current window, then there is no need of invoking the logout action at Intellicus. A new user will login through new window, so new session will be created for that user.

Implementation code can be written inside any php or html file of Host application.

  1. Host application need to add intellicaSSO.php in their application.
  2. Host application needs to include file intellicaSSO.php.

include_once(“intellicaSSO.php”);

  1. Make an object of SingleSignOn class for invoking the methods of this class.
  2. Set the IntellicusUrl. Intellicus url can be read from property file.
  3. call the method logoutFromIntellicus of SingleSignOn.

Method:

public function logoutFromIntellicus()

Sample Code for Single Sign-On request:

include_once(“intellicaSSO.php”);

try
{

	$sso=new SingleSignOn();

	// Set the path for Intellicus Web application
	// This can be read from any property file or from repository/database.
	// In lbMode , give the URl for LB application,
	// else give the URL for Intellicus Web application.
	$sso->setIntellicusURL("http://192.168.33.165/intellicus");
	//$sso->setLbMode(TRUE);

	// Set the credentials for logged-in user for End -user requests.
	// user password is not required, if the authentication mode for organization is "Host Application."
	// This user must exist at Intellicus.
	$userinfo=new UserInfo;
	$userinfo->setUserId("a");
	$userinfo->setOrgID("ab");
	/*$userinfo->setUserId((string)$_SESSION['userId']);
	$userinfo->setOrgID((string)$_SESSION['orgId']);*/
	$sso->setUserInfo($userinfo);

	//	 Set user credentials for admin user.
	// Admin user credentials are required if some request for admin activity is raised.
	// Admin activities are like User Management, Database connection creation/modification etc.
	// These can be read from any property file or from repository/database.
	$adminUserinfo=new UserInfo;
	$adminUserinfo->setUserId("Admin");
	$adminUserinfo->setPassword("Admin");
	$adminUserinfo->setOrgID("Intellica");
	//$sso->setAdminUserInfo($adminUserinfo);
	SingleSignOn::setAdminUserInfo($adminUserinfo);

	//Set the business parameters/hidden parameters that need to be passed to Intellicus
	//This can be read from any property file or from repository/database.
	$sso->setHiddenParameter("p_CompanyOID","Company_xyz");

	session_start();

	// get the url for requested Intellicus API like 
	// Report listing /Dashboards/User preferences/Query Object list etc.
	//$onSuccess="./core/ReportListForCategory.jsp?REPORT_TYPE=ADHOC";
	$onSuccess="./core/CategoryList.jsp?";

	// Check for the availability of Intellicus token in session.
	// If it is not found in session, it means user is first time  giving request to intellicus.
	// So Call the Intellicus methods to get the Token from Intellicus.
	// This token is sent by Host Application for the further interaction with intellicus.
	
	// If token is found in session,then it means,user has already  taken token from intellicus.
	// So,no need to get the token again from Intellicus.User can use the same token which he has.
	if($_SESSION['intellicusToken']==null)
	{

		//if user is not available at Intellicus end,
		// it will create the user dynamically and assign the role to that user.
		// these roles should have entry in Integration xml.
		$sso->setHiddenParameter("USER_ROLES","Admin");

		//call getIntellicusToken().
		// this method returns a intellicus token string ,if user authentication is done successfully.
		$token=$sso->getIntellicusToken();
		
		//if user is authenticated by Intellicus,then only call the Intellicus redirectionAPI
		//else show the error status message 
		if(trim($sso->isUserAuthenticated())=="TRUE")
		{
			$_SESSION['intellicusToken']=$token;
			$sso->setBusinessParameter("ABC","1");
			$sso->redirectToIntellicus($onSuccess,$token);
		}
		else // if user authentication fails at Intellicus end
		{
			print_r($sso->getUserAuthenticationMessage());
		}
	}
	else // if token found in session
	{
		$sso->setBusinessParameter("ABC","2");
		$sso->redirectToIntellicus($onSuccess,$token);
	}

}
catch(SingleSignOnException $e)// if connection for the intellicusURL can not be opened.Reason can be 
//Intellicus url is wrong or Report Server is down.
{
	print_r("Intellicus Web Application Not Available");
}
catch(Exception $e)
{
	print_r("Intellicus Web Application Not Available");
}
Leave A Comment
*
*