Вопрос

I am writing a standalone Java application which talks to a Lotus Notes client using notes.jar. The application doesn't have access to a Domino server which is why I'm using the Lotus Notes client.

The user id file location and password are supplied by the user through my application and which then connects to the Lotus Notes client using these.

In the client I first create a session using a default ID which my application sets within the notes.ini file for the Lotus Notes client, and then switch the ID, i.e.:

Session session = NotesFactory.createSession((String) null, (String) null, "defaultPassword");
session.createRegistration().switchToID(userSuppliedIDFilename, userSuppliedPassword);

If the user-supplied password is correct, this all works fine.

If the password is wrong however, the switchToID() method prompts the console for the correct password:

The ID file being used is: CN=Test Test/=Development
Enter password (press the Esc key to abort):

My Java application can't respond to this console prompt so it hangs.

Is there any way to stop the prompt. i.e. get the switchToID() method to throw an exception when the password is wrong so that the application can return an error message to the user?

Is there a way for my application to send the Esc key back to the prompt so I can abort the process as indicated in the message coming back from Notes?

Is there a better way to create a client session with user-entered ID file and password?

Thanks, Richard

Это было полезно?

Решение 2

As far I understood, it would throw a NotesException if the session is not created successfully.

NotesFactory.createSession((String)null, (String)null, passwordString) throws NotesException

Access is granted if the password matches the Notes user ID password. Why don't you try .. catch it

try {
  Session session = NotesFactory.createSession((String) null, (String) null, "defaultPassword");
  if(session != null) {
    //do sth.
  }
}
catch (NotesException e) {

}

Другие советы

You can switch to userSuppliedIDFilename without using switchToID() and beeing able to catch a wrong userSuppliedPassword this way:

    NotesThread.sinitThread();
    Session session = NotesFactory.createSession((String) null, (String) null, "defaultPassword");
    session.setEnvironmentVar("KeyFileName", userSuppliedIDFilename, true);
    session.recycle();
    NotesThread.stermThread();
    NotesThread.sinitThread();
    try {
        session = NotesFactory.createSession((String) null, (String) null, userSuppliedPassword);
    } catch (NotesException e) {
        // wrong password for userSuppliedIDFilename
        // ask user for correct password... 
    }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top