developerWorks  >  Lotus  >  Forums & community  >  IBM Sametime Forum

IBM Sametime Forum

developerWorks




Get a login token for login through Notes 5/6 (Java)
Peter Gerritsen 09/18/2003 09:28 AM
Sametime Developers Toolkit All Releases Windows NT/2000


I created an applet based on the LiveNames example. In this applet I now use a login by username and password.
Because I want to use a user's Notes login in the applet (Single Sign On) I need to retrieve a login token based on the Notes username. How do I do this. So far I tried to resolve a user by username then use the STuser retrieved from that to get a token. But this doesn't work as it that you need to be logged in to resolve a user. The code I have so far:

public void init() {
try
{
m_session = new STSession("LiveNamesApplet " + this);
m_session.loadAllComponents();
m_session.start();

setLayout(new BorderLayout());
m_awarenessList = new AwarenessList(m_session, true);
add(m_awarenessList, BorderLayout.CENTER);

m_names = (NamesService) m_session.getCompApi(NamesService.COMP_NAME);
m_names.addNamesServiceListener(this);

m_token = (TokenService) m_session.getCompApi(TokenService.COMP_NAME);
m_token.addTokenServiceListener(this);

m_lookup = (LookupService) m_session.getCompApi(LookupService.COMP_NAME);

m_resolver = m_lookup.createResolver(false, // Return all matches.
false, // Non-exhaustive lookup.
true, // Return resolved users.
false); // Do not return resolved groups.

m_resolver.addResolveListener(this);

System.out.println("Resolving user");
m_resolver.resolve("Peter Gerritsen");
}
catch(DuplicateObjectException e)
{
e.printStackTrace();
}
}

public void resolved(ResolveEvent event)
{
STUser tempUser;
tempUser = (STUser) event.getResolved();

if (m_comm.isLoggedIn()) {
System.out.println("Resolved user will be added");
m_awarenessList.addUser(tempUser);
}
else {
System.out.println("Token for resolved user will be added");
m_token.generateToken();
}
}

public void tokenGenerated(TokenEvent event) {
System.out.println("Token generated");
m_comm.loginByToken("sametime.aedificomm.net",
event.getToken().getLoginName(),
event.getToken().getTokenString());
}

public void generateTokenFailed(TokenEvent event) {
System.out.println("Token generation failed");
}

Go back