Reading and writing OpenTokens
You can use the Agent API to read an OpenToken from an HTTP request or and write an OpenToken to an HTTP response.
|
As of Java Integration Kit 2.8, there are two versions of the OpenToken agent: the standard OpenToken agent, and the Jakarta EE 9 OpenToken agent. There are two new instances of sample code available for the Jakarta EE 9 OpenToken agent, which are documented below. These two instances of sample code contain new package locations. |
When the agent object is instantiated, it reads the OpenToken Adapter configuration from the agent-config.txt file. This configuration data includes the name of the cookie that the agent object writes, as well as the key to use when encrypting a new OpenToken. If the agent object doesn’t find the agent-config.txt file, the agent constructor will throw an exception.
To instantiate the agent object, invoke a constructor and load the configuration using one of the following methods.
Sample code - Java native multimap method (standard OpenToken agent)
import com.pingidentity.opentoken.TokenException;
import com.pingidentity.opentoken.generic.Agent;
import com.pingidentity.opentoken.generic.util.PingFederateMultiMap;
. . .
Agent agent = Agent.createUsingNativeMultiMap("<PATH_TO_FILE>/agent-config.txt");
|
This method requires the following library to be available:
You can find help in Deploying the Java agent. |
Sample code - Java native multimap method (Jakarta EE 9 OpenToken agent)
import com.pingidentity.opentoken.jakarta.TokenException;
import com.pingidentity.opentoken.jakarta.generic.Agent;
import com.pingidentity.opentoken.jakarta.generic.util.PingFederateMultiMap;
. . .
Agent agent = Agent.createUsingNativeMultiMap("<PATH_TO_FILE>/agent-config.txt");
|
This method requires the following library to be available:
You can find more information in Deploying the Java agent. |
Sample code - Apache commons multimap method (standard OpenToken agent)
import java.io.IOException;
import java.io.File;
import java.io.InputStream;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.map.MultiValueMap;
import com.pingidentity.opentoken.Agent;
import com.pingidentity.opentoken.TokenException;
import com.pingidentity.opentoken.util.UrlHelper;
. . . .
Agent agent = new Agent("<PATH_TO_FILE>/agent-config.txt");
|
This method requires the following libraries to be available:
You can find help in Deploying the Java agent. |
Sample code - Apache commons multimap method (Jakarta EE 9 OpenToken agent)
import java.io.IOException;
import java.io.File;
import java.io.InputStream;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import org.apache.commons.collections.MultiMap;
import org.apache.commons.collections.map.MultiValueMap;
import com.pingidentity.opentoken.jakarta.Agent;
import com.pingidentity.opentoken.jakarta.TokenException;
import com.pingidentity.opentoken.jakarta.util.UrlHelper;
. . . .
Agent agent = new Agent("<PATH_TO_FILE>/agent-config.txt");
|
This method requires the following libraries to be available:
You can find help in Deploying the Java agent. |