Results 1 to 2 of 2

Thread: Why not use names instead of numbers?

  1. #1
    Join Date
    Jul 2005
    Posts
    10

    Default Why not use names instead of numbers?

    As I've been reading through the Acegi documentation and looking at the code, it all looks very nice, but one point made me think 'Ugh, how annoying, why didn't they just...'

    It seems a pain to make developers write code like this:

    <authz:acl domainObject="${contact}" hasPermission="16,1">
    <td><A HREF="<c:url value="del.htm"><caram name="contactId" value="${contact.id}"/></c:url>">Del</A></td>
    </authz:acl>


    Wouldn't it be much nicer, and not that much work for the framework, to allow:

    <authz:acl domainObject="${contact}" hasPermission="DELETE,READ">
    <td><A HREF="<c:url value="del.htm"><caram name="contactId" value="${contact.id}"/></c:url>">Del</A></td>
    </authz:acl>


    I've always hated the int constants for enumerations. Why not use something like the commons ValuedEnum to track these and then allow use of the Name instead of forcing the developers to keep track of meaningless numbers?

    If we decide to use Acegi, I will probably try to extend the framework in this way. But if there's a good reason why this wasn't done already, I'd like to find out before I try!

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    It was done this way as internally the ACL services use integer masking and have no specific binding to enumeration names. I agree the taglib you've posted could be improved, and we welcome patches in JIRA. One approach might be to provide a taglib that obtains a Properties instance from the application context, and then relies on the Properties instance to map between a permission name and its integer equivalent. Alternatively, reflection could be used to look at public static final integers against the returned AclEntry and compare these with the hasPermission String.
    Ben Alex
    Project Founder, Spring UAA, Spring Roo and Spring Security

Similar Threads

  1. Replies: 2
    Last Post: Sep 13th, 2005, 09:22 PM
  2. Replies: 0
    Last Post: Apr 5th, 2005, 06:32 AM
  3. MBeanClientInterceptor assumes lower-case Attribute names
    By Joris Kuipers in forum Container
    Replies: 10
    Last Post: Mar 31st, 2005, 09:18 AM
  4. Replies: 6
    Last Post: Mar 16th, 2005, 10:41 PM
  5. Trouble with form input names
    By robinhyman in forum Web
    Replies: 4
    Last Post: Oct 22nd, 2004, 11:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •