I want to pass property values assigned in an xml file to a Spring expression (an SpEL) in Java. Can you point me out how to achieve that? To make it clear, I've provided the following example.
example.xml file:
<beans>
<bean id="user" class="x.y.User">
<property name="name" value="A"/>
<property name="userId" value="33"/>
<bean id="customer" class="x.y.Customer">
<property name="name" value="B"/>
<property name="customerId" value="33"/>
</bean>
</beans>
Bear in mind that I have 'User' and 'Customer' model classes.
I want to secure a method called 'edit' by using Pre-Authorize annotation and Spring expressions in the following way.
@PreAuthorize("(#user.userId == #customer.customerId)")
public Boolean edit(User user, Customer custmer) {
return true;
}
The question is, how can I pass values of userId and customerId from "example.xml file to the above expression to compare the two values, then to secure the 'edit' method?
Note: I don't want to use permission evaluator. Please point me if it is possible to do it without considering permission evaluator. your support and cooperation will be strongly appreciated!.