Coder Social home page Coder Social logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
Hi. You're going in the right direction by using that constructor of 
PKCS11KeyStoreKeyingDataProvider. The class has different constructors for 
different scenarios. If you check the java docs, the parameters that are being 
passed null are key store and entry password providers, respectively. Some 
smart card native libraries handle PIN requests on their own; that's why the 
parameters can be null.

On your scenario you need to specify a KeyStorePasswordProvider. An interface 
is used instead of directly supplying the password to allow scenarios where the 
password is obtained on demand (from user input, for instance).

Hope this helps. I'm leaving this issue open until you come back with some 
feedback. In the future please use the Q&A wiki section since this isn't really 
an issue.

Original comment by luis.fgoncalv on 26 Feb 2012 at 9:48

  • Added labels: Type-Other
  • Removed labels: Type-Defect

from xades4j.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
Hi,
Thank you very much for prompt answer and sorry for publishing to issues.

Unfortunately I am just starting work with java, and although read some books, 
have almost no practical knowledge, that's way shame on me, but probably I am 
asking for trivial thing.

Before and after posting the first post I was experimenting with passing 
arguments, but I was unable to initiate (or pass) the 
KeyStoreKeyingDataProvider.KeyStorePasswordProvider properly.

Finally I understood, and it is the first time I managed to run the code ... 
simple I just needed to implement the KeyStorePasswordProvider, just according 
to your advice, so I put into my code:

public class KeyStorePasswordProvider implements 
KeyStoreKeyingDataProvider.KeyStorePasswordProvider{
    @Override
    public char[] getPassword() {
    String password="mypassword";
    return password.toCharArray();
    }
}

and

keyingDataProvider = new PKCS11KeyStoreKeyingDataProvider(
    nativeLibrary,
    providerName,
    new FirstCertificateSelector(),
    new KeyStorePasswordProvider(),
    null,
    true);

System.out.println(keyingDataProvider.getSigningCertificateChain().toString());


however

1. get the exception:

2012-02-27 01:16:13 main main
SEVERE: null
java.security.KeyStoreException: Can't initialize Sun PKCS#11 security provider.
Reason: xades4j.verification.UnexpectedJCAException: The keystore couldn't be 
initialized
        at XadES.XADES.getSigningCertificateChain(XADES.java:45)
        at main.main(main.java:13)


2. Although I implemented the interface, I don't understand how can I pass card 
password (now it is just written in the code).


Could you help me further please.

Thanks in advance

Brgs
Norbert

Original comment by [email protected] on 27 Feb 2012 at 12:18

from xades4j.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
When you get some sleep, you think better :-)
Just realized that I can add a constructor and pass the password via the 
constructor. 

public class KeyStorePasswordProvider implements 
KeyStoreKeyingDataProvider.KeyStorePasswordProvider{
    private String password;

    @Override
    public char[] getPassword() {
    return password.toCharArray();
    }

    public KeyStorePasswordProvider(String password) {
    this.password=password;
    }

}

Now, I successfully accessed my smartcard.
More questions will send through Q&A.

Thank you very much for your help.


Brgs
Norbert

Original comment by [email protected] on 27 Feb 2012 at 8:55

from xades4j.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
Yes, that would be it. You're welcome!

Original comment by luis.fgoncalv on 27 Feb 2012 at 9:30

  • Changed state: Invalid

from xades4j.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 14, 2024
hi
you can to share for me this source code? thanks alot

Original comment by [email protected] on 30 Jul 2012 at 3:33

from xades4j.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.