public String authenticate(String username, byte[] password) { // throws
   // RemoteException
   // {
   UserInterface user = DbObjectServiceModel.GetServerSideInstance().FindUser(username);
   if (user == null) {
     return null;
   } else {
     try {
       if (user.Fetch()) {
         byte[] hashedPassword = user.GetPassword();
         MessageDigest.getInstance("SHA-512");
         if (MessageDigest.isEqual(password, hashedPassword)) {
           // authentication successful.
           // generate a unique string to return it to the client.
           return java.util.UUID.randomUUID().toString();
         } else {
           // authentication failure.
           return null;
         }
       }
     } catch (AlreadyDeletedException e) {
       // the user had already been killed.
       e.printStackTrace();
       return null;
     } catch (NoSuchAlgorithmException e) {
       // Should never reach this block, but throw it here anyway.
       e.printStackTrace();
       return null;
     }
   }
   return "";
 }