mina-ftpserver-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicklas Nordborg <nick...@compunet.se>
Subject The User.getAuthorities(Class<Authority> clazz) method has a flaw
Date Wed, 28 May 2008 18:42:56 GMT
I think this method has a flaw in it's signature. It is impossible to 
call this method with any other class object than the Authority.class. 
For example if I try:

   Authority[] auth = user.getAuthorities(WritePermission.class);

I get the following compile error (cleaned up a bit):

   [javac] BaseUserManager.java:118: cannot find symbol
   [javac] symbol  : method getAuthorities(Class<WritePermission>)
   [javac] location: class net.sf.basedb.clients.ftp.BaseUser
   [javac]                   user.getAuthorities(WritePermission.class);
   [javac]                       ^

A workaround is to do:

   Class c = WritePermission.class;
   Authority[] auth = user.getAuthorities(c);

I think the proper solution is to change the method signature to:

    Authority[] getAuthorities(Class<? extends Authority> clazz);

This would allow any subclass of the Authority class to be used as a 

Just a final note. It is no big deal for me. I am not going to call this 
method in my code and it seems like it is not called anywhere internally 
in the FTP Server code either. It was just something I noticed while 
implementing the User interface and trying to test my implementation of it.


View raw message