micho2001 wrote:
If you are using all this protected code from just on place (i.e: a controller in a webapp) then I would agree with you. the most common aproach I've seen is using JAAS along with declarative security on the web tier and leaving the domain EJB's without security.
But what about if you have different clients? If you don't have authorization at domain level (like in EJB), you would probably find yourself duplicating this logic for each client that uses your domain objects and
Comments are welcome!
The idea is of course to avoid code duplication - and business logic is certainly one of the best piece of code you shouldn't code twice in your application...
EJB or not EJB is just a technological decision for me. You can architect your application in different logical layers - separating presentation and business (with a set of adapters between the two if needed).
The security constraints would fit just in front of your business layer (the first step inside actually).
If you have multiple clients, I don't see why you cannot reuse the same business layer but with another presentation? It is just a matter of interfacing and passing user identification to the business...
Quote:
the most common aproach I've seen is using JAAS along with declarative security on the web tier and leaving the domain EJB's without security
I'm not an expert (yet ;-), but my experience as shown that security is often one of the latest points addressed in software development. As a result, the business has not been thought/developped with this in mind. Often people reduce the security down to simple menu activation/deactivation... therefore security code ends-up in the presentation.
This approach doesn't work anymore when you have requirements for different types of clients on top of the same business...
Moreover, some security scenarios cannot be implemented this way. What if you have constraints like:
users in role A can only retrieve information of airports in their country, while others can see all airports in every countries
Would you code this filtering logic in your presentation? Hmm... you will probably have the same constraint for update... Too bad.
As I said, I don't have enough experience yet to discuss this topic into deeper details (and my english isn't good enough), but I remember what someone told me once:
a good application is first an application that runs and satisfies the customer ;-) So whatever approach you take, provided it does the job, it is already a good approach...
-bertrand