Attribute drop-off process
To drop off user attributes to PingFederate, configure your application to authenticate itself, provide the encoded attributes, and store a reference ID from the response.
Providing the user attributes
Configure your application to make an HTTP POST call to the Reference ID Adapter dropoff endpoint:
https://pf_host:pf_port/ext/ref/dropoff
In the call, provide the following:
-
Authentication credentials, if you are using the HTTP Basic or HTTP header authentication. Learn more in Authentication methods.
-
The ID of the Reference ID Adapter instance.
-
The user attributes.
PingFederate expects the attributes to be encoded as a JSON object or as query parameters in the URL, depending on the Incoming Attribute Format setting in your adapter instance configuration.
Example code:
// Drop the attributes into PingFederate String dropoffLocation = "https://localhost:9031/ext/ref/dropoff"; System.out.println(dropoffLocation); URL dropUrl = new URL(dropoffLocation); URLConnection urlConnection = dropUrl.openConnection(); HttpsURLConnection httpsURLConnection = (HttpsURLConnection)urlConnection; httpsURLConnection.setSSLSocketFactory(socketFactory); urlConnection.setRequestProperty("ping.uname", "changeme"); urlConnection.setRequestProperty("ping.pwd", "this is a default example and should not be used in production"); urlConnection.setRequestProperty("ping.instanceId", "idpadapter"); // Write the attributes in URL Connection, this example uses UTF-8 encoding urlConnection.setDoOutput(true); OutputStreamWriter outputStreamWriter = new OutputStreamWriter(urlConnection.getOutputStream(), StandardCharsets.UTF_8); idpUserAttributes.writeJSONString(outputStreamWriter); outputStreamWriter.flush(); outputStreamWriter.close();
Parsing the reference ID from the response
The response from PingFederate includes a newly-generated reference ID associated with the attributes it received. You will use this REF
value later in the authentication flow.
Example response:
HTTP/1.1 200 OK { “REF”:”54321” }
Configure your application to parse the response and store the reference ID.
Example code:
// Get the response and parse it into a JSON object InputStream is = urlConnection.getInputStream(); InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8); JSONParser parser = new JSONParser(); JSONObject jsonRespObj = (JSONObject)parser.parse(streamReader); // Grab the value of the reference Id from the JSON Object. This value // must be passed to PingFederate on resumePath as the parameter 'REF' String referenceValue = (String)jsonRespObj.get("REF"); System.out.println("Reference ID = " + referenceValue);