Friday, July 20, 2012

Create a keystore for SSL using maven

Normally you would buy a trusted certificate however, the poor man's way is to create one your self.

Put this in a pom.xml and run it with mvn install.


<project>
<modelVersion>1.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<build><plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>clean</id>
<goals>
<goal>clean</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>genkey</id>
<goals>
<goal>genkey</goal>
</goals>
</execution>
</executions>
<configuration>
<keystore>example.keystore</keystore>
<dname>cn=localhost</dname>
<keypass>broadleaf</keypass>
<storepass>broadleaf</storepass>
<alias>broadleaf</alias>
<keyalg>RSA</keyalg>
</configuration>
</plugin>
</plugins>
</build>
</project>


SSL on tomcat

To turn on SSL port in tomcat is a simple process. You will need to modify the configuration file context.xml to allow the port to be open.


  1. Create the keyStore file to be used for ssl.  Click here to  create one using maven. 
  2.  In your tomcathomedir/conf/server.xml, add the following:


    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"                keystoreFile="/tmp/example.keystore"
               keystorePass="somePassword"               clientAuth="false" sslProtocol="TLS" />

That's it.....
Now hit the url  in your browser , https://localhost:8443 and it should ask your for security exception.   



Thursday, June 21, 2012

Invoking specific locale in gwt application



To invoke a specific locale from a gwt application using the URL,

add the get parameter locale=<string> where
string is the locale defined in your module file.  

for example:
Make sure your gwt module xml file contains the language you are trying to set.


<?xml version="1.0" encoding="UTF-8"?>
<module>
    <inherits name="com.google.gwt.user.User" />
    <inherits name="org.broadleafcommerce.openadmin.userModule" />
    <inherits name="com.google.gwt.core.CompilerParameters"/>
    <inherits name="com.google.gwt.i18n.I18N"/>
    <extend-property name="locale" values="en_US"/>
    <extend-property name="locale" values="es"/>
    <extend-property name="locale" values="es_MX"/>
    <extend-property name="locale" values="fr"/>
    <set-property-fallback name="locale" value="en_US"/>
<entry-point class="org.broadleafcommerce.openadmin.client.BLCLaunch" />
</module>