Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

Using credentials to control access to public methods: good or bad     idea?

Thread view: 
Olli Plough - 30 Nov 2007 12:11 GMT
Hi,

in the application I'm working on there are some methods I don't want
the application developer to call (it's not the way to do things and
the use could corrupt data). In order to program truly against an
interface and have generic code I have to put these methods into the
respective Java interface, though. Problem is that the user should not
call these methods but use a different approach. My idea is now that
those methods require some credentials to be passed on as a parameter
and the "kernel" verifies whether the credentials that only the kernel
knows are correct. If not an exception is thrown. Now I'm asking
myself whether this is a good idea or rather brain damaged. My concern
is that the problem should rather be solved on a design level rather
than doing tricky things. But I see no way round putting those methods
into the respective Java interface class. Otherwise the framework
cannot call them itself ...

Any ideas or opinions would be appreciated.
Regards, Oliver Plohmann
Manish Pandit - 01 Dec 2007 01:56 GMT
> Hi,
>
[quoted text clipped - 15 lines]
> Any ideas or opinions would be appreciated.
> Regards, Oliver Plohmann

From what I understood, you're right. Passing credentials to a method
and the method determining whether to execute or not is not a good
idea under most circumstances.

That is why Java EE supports the security model based on descriptors,
where by you declare roles, assign users to those roles and then have
the permissions managed on the methods based on these roles, all
external to the application in the form of deployment descriptors.
This is also referred to as the declarative security model (vs. the
programmatic security model you've mentioned in the post).

Here is a good tutorial by Sun on EE Security :
http://java.sun.com/javaee/5/docs/tutorial/doc/bnbwk.html

-cheers,
Manish
Martin Gregorie - 01 Dec 2007 17:32 GMT
>> Hi,
>>
[quoted text clipped - 29 lines]
> Here is a good tutorial by Sun on EE Security :
> http://java.sun.com/javaee/5/docs/tutorial/doc/bnbwk.html

I assume the OP has these sensitive classes in a package. If so, why
can't they simply be declared as "protected class", which would restrict
access to package members?

Signature

martin@   | Martin Gregorie
gregorie. | Essex, UK
org       |



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.