MicroStrategy ONE

Getting custom information from the header

Some SSO providers can provide additional information about users, such as the geo location, in the request header. This example demonstrates how to customize authentication to extract this information and add it to the user session. The additional user information—geo location—is used to add a security filter to the user session.

Getting location information from the header requires some Java programming. You make changes to an XML configuration file, but you also make changes to a Java class file. You write custom Java code that gets location information from the header and uses it to populate the SSOIServerCredentials object, which is later used by the Authentication Filter code to create a session on the Intelligence Server.

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 only with Trusted authentication mode.

Prerequisites

  • MicroStrategy Library is deployed
  • MicroStrategy Intelligence Server is running
  • A trust relationship has been set up between the REST Server and the Intelligence Server
  • You have Java programming experience

Jave and XML files used for the customization

  • CustomCredentialsProvider.java

  • TrustedConfig.xml

To help you understand the structure of these files and how to customize them, we have provided sample files that you can download. To use the sample, follow the steps below:

  1. Download the sample project and extract the contents.
  2. Generate the files that perform the customizaton.

    1. Open the sample project in Eclipse.
    2. Configure the project for your environment.

      1. Open Project Properties -> Java Build Path -> Libraries.
      2. 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
    3. 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 gets location information from the header.

      • TrustedConfig.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, trustedIServerCredentialsProvider.

        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="trustedIServerCredentialsProvider" class="com.microstrategy.custom.auth.trusted.CustomCredentialsProvider" />
        </beans>
    4. Build the project.
  3. Use the customization in MicroStrategy Library.
    1. Deploy your MicroStrategy Web application.
    2. Copy the customization files from the project you built to your Library installation directory:
      • Copy the CustomCredentialsProvider.class file to the WEB-INF\classes\com\microstrategy\custom\auth\trusted folder.
      • Copy the TrustedConfig.xml file to the WEB-INF\classes\auth\custom folder.
    3. Restart MicroStrategy Library.

      When users log in to Library, information about their location will be extracted from the header and saved.