Suppose you have a plugin in Notes 8 Standard that needs to perform some task on startup but only after the user has successfully logged-in to the Notes client, i.e. unlocked their ID file.
Notes 8 Standard is built on Lotus Expeditor, and Lotus Expeditor has an encrypted store for storing credentials. The store must be “unlocked” before the credentials can be accessed. In the standalone Lotus Expeditor product, the credential store is unlocked through name and password, through single-sign-on with the OS or through a custom login module. In Lotus Notes 8, the credential store is unlocked by your Notes ID.
Since authenticating with Notes unlocks the Lotus Expeditor credential store, you can write code which responds to this event.
import com.ibm.rcp.security.auth.SecurePlatform;
import com.ibm.rcp.security.auth.events.ILoginContextEventListener;
import com.ibm.rcp.security.auth.events.LoginContextEvent;
import com.ibm.rcp.security.auth.service.ILoginContextService;
ILoginContextService service = SecurePlatform.getLoginContext();
service.addListener(new ILoginContextEventListener() {
public void handleLogin(LoginContextEvent event) {
if (event.type == LoginContextEvent.MethodEnd && !event.hasException) {
// run your post-login code here
}
}
public void handleLogout(LoginContextEvent arg0) {
}
});
To ensure your code runs early enough in the Notes 8 lifecycle to add the listener before the Notes ID is unlocked, add your plugin to the application lifecycle extension point:
<extension
point="com.ibm.rcp.lifecycle.application.startBundles">
<application id="com.ibm.rcp.personality.framework.RCPApplication">
<bundle id="com.my.plugin"/>
</application>
</extension>
A colleague asked whether the logout() event fires when the Notes ID is locked and whether the Notes API is available in the logout() event.
The logout() event is not fired when the ID is locked. However both events are fired as expected when the Notes ID is switched, i.e. logout() is called first followed by login().
In an ID switch, the Notes API is available in both events. The API operates under the old Notes ID in the logout() event and under the new Notes ID in the login() event.