Use a complex expression with Spring EL (conditional and parentheses)

I am using spring -EL with spring security

Is it possible to make "complex" conditional expressions with a parent expression?

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

throw java.lang.IllegalArgumentException:

Could not parse expression

but

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

.

+3
source share
1 answer

You have one additional (that should work:

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

All Articles