Page created: 11 Aug 2022
|
Page updated: 11 Aug 2022
The Agent API provides access to functionality for reading an OpenToken received in an Issue request from the PingFederate STS.
Java Sample Code
The code snippet below demonstrates using the PingFederate STS Java Client SDK to retrieve the OpenToken issued from the PingFederate STS and using the OpenToken Agent API to read the OpenToken. If any errors are encountered while creating the token, a TokenException is thrown:
// Configure STS Client
(SP-side, IdP connection) AgentConfiguration spAgentConfiguration = new
AgentConfiguration(); spAgentConfiguration.setPassword("Password1");
spAgentConfiguration.setCipherSuite(Token.CIPHER_SUITE_AES128CBC); // Instantiate the OpenToken agent
Agent spAgent = new Agent(spAgentConfiguration);
// Configure STS
Client STSClientConfiguration spStsConfig = new STSClientConfiguration();
spStsConfig.setStsEndpoint("https://sp.domain.com:9031/sp/sts.wst");
spStsConfig.setOutTokenType(TokenType.BINARY);
spStsConfig.setOutTokenValueType(TokenType.OPENTOKEN); // Instantiate STS Client
STSClient spStsClient = new STSClient(spStsConfig);
// Send RST Issue request to STS
Element opentoken = spStsClient.issueToken(new Saml20Token(samlToken));
// Read OpenToken
String otk = textContent(opentoken);
MultiMap otkValues = new MultiValueMap();
otkValues = spAgent.readTokenToMultiMap(otk);