PingAccess

Exchange object reference

The Exchange object is available to both the OAuth Groovy script rule and the regular Groovy script rule. PingAccess makes the Exchange object available to Groovy Script developers to provide request and response information for custom Groovy Rules. This object accesses the Exchange object in Groovy - exc.

Purpose

The Exchange object contains both the HTTP request and the HTTP response for the transaction processed by PingAccess. You can use this object to manipulate the request prior to it being sent to the site. You can also use this object to manipulate the response from the site before it is sent to the client.

An instance of the Exchange object lasts for the lifetime of a single application request. You can use the Exchange object to store additional information determined by the developer.

Some fields and methods for the Response object are not available in scripts used with an Agent. See the following Method Summary table for more information.

Groovy sample

//Evaluate if the content length of the request is empty
if (exc?.request?.header?.contentLength > -1 )
{
    //Set a custom header in the request object
    exc?.request?.header?.add("X-PINGACCESS-SAMPLE", "SUCCESS")
    pass()
}
else
{
    println("Request content is empty") //Debugging statement
    fail()
}

Method summary

Method Description

Identity getIdentity()

Obtains the PingAccess representation of the identity associated with the request. This object will be null for requests to an unprotected application or an unauthenticated request to an anonymous resource.

Request getRequest()

Obtains the PingAccess representation of the request. This request is sent to the site with any changes that might be made in a Groovy script.

Response getResponse()

Obtains the PingAccess representation of the response. If the site has not been called, the response is null. This field is not available in scripts used with an agent.

long getTimeReqSent()

Obtains the time, in milliseconds, when the request was sent to the site. This field is not available in scripts used with an Agent.

long getTimeResReceived()

Obtains the time, in milliseconds, when the response was received from the site. This field is not available in scripts used with an Agent.

String getRequestURI()

Returns the PingAccess Uniform Resource Identifier (URI) that received the request.

String getRequestScheme()

Obtains the scheme used by the browser or other user agent that made the request.

Object getProperty(String key)

Returns the value of a custom property.

void setProperty(String key, Object value)

Sets a custom property.

SslData getSslData()

Obtains information established in the TLS handshake made with PingAccess.