From: <php...@li...> - 2009-12-03 13:28:56
|
Hi, Thanks for you fast answer. I try again to implement the Java Array class like that (from the FAQ): $Byte = new JavaClass("java.lang.Byte"); $byte = $Byte->TYPE; $Array = new JavaClass("java.lang.reflect.Array"); $byteArray = $Array->newInstance($byte, 8192); $n; while (($n = $data->read($byteArray)) > 0) { $messageDigest->update($byteArray, 0, $n); echo "n= " . $n ; } -> I always got a : Maximum execution time of 60 seconds exceeded in ... When I try with a Php int Array like that: $buf = array(); for ($i=0; $i<8192; $i++){ $buf[$i] = '0'; } $n; while (($n = $data->read($buf)) > 0) { $messageDigest->update($buf, 0, $n); echo "n= " . $n ; } -> I receive that: n= 184n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 6259 Exception... Here you can find the original Java code: byte buf[] = new byte[8192]; int n; while ((n = data.read(buf)) > 0) { messageDigest.update(buf, 0, n); System.out.print("n=" + n); } Do you see where the problem can come from? Best regards Antoine _________________________________________________________________ Faites vos achats de Noël en ligne en toute sécurité : avec MSN Internet Explorer 8 surfez sûr, télécharger maintenant gratuitement ! http://www.microsoft.ch/msnie8/fr |
From: <php...@li...> - 2009-12-03 14:04:18
|
Well, if you hit the 60seconds, you have no other chance than 1) raise the limit in php.ini 2) optimize your code what do you want to do with your code? It looks like you are trying to generate a md5 hash or something like that... php has build in support for various hashes... also your loop always transfers data back-and-forth between java and php which makes it slow.. so instead of trying to figure out, whats wrong with the code, it maybe would be better if you would tell us, what you like to achieve so we can guide you to a possible better solution. kind regards, dominik On Thu, Dec 3, 2009 at 2:28 PM, <php...@li...> wrote: > > Hi, > > > Thanks for you fast answer. > > I try again to implement the Java Array class like that (from the FAQ): > > $Byte = new JavaClass("java.lang.Byte"); > $byte = $Byte->TYPE; > $Array = new JavaClass("java.lang.reflect.Array"); > $byteArray = $Array->newInstance($byte, 8192); > > $n; > while (($n = $data->read($byteArray)) > 0) { > $messageDigest->update($byteArray, 0, $n); > echo "n= " . $n ; > } > > -> I always got a : Maximum execution time of 60 seconds exceeded in ... > > > When I try with a Php int Array like that: > > $buf = array(); > for ($i=0; $i<8192; $i++){ > $buf[$i] = '0'; > } > $n; > while (($n = $data->read($buf)) > 0) { > $messageDigest->update($buf, 0, $n); > echo "n= " . $n ; > } > > -> I receive that: n= 184n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 8192n= 6259 Exception... > > Here you can find the original Java code: > > byte buf[] = new byte[8192]; > int n; > while ((n = data.read(buf)) > 0) { > messageDigest.update(buf, 0, n); > System.out.print("n=" + n); > } > > > Do you see where the problem can come from? > > Best regards Antoine > > > _________________________________________________________________ > Faites vos achats de Noël en ligne en toute sécurité : avec MSN Internet Explorer 8 surfez sûr, télécharger maintenant gratuitement ! > http://www.microsoft.ch/msnie8/fr > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |
From: <php...@li...> - 2009-12-03 18:31:49
|
Hi, > while (($n = $data->read($byteArray)) > 0) { > I always got a : Maximum execution time of 60 seconds exceeded in ... Yes, this is the correct behaviour. The above statement evaluates to an endless loop. $data->read(...) returns a java Integer object. Any object evaluates to true, according to the PHP type conversion rules. What you probably want is: while (($n = java_values($data->read($byteArray))) > 0) { ... Please see our API documentation at http://php-java-bridge.sourceforge.net/pjb/docs/php-api/JavaBridge/_JavaProxy.inc.html#functionjava_valuesand JAVA_PREFER_VALUES http://php-java-bridge.sourceforge.net/pjb/docs/php-api/JavaBridge/_Options.inc.htmlfor details. Regards, Jost Boekemeier |
From: <php...@li...> - 2009-12-07 09:01:46
|
Thanks Jost, This solution seem to work. But I still got a lot of problems for the rest of the script like [java-code] Certificate[] chain = ks.getCertificateChain(alias); if (chain.length >= 2) { String url = PdfPKCS7.getOCSPURL((X509Certificate)chain[0]); if (url != null && url.length() > 0) ocsp = new OcspClientBouncyCastle((X509Certificate)chain[0], (X509Certificate)chain[1], url).getEncoded(); } How to create an Array of object when you don't know the size... I can't use : $Certificate = new JavaClass("java.security.cert.Certificate"); $Array = new JavaClass("java.lang.reflect.Array"); $chain = $Array->newInstance($Certificate, 10); Otherwise, do you know someone who can help me to traduce this script (http://itextpdf.sourceforge.net/howtosign.html -> How to sign with a timestamp and OCSP in Java) Best regards > Date: Thu, 3 Dec 2009 19:31:36 +0100 > To: php...@li... > From: php...@li... > Subject: Re: [Php-java-bridge-users] messageDigest and byte manipulation(2) > > Hi, > > > while (($n = $data->read($byteArray)) > 0) { > > I always got a : Maximum execution time of 60 seconds exceeded in ... > > > Yes, this is the correct behaviour. The above statement evaluates to an > endless loop. > > $data->read(...) returns a java Integer object. Any object evaluates to > true, according to the PHP type conversion rules. > > > What you probably want is: > > while (($n = java_values($data->read($byteArray))) > 0) { > ... > > Please see our API documentation at > http://php-java-bridge.sourceforge.net/pjb/docs/php-api/JavaBridge/_JavaProxy.inc.html#functionjava_valuesand > JAVA_PREFER_VALUES > http://php-java-bridge.sourceforge.net/pjb/docs/php-api/JavaBridge/_Options.inc.htmlfor > details. > > > Regards, > Jost Boekemeier > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users _________________________________________________________________ Messenger à partir de votre boîte de réception ! Découvrez la foule d'atouts de Hotmail. http://www.microsoft.com/switzerland/windows/fr/windowslive/hotmail_bl1/hotmail_bl1.aspx |
From: <php...@li...> - 2009-12-07 10:47:56
|
Hi, [java-code] Certificate[] chain = ks.getCertificateChain(alias); if (chain.length >= 2) { String url = PdfPKCS7.getOCSPURL(( > > X509Certificate)chain[0]); > if (url != null && url.length() > 0) > ocsp = new OcspClientBouncyCastle((X509Certificate)chain[0], > (X509Certificate)chain[1], url).getEncoded(); > } => $chain = $ks->getCertificateChain($alias); if (java_values(chain.length)) >= 2) { $url = java("...PdfPKCS7")->getOCSPURL($chain[0]); if (java_values($url) != null && java_values($url->length()) > 0) { $val = new java("...OcspClientBouncyCastle", $chain[0], $chain[1], $url); $ocsp = $val->getEncoded(); } Where exactly are the problems? You can always use echo java_inspect($jobject) to see if a Java method or procedure invocation has returned the correct result. However, it isn't possible to blindly convert a Java program to PHP. PHP has different type conversion rules for example. If you have a working java library, just add it to your web context and call it from PHP. Regards, Jost Boekemeier |
From: <php...@li...> - 2009-12-10 09:14:52
|
Hi, I got a error when I call 'getOCSPURL' with the certificate. $url = java("com.lowagie.text.pdf.PdfPKCS7")->getOCSPURL($chain[0]); I know $chain[0] contain a valid X509CertificateObject, but I always got that exception: #0 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(248): java_ThrowExceptionProxyFactory->getProxy(102, 'org.bouncycastl...', '', true) #1 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(388): java_Arg->getResult(true) #2 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(394): java_Client->getWrappedResult(true) #3 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(594): java_Client->getResult() #4 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(1731): java_Client->invokeMethod(100, 'getOCSPURL', Array) #5 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(1839): java_JavaProxy->__call('getOCSPURL', Array) #6 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(2007): java_AbstractJava->__call('getOCSPURL', Array) #7 [internal function]: Java->__call('getOCSPURL', Array) #8 C:\Developpement\My Webs\ss_billing\classes\billing.class2.pdf.php(349): JavaClass->getOCSPURL(Object(java_InternalJava)) #9 C:\Developpement\My Webs\ss_billing\receive.php(183): billing_pdf::generation(Object(SimpleXMLElement)) #10 {main} I'm using iText-2.1.7.jar and some other functionality of this library are working fine... any idea ? > Date: Mon, 7 Dec 2009 11:47:44 +0100 > To: php...@li... > From: php...@li... > Subject: Re: [Php-java-bridge-users] messageDigest and byte manipulation(2) > > Hi, > > [java-code] > > Certificate[] chain = ks.getCertificateChain(alias); > if (chain.length >= 2) { > String url = PdfPKCS7.getOCSPURL(( > > > > X509Certificate)chain[0]); > > if (url != null && url.length() > 0) > > ocsp = new OcspClientBouncyCastle((X509Certificate)chain[0], > > (X509Certificate)chain[1], url).getEncoded(); > > } > > > > => > > $chain = $ks->getCertificateChain($alias); > if (java_values(chain.length)) >= 2) { > $url = java("...PdfPKCS7")->getOCSPURL($chain[0]); > if (java_values($url) != null && java_values($url->length()) > 0) { > $val = new java("...OcspClientBouncyCastle", $chain[0], $chain[1], > $url); > $ocsp = $val->getEncoded(); > } > > > Where exactly are the problems? > > You can always use > > echo java_inspect($jobject) > > to see if a Java method or procedure invocation has returned the correct > result. > > However, it isn't possible to blindly convert a Java program to PHP. PHP has > different type conversion rules for example. > > If you have a working java library, just add it to your web context and call > it from PHP. > > > Regards, > Jost Boekemeier > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users _________________________________________________________________ Faites vos achats de Noël en ligne en toute sécurité : avec MSN Internet Explorer 8 surfez sûr, télécharger maintenant gratuitement ! http://www.microsoft.ch/msnie8/fr |
From: <php...@li...> - 2009-12-10 14:20:28
|
Which exception do you get? On Thu, Dec 10, 2009 at 10:14 AM, < php...@li...> wrote: > > Hi, > > I got a error when I call 'getOCSPURL' with the certificate. > > $url = java("com.lowagie.text.pdf.PdfPKCS7")->getOCSPURL($chain[0]); > > I know $chain[0] contain a valid X509CertificateObject, but I always got > that exception: > #0 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(248): > java_ThrowExceptionProxyFactory->getProxy(102, 'org.bouncycastl...', '', > true) > #1 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(388): > java_Arg->getResult(true) > #2 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(394): > java_Client->getWrappedResult(true) > #3 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(594): > java_Client->getResult() > #4 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(1731): > java_Client->invokeMethod(100, 'getOCSPURL', Array) > #5 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(1839): > java_JavaProxy->__call('getOCSPURL', Array) > #6 C:\Developpement\My Webs\ss_billing\JavaBridge\java\Java.inc(2007): > java_AbstractJava->__call('getOCSPURL', Array) > #7 [internal function]: Java->__call('getOCSPURL', Array) > #8 C:\Developpement\My Webs\ss_billing\classes\billing.class2.pdf.php(349): > JavaClass->getOCSPURL(Object(java_InternalJava)) > #9 C:\Developpement\My Webs\ss_billing\receive.php(183): > billing_pdf::generation(Object(SimpleXMLElement)) > #10 {main} > > I'm using iText-2.1.7.jar and some other functionality of this library are > working fine... any idea ? > > > Date: Mon, 7 Dec 2009 11:47:44 +0100 > > To: php...@li... > > From: php...@li... > > Subject: Re: [Php-java-bridge-users] messageDigest and byte > manipulation(2) > > > > Hi, > > > > [java-code] > > > > Certificate[] chain = ks.getCertificateChain(alias); > > if (chain.length >= 2) { > > String url = PdfPKCS7.getOCSPURL(( > > > > > > X509Certificate)chain[0]); > > > if (url != null && url.length() > 0) > > > ocsp = new > OcspClientBouncyCastle((X509Certificate)chain[0], > > > (X509Certificate)chain[1], url).getEncoded(); > > > } > > > > > > > > => > > > > $chain = $ks->getCertificateChain($alias); > > if (java_values(chain.length)) >= 2) { > > $url = java("...PdfPKCS7")->getOCSPURL($chain[0]); > > if (java_values($url) != null && java_values($url->length()) > 0) { > > $val = new java("...OcspClientBouncyCastle", $chain[0], $chain[1], > > $url); > > $ocsp = $val->getEncoded(); > > } > > > > > > Where exactly are the problems? > > > > You can always use > > > > echo java_inspect($jobject) > > > > to see if a Java method or procedure invocation has returned the correct > > result. > > > > However, it isn't possible to blindly convert a Java program to PHP. PHP > has > > different type conversion rules for example. > > > > If you have a working java library, just add it to your web context and > call > > it from PHP. > > > > > > Regards, > > Jost Boekemeier > > > ------------------------------------------------------------------------------ > > Join us December 9, 2009 for the Red Hat Virtual Experience, > > a free event focused on virtualization and cloud computing. > > Attend in-depth sessions from your desk. Your couch. Anywhere. > > http://p.sf.net/sfu/redhat-sfdev2dev > > _______________________________________________ > > php-java-bridge-users mailing list > > php...@li... > > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > > _________________________________________________________________ > Faites vos achats de Noël en ligne en toute sécurité : avec MSN Internet > Explorer 8 surfez sûr, télécharger maintenant gratuitement ! > http://www.microsoft.ch/msnie8/fr > > ------------------------------------------------------------------------------ > Return on Information: > Google Enterprise Search pays you back > Get the facts. > http://p.sf.net/sfu/google-dev2dev > _______________________________________________ > php-java-bridge-users mailing list > php...@li... > https://lists.sourceforge.net/lists/listinfo/php-java-bridge-users > |