[jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Carl Bourne
Hi,

I need to do the equivalent of this in JRuby:--

PKCS10CertificationRequest csr = csrBuilder.build(signer);

Which equates to what I think is casting a 
"org.bouncycastle.pkcs.PKCS10CertificationRequestHolder" object to a  
"org.bouncycastle.pkcs.PKCS10CertificationRequest" object.

Is this possible?

Regards,

Carl

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Charles Oliver Nutter
There's no casting (in the usual Java sense) required in JRuby; if the
methods exist, they'll be callable. Just go with it :)

- Charlie

On Wed, Oct 17, 2012 at 1:08 PM, Carl Bourne  wrote:
> Hi,
>
> I need to do the equivalent of this in JRuby:--
>
> PKCS10CertificationRequest csr = csrBuilder.build(signer);
>
> Which equates to what I think is casting a 
> "org.bouncycastle.pkcs.PKCS10CertificationRequestHolder" object to a  
> "org.bouncycastle.pkcs.PKCS10CertificationRequest" object.
>
> Is this possible?
>
> Regards,
>
> Carl
>
> -
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Carl Bourne
Charles, 

Maybe I'm getting my terminology mixed up here. 

I basically have two different types of object . 

>> PKCS10CertificationRequestHolder and a 
>> PKCS10CertificationRequest 

In order for me to pass the holder object to another class the holder object 
needs to be just a request object as per my Java example. I may be missing 
something obvious here, but how would I do this in JRuby?

Regards,

Carl


Carl Bourne | Senior Sales Engineer | mobile: +44 (0) 7770 284294 | 
www.venafi.com

On 17 Oct 2012, at 19:43, Charles Oliver Nutter  wrote:

> There's no casting (in the usual Java sense) required in JRuby; if the
> methods exist, they'll be callable. Just go with it :)
> 
> - Charlie
> 
> On Wed, Oct 17, 2012 at 1:08 PM, Carl Bourne  wrote:
>> Hi,
>> 
>> I need to do the equivalent of this in JRuby:--
>> 
>> PKCS10CertificationRequest csr = csrBuilder.build(signer);
>> 
>> Which equates to what I think is casting a 
>> "org.bouncycastle.pkcs.PKCS10CertificationRequestHolder" object to a  
>> "org.bouncycastle.pkcs.PKCS10CertificationRequest" object.
>> 
>> Is this possible?
>> 
>> Regards,
>> 
>> Carl
>> 
>> -
>> To unsubscribe from this list, please visit:
>> 
>>http://xircles.codehaus.org/manage_email
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Charles Oliver Nutter
Yes, I think I was confused by your terminology.

Assuming the original Java code is right, here's the Ruby code:

csr = csrBuilder.build(signer)

- Charlie

On Wed, Oct 17, 2012 at 2:03 PM, Carl Bourne  wrote:
> Charles,
>
> Maybe I'm getting my terminology mixed up here.
>
> I basically have two different types of object .
>
>>> PKCS10CertificationRequestHolder and a
>>> PKCS10CertificationRequest
>
> In order for me to pass the holder object to another class the holder object 
> needs to be just a request object as per my Java example. I may be missing 
> something obvious here, but how would I do this in JRuby?
>
> Regards,
>
> Carl
>
>
> Carl Bourne | Senior Sales Engineer | mobile: +44 (0) 7770 284294 | 
> www.venafi.com
>
> On 17 Oct 2012, at 19:43, Charles Oliver Nutter  wrote:
>
>> There's no casting (in the usual Java sense) required in JRuby; if the
>> methods exist, they'll be callable. Just go with it :)
>>
>> - Charlie
>>
>> On Wed, Oct 17, 2012 at 1:08 PM, Carl Bourne  wrote:
>>> Hi,
>>>
>>> I need to do the equivalent of this in JRuby:--
>>>
>>> PKCS10CertificationRequest csr = csrBuilder.build(signer);
>>>
>>> Which equates to what I think is casting a 
>>> "org.bouncycastle.pkcs.PKCS10CertificationRequestHolder" object to a  
>>> "org.bouncycastle.pkcs.PKCS10CertificationRequest" object.
>>>
>>> Is this possible?
>>>
>>> Regards,
>>>
>>> Carl
>>>
>>> -
>>> To unsubscribe from this list, please visit:
>>>
>>>http://xircles.codehaus.org/manage_email
>>
>> -
>> To unsubscribe from this list, please visit:
>>
>>http://xircles.codehaus.org/manage_email
>>
>>
>
> -
> To unsubscribe from this list, please visit:
>
> http://xircles.codehaus.org/manage_email
>
>

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Carl Bourne
Oliver yes I did try that but it still doesn't seem to work as I would expect. 

Heres a bit more background to the problem. 

Using this Java code:

// Generate the certificate signing request
PKCS10CertificationRequestBuilder csrBuilder = new 
PKCS10CertificationRequestBuilder(entityName, publicKeyInfo);

csrBuilder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword, new 
DERPrintableString(new String("lexicon".toCharArray(;
ContentSigner signer = signerBuilder.build(entityPair.getPrivate());
PKCS10CertificationRequest csr = csrBuilder.build(signer);
   System.out.println(csr);

It returns this:

org.bouncycastle.pkcs.PKCS10CertificationRequest@ba259522


However when I try to do the same using JRuby with this code:

// Generate the certificate signing request
csrbuilder = PKCS10CertificationRequestBuilder.new(entityname, publickeyinfo )
password = String.new("password").toCharArray
csrbuilder.addAttribute(PKCSObjectIdentifiers::pkcs_9_at_challengePassword, 
DERPrintableString.new(String.new(password))) 
signer = signerbuilder.build(entitypair.getPrivate)
csr = csrbuilder.build(signer)
puts csr

It returns this:

org.bouncycastle.pkcs.PKCS10CertificationRequestHolder@c06a2100

Instead of returning org.bouncycastle.pkcs.PKCS10CertificationRequest object.




On 17 Oct 2012, at 20:07, Charles Oliver Nutter  wrote:

> Yes, I think I was confused by your terminology.
> 
> Assuming the original Java code is right, here's the Ruby code:
> 
> csr = csrBuilder.build(signer)
> 
> - Charlie
> 
> On Wed, Oct 17, 2012 at 2:03 PM, Carl Bourne  wrote:
>> Charles,
>> 
>> Maybe I'm getting my terminology mixed up here.
>> 
>> I basically have two different types of object .
>> 
 PKCS10CertificationRequestHolder and a
 PKCS10CertificationRequest
>> 
>> In order for me to pass the holder object to another class the holder object 
>> needs to be just a request object as per my Java example. I may be missing 
>> something obvious here, but how would I do this in JRuby?
>> 
>> Regards,
>> 
>> Carl
>> 
>> 
>> Carl Bourne | Senior Sales Engineer | mobile: +44 (0) 7770 284294 | 
>> www.venafi.com
>> 
>> On 17 Oct 2012, at 19:43, Charles Oliver Nutter  wrote:
>> 
>>> There's no casting (in the usual Java sense) required in JRuby; if the
>>> methods exist, they'll be callable. Just go with it :)
>>> 
>>> - Charlie
>>> 
>>> On Wed, Oct 17, 2012 at 1:08 PM, Carl Bourne  wrote:
 Hi,
 
 I need to do the equivalent of this in JRuby:--
 
 PKCS10CertificationRequest csr = csrBuilder.build(signer);
 
 Which equates to what I think is casting a 
 "org.bouncycastle.pkcs.PKCS10CertificationRequestHolder" object to a  
 "org.bouncycastle.pkcs.PKCS10CertificationRequest" object.
 
 Is this possible?
 
 Regards,
 
 Carl
 
 -
 To unsubscribe from this list, please visit:
 
   http://xircles.codehaus.org/manage_email
>>> 
>>> -
>>> To unsubscribe from this list, please visit:
>>> 
>>>   http://xircles.codehaus.org/manage_email
>>> 
>>> 
>> 
>> -
>> To unsubscribe from this list, please visit:
>> 
>>http://xircles.codehaus.org/manage_email
>> 
>> 
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 


-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-17 Thread Charles Oliver Nutter
On Wed, Oct 17, 2012 at 6:44 PM, Carl Bourne  wrote:
> Using this Java code:
>
> // Generate the certificate signing request
> PKCS10CertificationRequestBuilder csrBuilder = new 
> PKCS10CertificationRequestBuilder(entityName, publicKeyInfo);
> 
> csrBuilder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword, 
> new DERPrintableString(new String("lexicon".toCharArray(;
> ContentSigner signer = 
> signerBuilder.build(entityPair.getPrivate());
> PKCS10CertificationRequest csr = csrBuilder.build(signer);
>System.out.println(csr);
>
> It returns this:
>
> org.bouncycastle.pkcs.PKCS10CertificationRequest@ba259522
>
>
> However when I try to do the same using JRuby with this code:
>
> // Generate the certificate signing request
> csrbuilder = PKCS10CertificationRequestBuilder.new(entityname, publickeyinfo )
> password = String.new("password").toCharArray
> csrbuilder.addAttribute(PKCSObjectIdentifiers::pkcs_9_at_challengePassword, 
> DERPrintableString.new(String.new(password)))
> signer = signerbuilder.build(entitypair.getPrivate)
> csr = csrbuilder.build(signer)
> puts csr
>
> It returns this:
>
> org.bouncycastle.pkcs.PKCS10CertificationRequestHolder@c06a2100
>
> Instead of returning org.bouncycastle.pkcs.PKCS10CertificationRequest object.

Well that's very strange. Since you obviously have all the right types
up to the last build call, perhaps it's choosing the wrong build()
method? Is there one that returns a holder?

Oh, another thought...perhaps you're picking up JRuby's built-in
BouncyCastle, which is a bit older than the most recent version and
may have API differences? Perhaps build returns a "Holder" in our
version of BC?

- Charlie

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread Carl Bourne
Charles,

Indeed it seems to be an issue with JRuby 1.7 RC2 and maybe the included BC 
libraries. 

If switch back to JRuby 1.6 I get the expected result.

org.bouncycastle.pkcs.PKCS10CertificationRequest@206b4e2

Is there an easy way to exclude the included BC libraries?

Regards,

Carl

On 18 Oct 2012, at 02:29, Charles Oliver Nutter  wrote:

> On Wed, Oct 17, 2012 at 6:44 PM, Carl Bourne  wrote:
>> Using this Java code:
>> 
>> // Generate the certificate signing request
>>PKCS10CertificationRequestBuilder csrBuilder = new 
>> PKCS10CertificationRequestBuilder(entityName, publicKeyInfo);
>>
>> csrBuilder.addAttribute(PKCSObjectIdentifiers.pkcs_9_at_challengePassword, 
>> new DERPrintableString(new String("lexicon".toCharArray(;
>>ContentSigner signer = 
>> signerBuilder.build(entityPair.getPrivate());
>>PKCS10CertificationRequest csr = csrBuilder.build(signer);
>>   System.out.println(csr);
>> 
>> It returns this:
>> 
>> org.bouncycastle.pkcs.PKCS10CertificationRequest@ba259522
>> 
>> 
>> However when I try to do the same using JRuby with this code:
>> 
>> // Generate the certificate signing request
>> csrbuilder = PKCS10CertificationRequestBuilder.new(entityname, publickeyinfo 
>> )
>> password = String.new("password").toCharArray
>> csrbuilder.addAttribute(PKCSObjectIdentifiers::pkcs_9_at_challengePassword, 
>> DERPrintableString.new(String.new(password)))
>> signer = signerbuilder.build(entitypair.getPrivate)
>> csr = csrbuilder.build(signer)
>> puts csr
>> 
>> It returns this:
>> 
>> org.bouncycastle.pkcs.PKCS10CertificationRequestHolder@c06a2100
>> 
>> Instead of returning org.bouncycastle.pkcs.PKCS10CertificationRequest object.
> 
> Well that's very strange. Since you obviously have all the right types
> up to the last build call, perhaps it's choosing the wrong build()
> method? Is there one that returns a holder?
> 
> Oh, another thought...perhaps you're picking up JRuby's built-in
> BouncyCastle, which is a bit older than the most recent version and
> may have API differences? Perhaps build returns a "Holder" in our
> version of BC?
> 
> - Charlie
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 


-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread kristian
when I used jruby-core maven artifact and replaced the bouncy-castle
artifact the built in SSL support of jruby did not work any more.
maybe the build SSL support of jruby s of no importance for you then
that is way to go.

- Kristian

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread Carl Bourne
Thanks Kristian,

Unfortunately I will need to use the SSL support!

Any other work arounds be greatly appreciated.

Regards,

Carl

On 18 Oct 2012, at 09:52, kristian  wrote:

> when I used jruby-core maven artifact and replaced the bouncy-castle
> artifact the built in SSL support of jruby did not work any more.
> maybe the build SSL support of jruby s of no importance for you then
> that is way to go.
> 
> - Kristian
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 


-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread kristian
jruby NEEDS the slightly older version of BC and you need jruby's SSL
support, so the last possibility for you is to use that very same
version of BC as jruby !

I am sure jruby will support other versions of BC in one of its coming
releases ;) actually it would be nice to have IMO.

- Kristian

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread Carl Bourne
Thanks Kristian,

What's the best way to replace the BC .jar provided with JRuby with the same 
version as provided by BC?

Can I just download and reference the older version in my JRuby script, or do I 
need to remove the version that comes with JRuby and replace it?

Carl


On 18 Oct 2012, at 11:06, kristian  wrote:

> jruby NEEDS the slightly older version of BC and you need jruby's SSL
> support, so the last possibility for you is to use that very same
> version of BC as jruby !
> 
> I am sure jruby will support other versions of BC in one of its coming
> releases ;) actually it would be nice to have IMO.
> 
> - Kristian
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 


-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread kristian
JRUBY uses
org.bouncycastle:bcmail-jdk15on:jar:1.46
org.bouncycastle:bcprov-jdk15on:jar:1.46

for testing you can just prepend them to your bootclassloader - something like
jruby -J-Xbootclasspath/p:bcmail-jdk15on.jar:bcprov-jdk15on.jar

but doing so with BC version 1.47 did not work for me (the openssl bit
of jruby).

but I rather doubt that this will work - see also
http://www.bouncycastle.org/wiki/display/JA1/Porting+from+earlier+BC+releases+to+1.47+and+later

with regards,
Kristian

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread Carl Bourne
Thanks Kristian

All a little messy I guess - Hopefully this incompatibility will be fixed soon.

Thanks for your advice!

On 18 Oct 2012, at 11:06, kristian  wrote:

> jruby NEEDS the slightly older version of BC and you need jruby's SSL
> support, so the last possibility for you is to use that very same
> version of BC as jruby !
> 
> I am sure jruby will support other versions of BC in one of its coming
> releases ;) actually it would be nice to have IMO.
> 
> - Kristian
> 
> -
> To unsubscribe from this list, please visit:
> 
>http://xircles.codehaus.org/manage_email
> 
> 


-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email




Re: [jruby-dev] Casting to different types in JRuby

2012-10-18 Thread Charles Oliver Nutter
On Thu, Oct 18, 2012 at 6:54 AM, kristian  wrote:
> JRUBY uses
> org.bouncycastle:bcmail-jdk15on:jar:1.46
> org.bouncycastle:bcprov-jdk15on:jar:1.46
>
> for testing you can just prepend them to your bootclassloader - something like
> jruby -J-Xbootclasspath/p:bcmail-jdk15on.jar:bcprov-jdk15on.jar
>
> but doing so with BC version 1.47 did not work for me (the openssl bit
> of jruby).
>
> but I rather doubt that this will work - see also
> http://www.bouncycastle.org/wiki/display/JA1/Porting+from+earlier+BC+releases+to+1.47+and+later

We have an open issue to port to the newer BC. Help wanted :)

- Charlie

-
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email