Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use complex expression with Spring EL (conditional & parenthesis)

I'm using spring-EL with spring security

Is it possible to make 'complex' conditional expressions with parentesis?

@PreAuthorize("( hasRole('ROLE_USER') and ( isOwnerDocumentUUID( #docUuids ) ) or hasRole('ROLE_ADMIN')  ")

throw an java.lang.IllegalArgumentException:

Failed to parse expression

but

@PreAuthorize("hasRole('ROLE_USER') and ( isOwnerDocumentUUID( #docUuids ) ")

is accepted.

like image 376
mruellan Avatar asked Mar 18 '11 10:03

mruellan


1 Answers

You have one extra (, the following should work:

@PreAuthorize("( hasRole('ROLE_USER') and isOwnerDocumentUUID( #docUuids ) ) or hasRole('ROLE_ADMIN')  ") 
like image 123
axtavt Avatar answered Oct 29 '22 15:10

axtavt