Good morning,

I am trying to use the Java's Xades signature with JRuby in my Ruby on
Rails application.
But since two days now, i am facing the following errors without
getting any response to solve them.

This is the corresponding java code from this page:
http://java.sun.com/developer/technicalArticles/xml/dig_signature_api/

Load the KeyStore and get the signing key and certificate.
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream("mykeystore.jks"),
"changeit".toCharArray());
KeyStore.PrivateKeyEntry keyEntry =
    (KeyStore.PrivateKeyEntry) ks.getEntry
        ("mykey", new
KeyStore.PasswordProtection("changeit".toCharArray()));
X509Certificate cert = (X509Certificate) keyEntry.getCertificate();

// Create the KeyInfo containing the X509Data.
KeyInfoFactory kif = fac.getKeyInfoFactory();
List x509Content = new ArrayList();
x509Content.add(cert.getSubjectX500Principal().getName());
x509Content.add(cert);
X509Data xd = kif.newX509Data(x509Content);
KeyInfo ki = kif.newKeyInfo(Collections.singletonList(xd));


My corresponding JRuby code is the following:

require 'java'

include_class 'java.lang.System'
include_class 'java.lang.Object'
include_class('java.lang.String'){|package,name| "J#{name}"}
include_class 'java.io.IOException'
include_class 'java.io.InputStream'
include_class 'java.io.FileOutputStream'
include_class 'java.io.FileInputStream'
include_class 'java.security.KeyStore'
include_class 'java.security.KeyStoreException'

password = JString.new("changeit")
ks = KeyStore.getInstance("JKS")
ks.load(FileInputStream.new("keys/keystoreCps.jks"),
password.toCharArray())

keyEntry = KeyStore.PrivateKeyEntry.new
keyEntry = ks.getEntry("mykey",
KeyStore.PasswordProtection.new(password.toCharArray()))
cert = keyEntry.getCertificate()

#Create the KeyInfo containing the X509Data.
kif = sigFactory.getKeyInfoFactory()
x509Content = ArrayList.new
x509Content.add(cert.getSubjectX500Principal().getName())
x509Content.add(cert)
xd = kif.newX509Data(x509Content)
ki = kif.newKeyInfo(Collections.singletonList(xd))


So i am getting these errors with these 2 lines:
keyEntry = KeyStore.PrivateKeyEntry.new
keyEntry = ks.getEntry("mykey",
KeyStore.PasswordProtection.new(password.toCharArray())):

1) NoMethodError: undefined method `PrivateKeyEntry' for
Java::JavaSecurity::KeyStore:Class
2)  undefined method `PasswordProtection' for
Java::JavaSecurity::KeyStore:Class


I have visited this javadoc site, but still don't know how to solve
those problems

Kindly help me solve these errors.
Thanks in advance for your responses

Regards,
--

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to