Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scmail uses java.awt classes not available in Android #7

Closed
gusak opened this issue Nov 21, 2012 · 4 comments · May be fixed by rtyley/spongycastle#20
Closed

scmail uses java.awt classes not available in Android #7

gusak opened this issue Nov 21, 2012 · 4 comments · May be fixed by rtyley/spongycastle#20

Comments

@gusak
Copy link

gusak commented Nov 21, 2012

Hi,

I'm trying to use scmail lib for smime signing/encryption. I'm now stuck with one issue.

When we run the code below:
MimeBodyPart encryptedPart = encrypter.generate(body,new JceCMSContentEncryptorBuilder(CMSAlgorithm.RC2_CBC).setProvider(keyStoreProvider).build());
ByteArrayOutputStream out = new ByteArrayOutputStream();
encryptedPart.writeTo(out);

it fails in encryptedPart.writeTo(out); Here is the trace

11-21 13:30:53.385: E/dalvikvm(10025): Could not find class 'java.awt.datatransfer.DataFlavor[]', referenced from method org.spongycastle.mail.smime.handlers.pkcs7_mime.
11-21 13:30:53.385: W/dalvikvm(10025): VFY: unable to resolve new-array 3218 ([Ljava/awt/datatransfer/DataFlavor;) in Lorg/spongycastle/mail/smime/handlers/pkcs7_mime;
11-21 13:30:53.390: D/dalvikvm(10025): VFY: replacing opcode 0x23 at 0x000e
11-21 13:30:53.400: W/dalvikvm(10025): VFY: unable to find class referenced in signature ([Ljava/awt/datatransfer/DataFlavor;)
11-21 13:30:53.400: W/dalvikvm(10025): VFY: Ljava/lang/Object; is not instance of [Ljava/lang/Object;
11-21 13:30:53.405: W/dalvikvm(10025): VFY: bad arg 2 (into [Ljava/lang/Object;)
11-21 13:30:53.405: W/dalvikvm(10025): VFY: rejecting call to Lorg/spongycastle/mail/smime/handlers/PKCS7ContentHandler;. (Ljavax/activation/ActivationDataFlavor;[Ljava/awt/datatransfer/DataFlavor;)V
11-21 13:30:53.405: W/dalvikvm(10025): VFY: rejecting opcode 0x70 at 0x0004
11-21 13:30:53.410: W/dalvikvm(10025): VFY: rejected Lorg/spongycastle/mail/smime/handlers/pkcs7_mime;. ()V
11-21 13:30:53.410: W/dalvikvm(10025): Verifier rejected class Lorg/spongycastle/mail/smime/handlers/pkcs7_mime;
11-21 13:30:53.415: W/dalvikvm(10025): Class init failed in newInstance call (Lorg/spongycastle/mail/smime/handlers/pkcs7_mime;)

As i understand BC uses java.awt classes which do not exist on Android

@gusak
Copy link
Author

gusak commented Nov 21, 2012

i found this
http://stackoverflow.com/questions/13357855/how-to-fix-error-of-spongy-castle-on-android-could-not-find-class-java-awt-data

but it didn't work for me. if someone can try it i would appreciate for explanation

@rtyley
Copy link
Owner

rtyley commented Nov 21, 2012

Thanks for this report, I've not used the scmail functionality in anger (which is why it's marked as alpha on the project page) and I'm relying on feedback from users to judge stability.

Uses of java.awt classes are restricted to just the single class java.awt.datatransfer.DataFlavor and are all within this package:

https://github.com/rtyley/spongycastle/tree/sc-parent-1.47.0.2/scmail-jdk15on/src/main/java/org/spongycastle/mail/smime/handlers

Unfortunately the use of this class appears to be made necessary because several classes implement javax.activation.DataContentHandler which references it. I've only had a chance to take a brief look, it might make sense to just remove use of the DataContentHandler interface but I'm not sure of the knock-on effect of this.

The stackoverflow answer you reference above seems to give one line of attack, basically using the http://code.google.com/p/javamail-android project to use custom javamail & activation libs that don't reference the java.awt.datatransfer.DataFlavor class.

I don't have much time to look at this right now, but would love to hear of any progress you make.

@fuyiming
Copy link

what about this link , i meet the same problem as you. i am trying to solve it . https://code.google.com/p/androidmagnus/source/browse/trunk/Magnus/src/java/awt/datatransfer/DataFlavor.java?r=3

@rtyley
Copy link
Owner

rtyley commented Jan 26, 2014

Due to the problems with unavailable classes, support for bc-mail has been dropped completely as of v1.50. Pull requests are welcome tho- make sure you use the new Spongy Castle repo- same place the old one was: https://github.com/rtyley/spongycastle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants