/MipSDK-File-Java-Basic

MIP File SDK Java Wrapper Sample Application

Primary LanguageJavaMIT LicenseMIT

page_type languages products name description urlFragment
sample
java
m365
office-365
MIP File SDK Java Sample
This sample application demonstrates using the Microsoft Information Protection SDK Java wrapper to label and read a label from a file.
MipSDK-File-Java-Basic

MIP SDK Java Wrapper Sample

This sample application demonstrates a very basic MIP SDK Java wrapper sample. It'll demonstrate how to create the project, add dependencies, and get to a place where the app can run on both Windows and Ubuntu.

Features

This project framework provides the following features:

  • User authentication
  • List Labels
  • Apply Label
  • Read Label
  • Read Protection Information

Getting Started

Prerequisites

Installation

  • Windows

    • Install your JDK of choice.
    • Install Maven
  • Ubuntu

    • Install JDK: sudo apt-get install default-jdk
    • Install Maven: sudo apt-get install maven
    • Install MIP SDK Dependencies: sudo apt-get install scons libgsf-1-dev libssl-dev libsecret-1-dev freeglut3-dev libcpprest-dev libcurl3-dev uuid-dev libboost-all-dev

Quickstart

  1. git clone https://github.com/Azure-Samples/mipsdk-filesdk-java-sample.git
  2. cd mipsdk-filesdk-java-sample
  3. Install the MIP SDK JAR. This JAR file is located inside the MIP SDK Java Wrapper, available at https://aka.ms/mipsdkbins. Download and extract the JAR locally.
  • Windows: <PATH TO MAVEN>\mvn.cmd org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=<PATH TO MIP SDK>\java-sdk-wrapper.jar
  • Ubuntu: mvn org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file -Dfile=java-sdk-wrapper.jar

Note: Not using a fully qualified path for the -Dfile parameter may cause an exception. Use a full path.

  1. The Java wrapper download contains two folders: file_sdk and java_wrapper.

    • Copy all DLLs or SOs from the bins\debug folder in file_sdk for the appropriate architecture into your project folder root (the cloned project root).
    • Copy mip_java.dll or mip_java.so from the java_wrapper folder into the project folder root (the cloned project root).

    This requirement of copying to the project root is a bug and will be fixed in a future version.

  2. Update the ApplicationId on line 22 in App.java to match your application registration in Azure AD.

  3. Open the project folder in VS Code and load the project when prompted.

  4. Update the following block in App.java to include your clientId.

  appInfo.setApplicationId("YOUR CLIENT ID");
  appInfo.setApplicationName("MIP SDK Java Sample");
  appInfo.setApplicationVersion("1.14");

At this point, you should be able to build the project. If your app states that dependencies are missing:

  1. Press CTRL-SHIFT-P and finding Maven: Add a dependency...
  2. Search for msal4j and install.
  3. Press CTRL-SHIFT-P and finding Maven: Add a dependency...
  4. Search for slf4j-simple and install.

Resources