Saturday, May 17, 2008

FireGPG on Linux

How GPG works for the email.

Scenario 1: Sam creates public and private key Sam Publishes Sam's public Key to Key server. Bob Creates his public and private key Bob publishes Bob's public Key to Key Server.
Scenario 2:
No Sam and Bob need to engage a secured email communication. Sam pulls Bob's public key from key server and imports that public key into his trusted keyring using seahorse or gpg command line. Sam use Bob's Public Key to sign the message and send to Bob. Bob use his Private Key to decrypt and verify Sam's Message which was signed and encrypted using Bob's Public key.
Tools Needed
FireGPG GPG seahorse
Generate Key Pairs.
gpg --key-gen now the keys are generated and stored to keystore. Use the Seahorse to manual edit the keys and export keys. gpg normally get installed in usr/bin if you install with apt-get. Now install FireGPG plugin to FireFox.
Run the FireFox as ROOT. Here is the catch all the key genereration and keystore are acessible only for the root user. Firefox launch itself as firefox user, so when you launch the FireGPG it wont able to find the KEY's. It took me a while what was going wrong. If you launch the firefox as ROOT user or install the KEY's as universal user this issue can be fixed. Once you are in gmail and type the subject you should be able to see the encrypt and decrypt button and when you click the encrypt it should prompt for the public keys. If you are not a privilaged user to access the KEY store you wont see the KEYS.

Friday, May 9, 2008

NYI - Not Yet Implemented error

If you are getting this error

Exception in thread "main" java.lang.RuntimeException: NYI at cryptix.jce.provider.elgamal.ElGamalCipher.engineGetParameters(ElGamalCipher.java:120) at javax.crypto.Cipher.a(DashoA12275)
Reason is the suns default policy doesn't have the strength to encrypt/decrypt with higher strength keys. Got to SUN downloads and install/replace it in you JRE/lib/security Other Downloads Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 6

Wednesday, May 7, 2008

Formating Currencies and Dates in Struts 2

Create a Global message property so that the formating can be applied to all the pages name it globalMessages.properties

item.listprice = {0,number,$##0.00}
Now add the property to struts.properties
struts.custom.i18n.resources=globalMessages
Now how to Call the formating string in JSP where listprice comes from the stack and the formating string from the global resource we set earlier.
<s:text name="%{getText('item.listprice')}"> <s:param name="value" value="listprice"/> </s:text>
And now the Output
$12.20
Make sure to put the property files in the correct folder of your project.