Like what you see? Have a play with our trial version.

Error rendering macro 'rw-search'

null

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

User Session Termination

These Yellowfin services can end user's Yellowfin sessions.

Anchor
logoutuser
logoutuser

Expand
titleLOGOUTUSER

 

The This service terminates a Yellowfin session. However, it requires the LoginSessionId to be able to log the user out, which is enough to identify the user, hence the user ID is not required. When a single sign-on is performed with either the LOGINUSER or LOGINUSERNOPASSWORD functions, you can get the LoginSessionId via:

Code Block
languagejava
String token = response.getLoginSessionId();

 

Save this value, so that you can pass it out to the LOGOUTUSER request later:

Code Block
languagejava
request.setLoginSessionId(token);

 

 

  • Here is a basic request for this call:

    Code Block
    languagejava
    AdministrationServiceRequest rsr = new AdministrationServiceRequest();
    
    rsr.setLoginId("admin@yellowfin.com.au");
    rsr.setPassword("test");
    rsr.setOrgId(1);
    
    rsr.setFunction("LOGOUTUSER");
  • Pass the login session ID:

    Code Block
    languagejava
    rsr.setLoginSessionId(token);
    
  • If the user is logged into multiple Tomcat sessions simultaneously, then you can even specify which session to terminate by setting a parameter, for example:

    Code Block
    languagejava
    String[] _sessionId = new String[]{sessionId}; // logout by Tomcat session Id (cookies JSESSIONID)
    rsr.setParameters(_sessionId);

    Only one session should be provided for termination per request. Note that the Tomcat session ID is optional; if omitted, Yellowfin will terminate all of the user's sessions.

  • Once the request is configured, perform the call:

    Code Block
    languagejava
    AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);

    Initialize the Administration web service. Click here to learn how to do this.

 

  • This call's response will contain these parameters:

    Response Element

    Data Type

    Description

    StatusCode

    String

    Status of the web service call. Possible values include:

    • SUCCESS
    • FAILURE

     

     

Complete Example

Below is a complete example of the LOGOUTUSER function. This script is designed to perform the following steps:

  • Call the LOGINUSER service which retrieves the LoginSessionId;
  • Configures the login link. You will need to click this link first, to initialize a Yellowfin session for the specifed user. (In our example we will log in the user john.smith@yellowfin.com.au. Make sure that the user you mention, already exists in your Yellowfin instance, or you can even modify the userId.)
  • Configure the link to log out. You will need to click this once the session has started.

 

To use this script for yourself, carry out the following the steps:

  1. Copy the code and save it as ws_updateusertest.jsp.
  2. Put the file in the root folder: Yellowfin/appserver/webapps/ROOT.
  3. Adjust the host, port, admin user and user to update login/logout according to your environment.
  4. Run http://<host>:<port>/ws_updateusertest.jsp from your Internet browser.

 

Code Block
languagejava
<%            
/*              test.jsp                */
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.hof.util.*, java.util.*, java.text.*" %> 
<%@ page import="com.hof.web.form.*" %>
<%@ page import="com.hof.mi.web.service.*" %>
<% 
AdministrationServiceService s_adm = new AdministrationServiceServiceLocator("localhost",8080, "/services/AdministrationService", false);        // adjust host and port number
AdministrationServiceSoapBindingStub adminService = (AdministrationServiceSoapBindingStub) s_adm.getAdministrationService();
AdministrationServiceRequest rsr = new AdministrationServiceRequest();

String token = request.getParameter("token");

if (token == null) {
	
	//login the user:

	rsr.setLoginId("admin@yellowfin.com.au");          // provide your Yellowfin webservices admin account
	rsr.setPassword("test");                           // change to be the password of the account above
	rsr.setOrgId(1);
	rsr.setFunction("LOGINUSER");

	AdministrationPerson ap = new AdministrationPerson();

	String userId = "john.smith@yellowfin.com.au";

	ap.setUserId(userId);
	ap.setPassword("test");

	rsr.setPerson(ap);

	AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);

	if ("SUCCESS".equals(rs.getStatusCode()) ) {
		String token_ = rs.getLoginSessionId();
		out.write("Login by opening the link in a new subtab prior to Logout. The tomcat session must be initialized...");
		out.write("<BR>Login: <A href='http://localhost:8080/logon.i4?LoginWebserviceId=" + token_ + "'>");
		out.write("http://localhost:8080/logon.i4?LoginWebserviceId=" + token_ + "</a><br>");
		out.write("<BR>Logout: <A href='http://localhost:8080/test.jsp?token=" + token_ + "&userId=" + userId + "'>");
		out.write("http://localhost:8080/test.jsp?token=" + token_ + "&userId=" + userId + "</a><br>");
	} else {
		out.write("Failure");
		out.write(" Code: " + rs.getErrorCode() );
		return;
	}
} else {

	//logout the user:

	out.write("Trying to logout " + token + " session...<br>");

	rsr = new AdministrationServiceRequest();

	rsr.setLoginId("admin@yellowfin.com.au");          // provide your Yellowfin webservices admin account
	rsr.setPassword("test");                           // change to be the password of the account above
	rsr.setOrgId(1);

	rsr.setFunction("LOGOUTUSER");

	rsr.setLoginSessionId(token);

	AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);

	if ("SUCCESS".equals(rs.getStatusCode()) ) {
		out.write("Logout: Success");
	} else {
		out.write("Failure");
		out.write("Code: " + rs.getErrorCode() );
	}
} 
%>


 

 

Anchor
logoutbyuserid
logoutbyuserid

Expand
titleLOGOUTBYUSERID

 

This service is similar to the LOGOUTUSER function in that it logs out a specified user, however this one requires either a user ID (for example, an email address or any other type of ID depending on the Login ID method) or a user IpID (that is, the value of the IpId field in the Person table in Yellowfin's database), rather than a login session ID to identify the user.

This call uses the AdministrationPerson object which is used to provide the user ID or the user IpId.

 

  • Here is a basic request for this call:

    Code Block
    languagejava
    AdministrationServiceRequest rsr = new AdministrationServiceRequest();
    
    rsr.setLoginId("admin@yellowfin.com.au");
    rsr.setPassword("test");
    rsr.setOrgId(1);
    
    rsr.setFunction("LOGOUTBYUSERID");
  • Identify the user to log out, by passing their user ID or IpId:

    Code Block
    languagejava
    AdministrationPerson ap = new AdministrationPerson();
    ap.setUserId(userId); 
          
    rsr.setPerson(ap);
    
  • If the user is logged into multiple Tomcat sessions simultaneously, then you can specify which session to terminate by setting a parameter, for example:

    Code Block
    languagejava
    String[] _sessionId = new String[]{sessionId}; // logout by Tomcat session Id (cookies JSESSIONID)
    rsr.setParameters(_sessionId);

    Only one session should be provided for termination per request. Note that the Tomcat session ID is optional; if omitted, Yellowfin will terminate all of the user's sessions.

  • Once the request is configured, perform the call:

    Code Block
    languagejava
    AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);

    Initialize the Administration web service. Click here to learn how to do this.

 

  • This call's response will contain these parameters:

    Response Element

    Data Type

    Description

    StatusCode

    String

    Status of the web service call. Possible values include:

    • SUCCESS
    • FAILURE

     

     

Complete Example

Below is a complete example of the LOGOUTUSER function. This script is designed to perform the following steps:

  • Configures the login link. You will need to click this link first, to initialize a Yellowfin session for the specifed user. (In our example we will log in the user john.smith@yellowfin.com.au. Make sure that the user you mention, already exists in your Yellowfin instance, or you can even modify the userId.)
  • Configure the link to log out. You will need to click this once the session is set up.

 

To use this script for yourself, carry out the following the steps:

  1. Copy the code and save it as test.jsp.
  2. Put the file in the root folder: Yellowfin/appserver/webapps/ROOT.
  3. Adjust the host, port, admin user and user to login/logout according to your environment.
  4. Run http://<host>:<port>/test.jsp from your Internet browser.

 

Code Block
languagejava
<%            
/*              test.jsp                */
%>
<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.hof.util.*, java.util.*, java.text.*" %> 
<%@ page import="com.hof.web.form.*" %>
<%@ page import="com.hof.mi.web.service.*" %>
<% 
AdministrationServiceService s_adm = new AdministrationServiceServiceLocator("localhost",8080, "/services/AdministrationService", false);        // adjust host and port number

AdministrationServiceSoapBindingStub adminService = (AdministrationServiceSoapBindingStub) s_adm.getAdministrationService();
AdministrationServiceRequest rsr = new AdministrationServiceRequest();


String userId = request.getParameter("userId");

if (userId == null) {

	//login the user:

	rsr.setLoginId("admin@yellowfin.com.au");          // provide your Yellowfin webservices admin account
	rsr.setPassword("test");                           // change to be the password of the account above
	rsr.setOrgId(1);
	rsr.setFunction("LOGINUSER");


	AdministrationPerson ap = new AdministrationPerson();

	userId = "john.smith@yellowfin.com.au";

	ap.setUserId(userId);
	ap.setPassword("test");


	rsr.setPerson(ap);
	
	AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);


	if ("SUCCESS".equals(rs.getStatusCode()) ) {
		String token_ = rs.getLoginSessionId();
		out.write("Login by opening the link in a new subtab prior to Logout. The tomcat session must be initialized...");
		out.write("<BR>Login: <A href='http://localhost:8080/logon.i4?LoginWebserviceId=" + token_ + "'>");
		out.write("http://localhost:8080/logon.i4?LoginWebserviceId=" + token_ + "</a><br>");

		out.write("<BR>Logout: <A href='http://localhost:8080/test.jsp?token=" + token_ + "&userId=" + userId + "'>");
		out.write("http://localhost:8080/test.jsp?token=" + token_ + "&userId=" + userId + "</a><br>");

	}else {
		out.write("Failure");
		out.write(" Code: " + rs.getErrorCode() );
		return;
	}
} else {

	//logout the user:
	
	out.write("Trying to logout " + userId + " session...<br>");

	rsr = new AdministrationServiceRequest();

	rsr.setLoginId("admin@yellowfin.com.au");          // provide your Yellowfin webservices admin account
	rsr.setPassword("test");                           // change to be the password of the account above
	rsr.setOrgId(1);
	
	rsr.setFunction("LOGOUTBYUSERID");

	AdministrationPerson ap = new AdministrationPerson();
	ap.setUserId(userId);
	
	rsr.setPerson(ap);

	AdministrationServiceResponse rs = adminService.remoteAdministrationCall(rsr);


	if ("SUCCESS".equals(rs.getStatusCode()) ) {
		out.write("Logout: Success");
	} else {
		out.write("Failure");
		out.write(" Code: " + rs.getErrorCode() );
	}
} 
%>