Tuesday, October 20, 2009

SunJDK weblogic

Reference: http://buttso.blogspot.com/2009/09/switching-between-jrockit-and-sun-jdk.html


Switching Between JRockit and Sun JDK with WebLogic Server

Need to swap between JRockit and the Sun JDK when starting your WebLogic Server instance?

Looking at the start scripts $DOMAIN_HOME/bin/setDomainEnv.cmd, I just realized that this operational task is basically taken care of in the scripts we have.

To swap between the Sun JDK and JRockit to launch a WLS instance, all you need to do is set the JAVA_VENDOR environment variable to either "Sun" or "Oracle" and the scripts will take of launching WLS using the specified JDK.

Snippets from setDomainEnv.cmd:
set BEA_JAVA_HOME=d:\wls1031\jrockit_160_05_R27.6.2-20
set SUN_JAVA_HOME=d:\wls1031\jdk160_11

if "%JAVA_VENDOR%"=="Oracle" (
set JAVA_HOME=%BEA_JAVA_HOME%
) else (
if "%JAVA_VENDOR%"=="Sun" (
set JAVA_HOME=%SUN_JAVA_HOME%
) else (
set JAVA_VENDOR=Sun
set JAVA_HOME=d:\wls1031\jdk160_11
)
)

Where JAVA_HOME is then used by startWebLogic.cmd script when it launches the WLS instance to identify the JDK to use.

Snippets from startWebLogic.cmd
%JAVA_HOME%\bin\java %JAVA_VM% %MEM_ARGS%
-Dweblogic.Name=%SERVER_NAME%
-Djava.security.policy=%WL_HOME%\server\lib\weblogic.policy
%JAVA_OPTIONS%
%PROXY_SETTINGS%
%SERVER_CLASS%

With this information at hand, then switching between the two different JDKs is as simple as setting an environment variable before launching WebLogic Server.

Using JRockit:
>set JAVA_VENDOR=Oracle
>startWebLogic.cmd
...
d:\wls1031\JROCKI~1.2-2\bin\java -jrockit -Xms512m -Xmx512m -Dweblogic.Name=AdminServer ...

And just as easy to switch back to Sun. Note here that you could just unset the JAVA_HOME environment variable, which will set the script to use whatever default was configured when the domain was created.

Using Sun JDK:
>set JAVA_VENDOR=Sun
>startWebLogic.cmd
...
d:\wls1031\JDK160~1\bin\java -client -Xms256m -Xmx512m -Dweblogic.Name=AdminServer ...

Monday, October 12, 2009

OpenSSL resources

http://www.dylanbeattie.net/docs/openssl_iis_ssl_howto.html
http://www.herongyang.com/crypto/OpenSSL_Signing_keytool_CSR_5.html
http://security.ncsa.uiuc.edu/research/grid-howtos/usefulopenssl.php

To view the details of the certificate signing request contained in the file server.csr, use:
openssl req -noout -text -in server.csr


c:\OpenSSL\bin\openssl asn1parse -inform der -in demo.p7 -i > c:\demo.asn1

c:\OpenSSL\bin\openssl pkcs7 -inform der -in demo.p7 -text -print_certs -noout

View certificate details
C:\Program Files\LunaPCI\keys>openssl x509 -inform PEM -in cert0.cer -text


------------------------------------------------------------------------------

1) Generate RSA key:
$ openssl genrsa -out key.pem 1024
$ openssl rsa -in key.pem -text -noout

2) Save public key in pub.pem file:
$ openssl rsa -in key.pem -pubout -out pub.pem
$ openssl rsa -in pub.pem -pubin -text -noout

3) Encrypt some data:
$ echo test test test > file.txt
$ openssl rsautl -encrypt -inkey pub.pem -pubin -in file.txt \
-out file.bin
$ ll file.bin
-rw-r--r-- 1 root root 128 2007-07-11 01:58 file.bin

4) Decrypt encrypted data:
$ openssl rsautl -decrypt -inkey key.pem -in file.bin
test test test

But you should have public key in so called SubjectPublicKeyInfo format
(look at RFC2459).
You can look at ASN.1 structure of public key with command:
$ openssl asn1parse -in pub.pem
0:d=0 hl=3 l= 159 cons: SEQUENCE
3:d=1 hl=2 l= 13 cons: SEQUENCE
5:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption
16:d=2 hl=2 l= 0 prim: NULL
18:d=1 hl=3 l= 141 prim: BIT STRING

Sample Public key
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDRzVwcS4JP8K5iihVc4j26QZWp
4n4Bh9cTxdCovsrCd50lxPNRUPPGqPcPwYGLVyyTG8+DR9RtqcVrC3gYtI20G2+0
HbWTRWAAa/LF/x937nt3Q92CDu010eRY0CDtvyLcg90yLV/84TOc5PRwbCwuURgu
3Nzn+7BiEZ7lYCyXGQIDAQAB
-----END PUBLIC KEY-----


------------------------------------------------------------------------------
For public key in hex64 ending with '==', use openssl asn1parse -in c:\maybank.pem

-----BEGIN PUBLIC KEY-----
MIGIAoGAq74V/tQfDXWpO821eujW9MOpSROdVKQXncV3m+k1K0Vmnu8QGSzvFq5cBe7R6uHB
/J5gHKwFVG6XgrqjVa46gprk+8vQFfLfshHcFf/Vv79Ykpj0/PWaCAvp7uvcFKKByb1cDhAu
PDmzbBJYMyg7nG3dmAzhEqPK+LLOQ5s7mHkCAwEAAQ==
-----END PUBLIC KEY-----

------------------------------------------------------------------------------








Thursday, October 8, 2009

Netbeans Sign jar

http://ezzatron.com/2009/09/29/automatically-signing-jar-files-in-netbeans/