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

BindingSourceRestriction uses some methods missing in Java implementation for Android #265

Closed
RafaRioFal4699 opened this issue Oct 18, 2022 · 4 comments

Comments

@RafaRioFal4699
Copy link

RafaRioFal4699 commented Oct 18, 2022

I'm trying to make a signature method in order to accomplish some governmental requirements in my app.
I followed the steps mentioned in this issue #134 but at the moment of sign my XML, i found this exception:

FATAL EXCEPTION: main
    Process: com.example.xmlsigning, PID: 6946
    java.lang.NoSuchMethodError: No virtual method getAnnotatedSuperclass()Ljava/lang/reflect/AnnotatedType; in class Ljava/lang/Class; or its super classes (declaration of 'java.lang.Class' appears in /apex/com.android.art/javalib/core-oj.jar)
    at com.google.inject.spi.BindingSourceRestriction.getPermits(BindingSourceRestriction.java:343)
    at com.google.inject.spi.BindingSourceRestriction.access$500(BindingSourceRestriction.java:50)
    at com.google.inject.spi.BindingSourceRestriction$PermitMapConstruction.pushModule(BindingSourceRestriction.java:306)
    at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:396)
    at com.google.inject.spi.Elements.getElements(Elements.java:108)
    at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:160)
    at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
    at com.google.inject.Guice.createInjector(Guice.java:87)
    at com.google.inject.Guice.createInjector(Guice.java:69)
    at com.google.inject.Guice.createInjector(Guice.java:59)
    at xades4j.utils.XadesProfileCore.getInstance(XadesProfileCore.java:236)
    at xades4j.production.XadesSigningProfile.newSigner(XadesSigningProfile.java:110)
    at com.example.xmlsigning.MainActivity.SignXML(MainActivity.java:196)
    at com.example.xmlsigning.MainActivity$1.onClick(MainActivity.java:74)
    at android.view.View.performClick(View.java:7792)
    at android.view.View.performClickInternal(View.java:7769)
    at android.view.View.access$3800(View.java:910)
    at android.view.View$PerformClick.run(View.java:30218)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:226)
    at android.os.Looper.loop(Looper.java:313)
    at android.app.ActivityThread.main(ActivityThread.java:8751)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)

After a while, I found Android's implementation of Class Java class haven't got this specific method getAnnotatedSuperClass() and also it differs so much from Java's classic class Class:
image
Source: java.lang.Class reference from Android Developers (https://developer.android.com/reference/java/lang/Class)

So here it goes my question: Is this intended? Or haven't this API been desinged for Android?
In any case, I will thank you If you could provide me some help.

Thank you in advance

Addition: I don't know if it's important, but I'm using the EPES Signer Profile

@luisgoncalves
Copy link
Owner

As you probably noticed in the stack trace, xades4j internally uses Guice for dependency injection. Guice relies on reflection and other stuff that doesn't seem to work well on Android. I've had the goal to remove the DI container altogether, but that's a big task, probably with breaking changes, so I never did it.

In any case, xades4j was not developed nor tested with Android in mind.

Also see the info on: #154

@RafaRioFal4699
Copy link
Author

Okey, thanks for your answer. One last question, do you know or have you heard about another API with the same function but made for Android?

@luisgoncalves
Copy link
Owner

I don't know :/

There's a library endorsed by the EC: https://ec.europa.eu/digital-building-blocks/DSS/webapp-demo/doc/dss-documentation.html. It supports more than xades4j. Never tested it, though.

@RafaRioFal4699
Copy link
Author

Thanks, I will take a look

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

No branches or pull requests

2 participants