On 6 December 2011 15:12, gs84 wrote:
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
I don't really know what I am talking about here, but that line tries
to call method PrivateKeyEntry on class KeyStore. Is PrivateKeyEntry
not in fact a class? Should it be KeyStore::PrivateKeyEntry or
something along those lines?

Colin
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.


--
gplus.to/clanlaw

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

Discussion Posts

Previous

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 7 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedDec 6, '11 at 3:12p
activeDec 7, '11 at 1:44p
posts7
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Gs84: 4 posts Colin Law: 3 posts

People

Translate

site design / logo © 2021 Grokbase