Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Eclipse JAAS - registerListener()
Eclipse JAAS - registerListener() [message #125402] Tue, 03 February 2009 10:10 Go to next message
Lars Martin is currently offline Lars MartinFriend
Messages: 24
Registered: July 2009
Junior Member
Hi folks,

we're using Eclipse JAAS to add security to our RAP application.

[--------]

String configName = "myJAAS";
URL configUrl = Activator.getDefault().getBundle().getEntry(
"data/jaas_config.txt");
System.setProperty("login.config.url.1", configUrl.toExternalForm());
ILoginContext secureContext = LoginContextFactory.createContext(
configName, configUrl);
....
Subject s = secureContext.getSubject();
....
[--------]

The login works properly so far but now I want to register an event
listener to give the user feedback if the login failed for some reason.
The Eclipse JAAS API provides the method registerListener() to add an
event listener.

[--------]

secureContext.registerListener(listener)

[--------]


But how do I register my login dialog that implements CallbackHandler
and ILoginContextListener if the callbackhandler is defined in
plugin.xml as an extension? So my application doesn't know the used
LoginModule, CallbackHandler and actually used CallbackHandlerMapping.

Any help is appreciated.

Kindest regards, Lars
Re: Eclipse JAAS - registerListener() [message #125432 is a reply to message #125402] Tue, 03 February 2009 14:53 Go to previous messageGo to next message
Oleg Besedin is currently offline Oleg BesedinFriend
Messages: 41
Registered: July 2009
Member
> But how do I register my login dialog that implements CallbackHandler and
> ILoginContextListener if the callbackhandler is defined in plugin.xml as
> an extension?

Not sure if I understand the question. I imagine that those would be two
separate classes: dialog collects information from the user and passes it
via callbacks to the login module; the listener does something as a reaction
to the login status. For instance, such listener could be used to display a
"lock" icon in the status bar.

The login dialog can be registered with the extension point
"org.eclipse.equinox.security.callbackHandler".

The ILoginContextListener has this method:
/**
* This method is called after login sequence is finished. If login
* exception is not null, the login failed.
* @param subject the subject being authenticated, might be
<code>null</code>
* if there is no subject associated the context at this time
* @param loginException <code>null</code> if login succeeded, otherwise
contains
* exception caused login to fail
*/
void onLoginFinish(Subject subject, LoginException loginException);


(There is some sample code in the "org.eclipse.equinox.security.sample"
bundle in the equinox-incubator/security in the "/cvsroot/eclipse"
repository. I am not sure if anybody supports that code at this time, but
you can have a look at the KeyStoreLoginDialog as a starting point.)

Sincerely,
Oleg Besedin
Re: Eclipse JAAS - registerListener() [message #125471 is a reply to message #125432] Tue, 03 February 2009 15:42 Go to previous message
Lars Martin is currently offline Lars MartinFriend
Messages: 24
Registered: July 2009
Junior Member
Oleg Besedin wrote:
>> But how do I register my login dialog that implements CallbackHandler and
>> ILoginContextListener if the callbackhandler is defined in plugin.xml as
>> an extension?
>
> Not sure if I understand the question. I imagine that those would be two
> separate classes: dialog collects information from the user and passes it
> via callbacks to the login module; the listener does something as a reaction
> to the login status. For instance, such listener could be used to display a
> "lock" icon in the status bar.
>
> The login dialog can be registered with the extension point
> "org.eclipse.equinox.security.callbackHandler".
>
> The ILoginContextListener has this method:
> /**
> * This method is called after login sequence is finished. If login
> * exception is not null, the login failed.
> * @param subject the subject being authenticated, might be
> <code>null</code>
> * if there is no subject associated the context at this time
> * @param loginException <code>null</code> if login succeeded, otherwise
> contains
> * exception caused login to fail
> */
> void onLoginFinish(Subject subject, LoginException loginException);
>
>
> (There is some sample code in the "org.eclipse.equinox.security.sample"
> bundle in the equinox-incubator/security in the "/cvsroot/eclipse"
> repository. I am not sure if anybody supports that code at this time, but
> you can have a look at the KeyStoreLoginDialog as a starting point.)
>
> Sincerely,
> Oleg Besedin


Hi Oleg, thanks for your reply.

Yes, I've registered the CallbackHandler via plugin.xml. This callback
handler (a RAP/RCP dialog) collects the user input.
Now I wish to notify the user if the login doesn't not suceed (password
doesn't match). The notification should be done in the same dialog, the
dialog can stay open and the user can verify/correct its login. So I
have to register a listener that implements ILoginContextListener. My
dialog implements CallbackHandler to collect the user input and
implements ILoginContextListener to notify the user in case of login errors.

The problem is that my login bundle doesn't know the callback handler
instance because it is declared with the extension point. This is
correct - the actual JAAS configuration is separated from application
code. If my dialog also implements ILoginContextListener to notify the
user I can not register that listener because I do not have an instance.

secureContext.registerListener( ? );


Btw whats the current state of Eclipse JAAS? Does any roadmap exist?

Regards, Lars
Previous Topic:InvalidRegistryObjectException on upgrade
Next Topic:Unwanted Contributions
Goto Forum:
  


Current Time: Fri Apr 26 09:00:14 GMT 2024

Powered by FUDForum. Page generated in 0.02687 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top