MicroStrategy ONE
Setting custom session parameters
This example demonstrates how to customize authentication if you need to set additional session parameters during authentication, such as adding the Intelligence Server session locale.
Setting custom session parameters requires some Java programming. You make changes to an XML configuration file, but you also make changes to a Java class file. In this customization, you write custom Java code that sets the session locale for the Intelligence Server, the working set size, and the search working set size.
To help you get started, we have provided a sample project that you can download. It contains the files used to perform this customization. You can use the code in the files as the basis for creating your own customization.
This customization can be used with any authentication mode. In this example, Standard authentication is used.
Prerequisites
- MicroStrategy Library is deployed
- MicroStrategy Intelligence Server is running
- You have Java programming experience
Java and XML files used for the customization
-
CustomCredentialsProvider.java
-
StdConfig.xml
This is the configuration file for Standard authentication. If you use a different authentication mode, the name of this file would be different.
To see what the customization code looks like and try out the customization in MicroStrategy Library, follow the instructions below.
- Download the sample project and extract the contents.
- Generate the files that perform the customization.
- Open the sample project in Eclipse.
-
Configure the project for your environment.
- Open Project Properties -> Java Build Path -> Libraries.
-
In the Libraries pane, change the location for the following JAR files so that they point to those JARs in your environment.
- javax.servlet-api-3.1.0.jar
- restful-api-1.0-SNAPSHOT-jar-with-dependencies.jar
-
Customize the code in the two files that perform the customization—the Java class for the custom bean and the XML configuration file. You can use the files in the sample as-is or you can do your own customization. For example, you can add different code to the Java class for the custom bean, and you can also change the name of the custom bean class and the out-of-the-box bean that it will override.
-
CustomCredentialsProvider.java is the Java class for the custom bean. It contains custom code that sets additional session parameters. In this customization, you write custom Java code that sets the session locale for the Intelligence Server, the working set size and the search working set size.
-
StdConfig.xml is the configuration file that injects the custom code into the application. It tells MicroStrategy Library to override a specified out-of-the-box bean with a specified custom bean at runtime. In the code sample below, CustomCredentialsProvider, the Java class you created above, overrides the out-of-the-box class, stdIServerCredentialsProvider.
Copy<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd">
<!-- Override IServer credentials provider with custom bean -->
<bean id="stdIServerCredentialsProvider" class="com.microstrategy.custom.auth.trusted.CustomCredentialsProvider" />
<property name="locale" value="fr_CA"/> <!-- Locale code for all sesion locale properties -->
<property name="workingSet" value="7"/> <!-- Working set size -->
<property name="maxSearch" value= "8"/> <!-- Search working set size -->
</beans>
-
- Build the project.
-
Use the customization in MicroStrategy Library.
- Deploy your MicroStrategy Library application.
- Copy the customization files from the project you built to your Library installation directory:
- Copy CustomCredentialsProvider.class to the WEB-INF\classes\com\microstrategy\custom\auth\trusted folder.
- Copy StdConfig.xml to the WEB-INF\classes\auth\custom folder.
Restart MicroStrategy Library.
When users log in to Library, the values for the additional session parameters you added—the Intelligence Server locale, the working set size, and the search working set size—will be set during authentication.