A simple OGNL expression

A simple OGNL expression

June 13, 2013

When you start an OGNL expression, the current context is the PingFederate framework. You can refer to this by using the #this variable. You use this to retrieve the contents of an attribute in your current mapping operation. For example, in an IdP Connection, when mapping an Assertion you received to an SP Adapter, you can refer to the SAML_SUBJECT as:




The get method allows you to extract the value of an attribute by passing in the name as a string. The attribute name is case sensitive. You can retrieve attributes that are part of the adapter, the assertion or that came from a datasource lookup. A simple way to see what attributes are available to you in a particular mapping is by selecting the Edit link when you select Expression as the source, as shown in the following screenshot:


More on the editor in a future post.


Taking the earlier expression, let's build on it by converting the value  to uppercase, as follows: 




(If you are familiar with Java, you may be saying to yourself: "Hey, except for the # this looks just like Java." And that's true! As I said, Java-like...)


Explanation: The above expression extracts the value of SAML_SUBJECT with get, makes sure that we end up with a string with toString(), and then converts that subject string to uppercase. We need to make sure we get as a string because it potentially could be a collection or array of values, for example, if you are working with the LDAP memberOF attribute (more on that in a later post, too).


The result of this expression will be placed into whatever attribute you mapped it to, as shown in the following screenshot:


Here's what the results look like when received and consumed by the target application.


I'll have more in my next post in the series. In the meantime, let me know about any additional topics on OGNL you would like to see.




OGNL Blog Series:


  1. Introduction to OGNL
  2. A simple OGNL expression
  3. Declaring variables in OGNL
  4. Method calls in OGNL
  5. Arrays in OGNL
  6. OGNL: What about those curly braces?
  7. Looping in OGNL
  8. Looping in OGNL take 2
  9. So what exactly is #this in OGNL?
  10. A continuing look at #this variable in OGNL
  11. Functions in OGNL
  12. Misc Topics in OGNL


John DaSilva develops training and solutions at Ping Identity.