chrislee35 / IMAPCrypt

GPG Encrypts an IMAP folder
MIT License
12 stars 5 forks source link

Error when using command line #1

Closed mhep closed 2 years ago

mhep commented 9 years ago

Whenever I try to run IMAPCrypt from the command line on Ubuntu I get the following error once I've entered all the credentials:

java.lang.ClassCastException: org.dhs.chrislee.DateBasedMessageEvaluationCallback cannot be cast to java.lang.Comparable
    at java.util.TreeMap.compare(TreeMap.java:1290)
    at java.util.TreeMap.put(TreeMap.java:538)
    at java.util.TreeSet.add(TreeSet.java:255)
    at org.dhs.chrislee.IMAPCrypt.addMessageEvaluationCallback(IMAPCrypt.java:175)
    at org.dhs.chrislee.IMAPCrypt.main(IMAPCrypt.java:569)
chrislee35 commented 9 years ago

i'll look into tonight. which ubuntu and which java are you using?

mhep commented 9 years ago

Thanks for your quick reply!

I downloaded the latest 32bit java from here and am on Ubuntu 14.04.

Edit: Getting the GUI to work is sadly fairly hopeless, for there are so many 32bit dependencies not met if you are running a 64bit version of Ubuntu

chrislee35 commented 9 years ago

i've got a ubuntu 14.04 server vm. i'll try to get 32-bit java to work. why are you using 32-bit?

chrislee35 commented 9 years ago

I should package the 64-bit SWT libraries with IMAPCrypt, shouldn't I?

chrislee35 commented 9 years ago

My love for SWT has decreased significantly through this process... I'll probably get this to working state and then switch it over to Swing.

chrislee35 commented 9 years ago

I've created x64 versions of the tool on my website. http://chrisleephd.us/projects/imapcrypt/imapcrypt-lin-x64.jar sha256: 420b27f03270e0753194809dfae2fd113975eb6fe6ffa0c262c47648066e9c16 Please provide feedback on the tool.

mhep commented 9 years ago

Thanks so much!

I was using 32-bit because I couldn't get IMAPCrypt GUI working with 64-bit. Now I am back to 64-bit java.

I've tried running the GUI, and though it opens up fine, it doesn't seem to recognize my IMAP server posteo.de:

javax.mail.NoSuchProviderException: No provider for imaps
    at javax.mail.Session.getProvider(Session.java:464)
    at javax.mail.Session.getStore(Session.java:539)
    at javax.mail.Session.getStore(Session.java:519)
    at org.dhs.chrislee.IMAPCrypt.getFolders(IMAPCrypt.java:232)
    at org.dhs.chrislee.imapgui.groups.ServerGroup$1.handleEvent(ServerGroup.java:120)
    at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
    at org.dhs.chrislee.imapgui.IMAPGui.run(IMAPGui.java:75)
    at org.dhs.chrislee.imapgui.IMAPGui.main(IMAPGui.java:358)

The command-line version fails with the same error message.

chrislee35 commented 9 years ago

Ew, I was able to reproduce this in the VM, but not on the host, which worked just fine. This'll take a little bit of time to fix correctly.

chrislee35 commented 9 years ago

There was a strange classpath error that I still don't quite understand, but I think that different OSes will load the classes in different orders and once class was overwriting the imap(s) provider preference from the correct class. So, I removed the offending JARs and it seems to work in both environments. Please try: http://chrisleephd.us/projects/imapcrypt/imapcrypt-lin-x86_64.jar

mhep commented 9 years ago

I am able to connect to the server now! But as soon as I try to run any encryption (with date filters) I get the following error message:

org.dhs.chrislee.DateBasedMessageEvaluationCallback cannot be cast to java.lang.Comparable

If I try running it without any date filters I just get: null

Thanks again for your time!

chrislee35 commented 9 years ago

I'm still working on it. I'm giving the tool a complete make-over. I've almost got the transition to Swing done. Then I'll start testing with different Java versions and with Ubuntu.

mhep commented 9 years ago

Thanks so much! I'd be happy to help you test!

chrislee35 commented 9 years ago

I'm almost done with the next version. I've got all the GUI bits working, now I'm doing the integration with the IMAPCrypt portion and performing first-level testing. Soon, it'll be ready for user testing.

chrislee35 commented 9 years ago

I've got everything working but the logging in Swing. The LF5Appender won't update until control is returned from the IMAPCrypt module. I know that this is an issue where the event dispatcher loop isn't running while doing the folder enumeration or message encryption, but I can't figure out how to get the threading right. I'm frustrated with Swing.

mhep commented 9 years ago

Thank you in any case for all your work! There really isn't another comparable tool out there...

chrislee35 commented 9 years ago

mahaha, it's ready for testing. This link, http://chrisleephd.us/projects/imapcrypt/imapcrypt-2.0.0.jar, was built using Java 1.8. I hope this works better for you. I really wish that the idea of encrypting previously sent email would be adopted by other MUAs, but it's really hard to get right.

mhep commented 9 years ago

Sorry for getting back to you with yet another error, but trying to open the java GUI gives me this:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/dhs/chrislee/imapgui/IMAPGui : Unsupported major.minor version 52.0

chrislee35 commented 9 years ago

That's a Java version issue. What version of Java are you running?

chrislee35 commented 9 years ago

Rebuilt using Java 1.7, added SSL untrusted cert confirm box, other minor fixes: http://chrisleephd.us/projects/imapcrypt/imapcrypt-2.0.1.jar

mhep commented 9 years ago

2.0.1 starts perfectly, but seems to fail upon trying to encrypt an email. I guess it may have something to do with my Emails being mostly in German, and thus being saved in UTF-8? I hope there is a quick an easy fix to this! I am getting excited, so close.

2015-04-28 15:06:14 DEBUG IMAPCrypt:340 - Encrypting the MultiPartMime message
2015-04-28 15:06:14 ERROR IMAPCrypt:295 - Exception thrown: de.buelowssiege.mail.pgp_mime.PGPMimeException: Encryption failed!;
  nested exception is:
    javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/plain; charset=utf-8
chrislee35 commented 9 years ago

I ran into the same bug and thought it was something strange with my test set of emails (a bunch of collected spam). I'll drill into this issue and try to figure it out.

chrislee35 commented 9 years ago

Looks related to this thread: https://stackoverflow.com/questions/21856211/javax-activation-unsupporteddatatypeexception-no-object-dch-for-mime-type-multi

chrislee35 commented 9 years ago

When I cleaned up the new jar dependencies to make things work in Java 1.8, it removed some of the necessary handlers for the mime types. I upgraded the javamail package (1.5.3) to the latest version from https://java.net/projects/javamail/pages/Home, and everything works great now.

chrislee35 commented 9 years ago

An updated copy is now uploaded to my website and on github.