title: How to do the type casting in Spring expression language
body: <p>I'm trying to use the @PreAuthorize annotation for access control. I need to check some custom fields in the details of the authentication object. I have a CustomWebAuthenticationDetails class, which is a subclass of WebAuthenticationDetails and contains custom fields. Normally, I would use the following to get to my custom fields in CustomWebAuthenticationDetails:</p>
  
  <pre><code>((CustomWebAuthenticationDetails)authentication.getDetails()).getCustomField()
  </code></pre>
  
  <p>However, when I try to use the above statement (even including the fully qualified path to CustomWebAuthenticationDetails) in the @PreAuthorize expression, I get the following error:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Failed to parse expression ...
  </code></pre>
  
  <p>How am I supposed to do with the type casting here?</p>
  
  <p>Thanks,</p>
  
  <p>Daniel</p>