title: Spring security - Secure a request by validating principle against @RequestParam parameter?
body: <p>I work with Restful API (with many urls) using Spring 3.1.2, and want to apply security filters per request that uses both data from the authenticated user "principal" and the data sent by the request.</p>
  
  <p><strong>example:</strong></p>
  
  <p>validate accountId from request url: </p>
  
  <p><code>http://www.foo.com/accountRecords?accountId=23</code></p>
  
  <p>with principal data <code>principal.accountId = 23</code>.</p>
  
  <p>I know this can be done from within the @requestMapping methods, but want to do it <strong>outside</strong> the actual method, so it will be maintainable and configurable without interfering the business logic.</p>
  
  <p>But I didn't find any advice\sample about it..</p>
  
  <p>I believe it should look something like:
  <code>@PreAuthorize("principal.accountId == requestParam.accountId")</code></p>