hello just a quick question i am not sure about. Do CallbackHandller implementations have to have a no argument constructor? It makes sense to me that they dont, because you need a way to pass parameters to populate username/password etc.is that right? thanks in advance shai
Shai koren<br />SCJP2 <br />SCEA (well yea only part 1 so far)
Originally posted by shai koren: hello just a quick question i am not sure about. Do CallbackHandller implementations have to have a no argument constructor? It makes sense to me that they dont, because you need a way to pass parameters to populate username/password etc.is that right? thanks in advance shai
Shai- Super question! JAAS can be confusing in this regard. Here's a quick answer: CallbackHandlers must have a no-arg constructor. The callback handler is responsible for retrieving the uid and password from the user (or other source), so it's hard to pass those items to it at instantiation time... The handle method in the CallbackHandler is called with a particular callback (like PasswordCallback) when the prevailing LoginModule needs to retrieve the password info from the user. Most callback handlers then prompt the user or use some ofhter mechanism to generate this information. In many cases the callback handler is constructed by the owning app and passed into the constructor for the LoginContext object (thus allowing constructors with arguments to be used). However, the default callback handler for the VM instance can also be specified by setting the auth.login.defaultCallbackHandler system property. If this mechanism is used, then the system will instantiate the callback handler and thus will need a no-arg constructor. Hope this helps!
Brian Buege<br />Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0072225653/brivacom-20" target="_blank" rel="nofollow">Hacking Exposed J2EE & Java: Developing Secure Web Applications with Java Technology</a><br />Visit the <a href="http://www.hackingexposedjava.com" target="_blank" rel="nofollow">Companion Website</a>