JAVA/CORBA CLASSES

Examples: hashPassword method
This agent deals with three fields in the selected document: PasswordCreate, a password field entered by the user; PasswordVerification, another password field entered by the user; and Password, a hidden text field generated by the agent. If Password is null, the agent hashes a value from PasswordCreate. If Password contains a value, the agent verifies it against PasswordVerify.

import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();

     // (Your code goes here)
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     Document doc = dc.getFirstDocument();
     // If password exists, verify it
     String password = doc.getItemValueString("Password");
     if (password != null) {
       String pVerify = doc.getItemValueString("PasswordVerification");
       if (pVerify != null) {
         if (session.verifyPassword(pVerify, password))
           System.out.println("Password verification OK");
         else
           System.out.println("Password verification failed");
         doc.replaceItemValue("PasswordVerification", "");
         doc.save(true, true, true);
       }
       else
         System.out.println("Password verification not specified");
     }
     else { // if password does not exist, create it
       String pCreate = doc.getItemValueString("PasswordCreate");
       if (pCreate != null) {
         doc.replaceItemValue("Password",
           session.hashPassword(pCreate));
         doc.replaceItemValue("PasswordCreate", "");
         doc.save(true, true, true);
         System.out.println("Password created");
       }
       else
         System.out.println("Password not specified");
     }

   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}

See Also