You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Josep Riudavets <jr...@uoc.edu> on 2003/09/23 11:45:30 UTC

Cocoon + IXSIL

Hi ... My name is Josep, from Barcelona (Spain).

I'm trying to develop a XSP page, including an instance of my own class:
 
<?xml version="1.0" encoding="UTF-8"?>
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>
<xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:esql="http://apache.org/cocoon/SQL/v2">
<xsp:structure>
<xsp:include>edu.uoc.riudavets.CrearSignatura</xsp:include>
<xsp:include>java.io.*</xsp:include>
</xsp:structure>
<procesa>
<xsp:logic>
String a00 = "/usr/local/tomcat/webapps/cocoon/fitxers/usuaria.p12";
String a11 = "federicoa";
String a22 = "/usr/local/tomcat/webapps/cocoon/fitxers/exped.xml";
CrearSignatura cs = new CrearSignatura();
cs.Signar(a00,a11,a22);
</xsp:logic>
</esql:connection>
</procesa>
</xsp:page>


This class is placed into a package "edu.uoc.riudavets" under WEB-INF/classes. 

My problem: when I execute this class out of Cocoon, with a java IDE, it works perfectly. Buy when I catch the class and I put the package into WEB-INF/classes in order to use with Cocoon, it does not work. Cocoon recognize the package and the cass, with its constructor ... but Cocoon does not execute it !!!

I'm using Cocoon2 under Tomcat 4.1 and J2SDK 1.4. The class I have created uses IXSIL_1_1 libraries.

I have a doubt: if the class uses a lot of IXSIL libraries, have I to put these these libraries under WEB-INF/lib directory? Does Cocoon see the libraries that are included ("import") into the class that I have created? And does Tomcat see them?

Sorry about my English ... I hope to learn more in next months!!!

Thanks a lot.


CrearSignatura.java

package edu.uoc.riudavets;

import java.io.*;
import java.security.PublicKey;

import java.security.interfaces.RSAPrivateKey;

import org.apache.xerces.parsers.*;
import org.w3c.dom.*;
import iaik.x509.*; 
import iaik.pkcs.pkcs12.*;
import iaik.ixsil.core.*;
import iaik.ixsil.algorithms.*;
import iaik.ixsil.init.*;
import iaik.ixsil.util.*;
import iaik.ixsil.keyinfo.x509.*;
import iaik.ixsil.keyinfo.*;

public class CrearSignatura{
public CrearSignatura(){
}
public void Signar(String args[]){
PKCS12 p12 = null;
KeyBag bossa = null;
X509Certificate X509cert=null;
X509Certificate[] certs = new X509Certificate[1];
RSAPrivateKey sk = null;
PublicKey pk = null;
iaik.security.provider.IAIK.addAsProvider(true);
BufferedReader entrada = new BufferedReader(new InputStreamReader(System.in));
try{
IXSILInit.init(new URI("file", null, "C://j2sdk//IAIK-XML//init//properties//init.properties", null, null));
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}
try{
FileInputStream p12_f = new FileInputStream(args[0]);
p12 = new PKCS12(p12_f);
}catch(Exception e){
e.printStackTrace();
System.exit(1);
}
try{
System.out.println("\nIntentado Decrypt...\n");
char[] password = args[1].toCharArray();
p12.decrypt(password);
System.out.println("Decrypt realizado!!!\n");
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}
try{
System.out.println("Intentado obtener KeyBag...\n");
bossa = p12.getKeyBag();
System.out.println("KeyBag obtenido!!!\n");
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}
try{
System.out.println("Extrayendo Clave Privada...\n");
sk = (RSAPrivateKey)bossa.getPrivateKey();
System.out.println("Clave Privada guardada!!!\n");
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}
try{
System.out.println("Extrayendo Clave Publica...\n");
CertificateBag[] cb = p12.getCertificateBags();
X509cert = new X509Certificate();
X509cert = cb[0].getCertificate();
FileOutputStream cert_fitxer=new FileOutputStream("certificat_uocTest.cer");
X509cert.writeTo(cert_fitxer); 
cert_fitxer.close();
pk=X509cert.getPublicKey(); 
System.out.println("Clave Publica guardada!!!\n");
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}

try{
/*System.out.println("Extraccio dades a signar...\n");
FileInputStream fitxer = new FileInputStream(args[2]); 
byte[] body = new byte[fitxer.available()];
System.out.println("Dades a signar capturades!!!\n");*/
URI baseURI = new URI("file", null,args[2], null, null);
DOMParser parser = new DOMParser();
parser.parse(args[2]);
Document document = parser.getDocument();
Signer signer = new Signer(document, baseURI, new Position("/cad", null, 0));
SignerSignature signature = signer.getSignature();
SignerSignedInfo signedInfo = signer.getSignature().getSignerSignedInfo();

KeyManagerImpl keyManager = new KeyManagerImpl(signer.toDocument());
keyManager.setId("KeyInfo");
KeyProviderImplX509Data x509KeyProvider = new KeyProviderImplX509Data(signer.toDocument());
X509Data x509CertificateData = new X509Data();
x509CertificateData.insertHintAt(X509cert, 0);
x509KeyProvider.insertX509DataAt(x509CertificateData, 0);
keyManager.addKeyProvider(x509KeyProvider);
signature.setKeyManager(keyManager);
CanonicalizationAlgorithmImplCanonicalXML c14nAlg = new CanonicalizationAlgorithmImplCanonicalXML();
signedInfo.setCanonicalizationAlgorithm(c14nAlg);
SignatureAlgorithmImplRSA signatureAlg = new SignatureAlgorithmImplRSA();
signatureAlg.setSignerKey(sk);
signedInfo.setSignatureAlgorithm(signatureAlg);
SignerReference reference = signedInfo.createReference();
reference.setURI(new URI(""));
TransformImplEnvelopedSignature env = new TransformImplEnvelopedSignature();
reference.insertTransformAt(env, 0);
DigestAlgorithmImplSHA1 digestAlg = new DigestAlgorithmImplSHA1();
signedInfo.setSignatureAlgorithm(signatureAlg);
reference.setDigestAlgorithm(digestAlg);
signedInfo.addReference(reference);
// Add key info.
SignerReference keyInfo = signedInfo.createReference();
// Set reference URI
keyInfo.setURI(new URI("#KeyInfo"));
// Create new instance of digest algorithm
DigestAlgorithmImplSHA1 digestAlg1 = new DigestAlgorithmImplSHA1();
// Set digest algorithm
keyInfo.setDigestAlgorithm(digestAlg1);
// Add reference to signature
signedInfo.addReference(keyInfo);
signer.getSignature().sign();
/*digestAlg.setInput(new FileInputStream(args[2]));
InputStream out_t = digestAlg.digest();
signatureAlg.setInput(out_t);
InputStream out_t2 = signatureAlg.sign();*/
Document d = signer.toDocument();
FileOutputStream outputXMLDoc = new FileOutputStream("out.xml");
DOMUtilsImpl domUtilitites = new DOMUtilsImpl();
domUtilitites.serializeDocument(d, outputXMLDoc);
}catch(Exception ex){
ex.printStackTrace();
System.exit(1); 
}
}

}



Re: Cocoon + IXSIL

Posted by Ugo Cei <u....@cbim.it>.
Josep Riudavets wrote:
> Hi ... My name is Josep, from Barcelona (Spain).
> 
> I'm trying to develop a XSP page, including an instance of my own class:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>

These processing instructions are from Cocoon 1. You don't need to use 
them for Cocoon 2.

> I'm using Cocoon2 under Tomcat 4.1 and J2SDK 1.4. The class I have 
> created uses IXSIL_1_1 libraries.

Can you show us the sitemap pipeline you're using to generate this page?

	Ugo

-- 
Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
Phone: +39.0382.525100 - E-mail: u.cei@cbim.it


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Josep Riudavets dijo:
> I have removed next lines
> <?cocoon-process type="xsp"?>
> <?cocoon-process type="xslt"?>
>
> from my XSP page, because I'm using Cocoon 2.1.
>
> And this is the pipeline that I use to generate the page :
>
> <map:pipeline>
> <map:match pattern="*.xsp">
> <map:generate type="serverpages" src="XSP/{1}.xsp"/>
> <map:transform src="XSL/{1}.xsl"/>
> <map:serialize type="html"/>
> </map:match>
> </map:pipeline>
>
>
> I think the problem resides in IXSIL libraries. These libraries are used
> in order to implement XML-dSig stardard.
>
> When I created my class, it works perfectly. But when I try to use this
> class from Cocoon, it does not recognize IXSIL libraries. Where do I
> have to place IXSIL jars in order to be recognized by Cocoon? I have put
> them into /WEB-INF/lib directory, but it is not enough. The jars that
> form these libraries are:
>
> IXSIL_1_1_0_XXX.jar The actual IXSIL libraray.
> xalan.jar
> xml-apis.jar
> runtime.jar
> bsf.jar
> xerces.jar

Check this: http://wiki.cocoondev.org/Wiki.jsp?page=MigrateToCocoon2

About the libraries... if you are using Tomcat 4.1.x, copy these files:

xalan.jar
xml-apis.jar
xerces.jar

in your $TOMCAT/common/endorsed directory.

More info: http://wiki.cocoondev.org/Wiki.jsp?page=EndorsedLibsProblem

Best Regards,

Antonio Gallardo




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Josep Riudavets dijo:
> Ok, new versions of xalan, xerces and xml-apis ara now at
> /tomcat/common/endorsed. And I have also placed them into
> /j2sdk/jre/lib/ext/endorsed

Try to put the IXSIL libraries into WEB-INF/lib?

Best Regards,

Antonio Gallardo




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Josep Riudavets dijo:
>> Try to put the IXSIL libraries into WEB-INF/lib?
>
> It's the first thing I tried !!!
>
> Do you know if Cocoon recognizes jars placed under /j2sdk/jre/lib/ext ?
> I have placed IAIK jars there, and OK ... but when I place there IXSIL,
> wrong !!!

What about $Tomcat/commons/endorsed?

Best Regards,

Antonio Gallardo




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Antonio Gallardo <ag...@agsoftware.dnsalias.com>.
Can be this the sources of your problems?

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20308

Best Regards,

Antonio Gallardo




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Josep Riudavets <jr...@uoc.edu>.
> What about $Tomcat/commons/endorsed?

Yes, I have placed xalan, xerces and xml-apis there, too.

But I have detected a strage detail: when I put IXSIL_1_1_0_Evaluation.jar
into /j2sdk/jre/lib/ext, Cocoon fails. It seems that there's a conflict
between IXSIL libraries and other Java libraries. Cocoon does not like the
IXSIL libraries to be into some directories.

I think xalan and xerces works perfectly, because Cocoon works OK if I don't
instantiate my own classes(which use IXSIL) in the XSP page


----- Original Message -----
From: "Antonio Gallardo" <ag...@agsoftware.dnsalias.com>
To: <us...@cocoon.apache.org>
Sent: Monday, September 29, 2003 1:59 PM
Subject: Re: Cocoon + IXSIL


> Josep Riudavets dijo:
> >> Try to put the IXSIL libraries into WEB-INF/lib?
> >
> > It's the first thing I tried !!!
> >
> > Do you know if Cocoon recognizes jars placed under /j2sdk/jre/lib/ext ?
> > I have placed IAIK jars there, and OK ... but when I place there IXSIL,
> > wrong !!!
>
> What about $Tomcat/commons/endorsed?
>
> Best Regards,
>
> Antonio Gallardo
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Josep Riudavets <jr...@uoc.edu>.
> Try to put the IXSIL libraries into WEB-INF/lib?

It's the first thing I tried !!!

Do you know if Cocoon recognizes jars placed under /j2sdk/jre/lib/ext ? I
have placed IAIK jars there, and OK ... but when I place there IXSIL, wrong
!!!



----- Original Message -----
From: "Antonio Gallardo" <ag...@agsoftware.dnsalias.com>
To: <us...@cocoon.apache.org>
Sent: Monday, September 29, 2003 1:39 PM
Subject: Re: Cocoon + IXSIL


> Josep Riudavets dijo:
> > Ok, new versions of xalan, xerces and xml-apis ara now at
> > /tomcat/common/endorsed. And I have also placed them into
> > /j2sdk/jre/lib/ext/endorsed
>
> Try to put the IXSIL libraries into WEB-INF/lib?
>
> Best Regards,
>
> Antonio Gallardo
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Josep Riudavets <jr...@uoc.edu>.
Ok, new versions of xalan, xerces and xml-apis ara now at
/tomcat/common/endorsed. And I have also placed them into
/j2sdk/jre/lib/ext/endorsed

But my problem is that Cocoon does not recognize IXSIL libraries !!!!!! I
add next line:

<xsp:include>iaik.ixsil.core.*</xsp:include>
<xsp:include>iaik.ixsil.algorithms.*</xsp:include>
<xsp:include>iaik.ixsil.init.*</xsp:include>
<xsp:include>iaik.ixsil.util.*</xsp:include>
<xsp:include>iaik.ixsil.keyinfo.X509.*</xsp:include>

And when I try to use these classes, Cocoon falls down :

org.apache.cocoon.components.language.LanguageException: Error compiling
procesa_xsp:
ERROR 1 (org/apache/cocoon/www/XSP/procesa_xsp.java):
...
iaik.security.provider.IAIK.addAsProvider(true);
		try{
// start error (lines 803-803) "IXSILInit cannot be resolved"
		IXSILInit.init(new URI("file", null,
"/usr/local/j2sdk1.4.1_02/IAIK-XML/init/properties/init.properties", null,
null));
// end error
 }catch(Exception ex){
	    ex.printStackTrace();

These classes ara packed into IXSIL_1_1_0_Evaluation.jar ... and I don't
know where to put this file, and what to do in order to Cocoon recognizes
it.






----- Original Message -----
From: "Antonio Gallardo" <ag...@agsoftware.dnsalias.com>
To: <us...@cocoon.apache.org>
Sent: Monday, September 29, 2003 12:09 PM
Subject: Re: Cocoon + IXSIL


> Josep Riudavets dijo:
> > I have removed next lines
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="xslt"?>
> >
> > from my XSP page, because I'm using Cocoon 2.1.
> >
> > And this is the pipeline that I use to generate the page :
> >
> > <map:pipeline>
> > <map:match pattern="*.xsp">
> > <map:generate type="serverpages" src="XSP/{1}.xsp"/>
> > <map:transform src="XSL/{1}.xsl"/>
> > <map:serialize type="html"/>
> > </map:match>
> > </map:pipeline>
> >
> >
> > I think the problem resides in IXSIL libraries. These libraries are used
> > in order to implement XML-dSig stardard.
> >
> > When I created my class, it works perfectly. But when I try to use this
> > class from Cocoon, it does not recognize IXSIL libraries. Where do I
> > have to place IXSIL jars in order to be recognized by Cocoon? I have put
> > them into /WEB-INF/lib directory, but it is not enough. The jars that
> > form these libraries are:
> >
> > IXSIL_1_1_0_XXX.jar The actual IXSIL libraray.
> > xalan.jar
> > xml-apis.jar
> > runtime.jar
> > bsf.jar
> > xerces.jar
>
> Check this: http://wiki.cocoondev.org/Wiki.jsp?page=MigrateToCocoon2
>
> About the libraries... if you are using Tomcat 4.1.x, copy these files:
>
> xalan.jar
> xml-apis.jar
> xerces.jar
>
> in your $TOMCAT/common/endorsed directory.
>
> More info: http://wiki.cocoondev.org/Wiki.jsp?page=EndorsedLibsProblem
>
> Best Regards,
>
> Antonio Gallardo
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Cocoon + IXSIL

Posted by Josep Riudavets <jr...@uoc.edu>.
I have removed next lines 
<?cocoon-process type="xsp"?>
<?cocoon-process type="xslt"?>

from my XSP page, because I'm using Cocoon 2.1.

And this is the pipeline that I use to generate the page :

<map:pipeline>
<map:match pattern="*.xsp">
<map:generate type="serverpages" src="XSP/{1}.xsp"/>
<map:transform src="XSL/{1}.xsl"/>
<map:serialize type="html"/>
</map:match>
</map:pipeline>


I think the problem resides in IXSIL libraries. These libraries are used in order to implement XML-dSig stardard. 

When I created my class, it works perfectly. But when I try to use this class from Cocoon, it does not recognize IXSIL libraries. Where do I have to place IXSIL jars in order to be recognized by Cocoon? I have put them into /WEB-INF/lib directory, but it is not enough. The jars that form these libraries are:

IXSIL_1_1_0_XXX.jar The actual IXSIL libraray.
xalan.jar
xml-apis.jar
runtime.jar
bsf.jar
xerces.jar

I also use IAIK JCE libraries, but Cocoon recognizes them, and these libraries are placed under J2SDK directory !!!  Why Cocoon recognizes IAIK but not IXSIL ???

Please, some help !!! I'm working about this from two months ago !!!! 




----- Original Message ----- 
From: "Ugo Cei" <u....@cbim.it>
To: <us...@cocoon.apache.org>
Sent: Tuesday, September 23, 2003 7:04 PM
Subject: Re: Cocoon + IXSIL


> Josep Riudavets wrote:
> > Hi ... My name is Josep, from Barcelona (Spain).
> > 
> > I'm trying to develop a XSP page, including an instance of my own class:
> >  
> > <?xml version="1.0" encoding="UTF-8"?>
> > <?cocoon-process type="xsp"?>
> > <?cocoon-process type="xslt"?>
> 
> These processing instructions are from Cocoon 1. You don't need to use 
> them for Cocoon 2.
> 
> > I'm using Cocoon2 under Tomcat 4.1 and J2SDK 1.4. The class I have 
> > created uses IXSIL_1_1 libraries.
> 
> Can you show us the sitemap pipeline you're using to generate this page?
> 
> Ugo
> 
> -- 
> Ugo Cei - Consorzio di Bioingegneria e Informatica Medica
> P.le Volontari del Sangue, 2 - 27100 Pavia - Italy
> Phone: +39.0382.525100 - E-mail: u.cei@cbim.it
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
>