Thursday, September 5, 2013

Postgres grant read only

Prior to postgres 9.0 you can use this:



 SELECT 'GRANT SELECT ON ' || relname || ' TO xxx;'  a
 FROM pg_class JOIN pg_namespace ON pg_namespace.oid = pg_class.relnamespace  
 WHERE nspname = 'public' AND relkind IN ('r', 'v')  

Postgres 9+ you can use this:



 GRANT SELECT ON ALL TABLES IN SCHEMA public TO xxx;  

Reference:


http://stackoverflow.com/questions/760210/how-do-you-create-a-read-only-user-in-postgresql

Thursday, August 15, 2013

Blocked loading mixed active content

Problem

With the latest versions of firefox, a javascript file fail to load from an external site such as google using the following code:


 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>  

The connection was secure running on HTTPS. However the connection to load the javascript file was not secure running purely on HTTP.

Solution


To get the javascript file to load properly I simply changed the SRC URL to use HTTPS as shown below:

 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.js"></script>  

Monday, August 5, 2013

ClassFormatException Invalid byte tag in constant pool: 60 with Grails in Tomcat 7.0.42

The Problem

I encountered this error when deploying my grails application to the latest version of Tomcat 7.0.42.

The stacktrace is shown below:


 SEVERE: Unable to process Jar entry [com/ibm/icu/impl/data/LocaleElements_zh__PINYIN.class] from Jar [jar:file:/usr/local/apache-tomcat-7.0.42/webapps/mutations/WEB-INF/lib/icu4j-2.6.1.jar!/] for annohas been forcibly unregistered.  
 tations  
 org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 60  
     at org.apache.tomcat.util.bcel.classfile.Constant.readConstant(Constant.java:133)  
     at org.apache.tomcat.util.bcel.classfile.ConstantPool.<init>(ConstantPool.java:60)  

The offending jar file was the
icu4j-2.6.1.jar

The Solution

I updated the BuildConfig.groovy file to remove any dependencies to the offending JAR file and updated the dependency to use the latest version of the icu4j which at the time was version 51.1. To do that I inserted this code:


   inherits("global") {  
           excludes "icu4j"  
   }  
   dependencies {  
           runtime 'com.ibm.icu:icu4j:51.1'  
   }  

Environment

Grails version: 2.2.4
Tomcat version: 7.0.42


Monday, May 13, 2013

HTML5 localStorage isolation

HTML5 localStorage isolation

I've recently started using one of HTML5's new features of local browser storage, however, when I started using it in my development environment, I noticed that whenever my domain changed, the values put into storage could not be retrieved.

That is, localStorage is isloated by the domain

For example, if my domain was localhost then I changed the web address to be my IP address for example 192.168.1.100, then there will be separate instances of localStorage for each domain even though they are pointing to the same web server.

Unforutnately, a lot of books and websites, fail to mention this

Reference:

http://stackoverflow.com/questions/4201239/in-html5-is-the-localstorage-object-isolated-per-page-domain

 


Monday, January 21, 2013

Some of your private key files are encrypted for security reasons

To get rid of passphrase when restarting Apache HTTPD use the following command:



openssl rsa -in secure.example.org-2009.key -out secure.example.org-2009.key.unprotected

Sunday, December 9, 2012

Configuring certificates in apache

http://www.digicert.com/ssl-certificate-installation-apache.htm

To view whether you certificates are configured correctly use the following command:



keytool -printcert -sslserver


Thursday, November 22, 2012

sun.security.validator.ValidatorException: PKIX path building failed

sun.security.validator.ValidatorException: PKIX path building failed 

This error means that the certifcate that you have recevied in your code does not have an authority and so by default, the Java software rejects it.

To get around this, you'll have to manually import this certificate into your local keystore.

First you'll want to export the certificate to local drive. To do that we'll use firefox browser to find and export that certificate to file:

Click on Tools -> Options -> Advanced -> Encryption tab and you should see the following:


 


Then click on "View certificates"



Go to the "Servers" tab
Find the certficate of interest, and then click "Export"
Save the certficate some where to disk. You'll be importing the certificate to your keystore next.


Java's keystore is located here:

JAVA_HOME/jre/lib/security/cacerts
To import the certificate, we'll use the keytool command:


keytool -import -noprompt -trustcacerts -alias dc7-dev2 -file EXPORTED_CERTIFICATE -keystore "JAVA_HOME\jre\lib\security\cacerts"

Then you will be prompted for a password. By default, the password is "changeit"

 If all goes well, you should see the following response message: "Certificate was added to keystore"