Recent Notes

Displaying keyword search results 1 - 10
Created by Dr. Xi on November 01, 2013 10:17:57    Last update: November 01, 2013 10:17:57
This example class reads a RSA private key file in PEM format. import java.io.*; import java.security.*; im...
Created by Dr. Xi on October 31, 2013 18:17:09    Last update: October 31, 2013 18:17:09
You have a PGP public in PEM format, which cannot be stored in a Java key store. But you have the PEM encoded public key file. This class reads the file and creates a public key class in Java. Example key file: -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0B... Java code: import java.io.*; import java.security.*; im...
Created by Dr. Xi on October 12, 2013 13:06:55    Last update: October 12, 2013 13:06:55
Generate the ssh keys: $ ssh-keygen -t rsa Generating public/private r... Convert the ssh public key to PEM format: $ cd .ssh ~/.ssh$ ssh-keygen -f mykey.pub -e -m...
Created by Fang on December 06, 2011 19:03:25    Last update: December 07, 2011 08:54:11
Our custom tag, as implemented in the previous note , is broken when a template is used. Create a template file ( home-template.xhtml ): <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Stric... and a test page that uses it ( home.xhtml ): <?xml version="1.0" encoding="UTF-8"?> <ui:comp... Then request the page with URL: http://localhost:8080/facelet-demo/home.jsf?name=Jack . You'll find that our hello tag works inside ui:repeat but fails to get the value defined by ui:param ! What's the problem? Our hello tag implementation evaluated the EL with the wrong EL context! This is the corrected implementation: package com.example; import java.io.IOExcep...
Created by Fang on November 03, 2011 19:47:38    Last update: November 08, 2011 20:24:47
This is a step-by-step example to create a really simple facelet taglib (in JSF 2 with Maven). Create a simple Maven project with: mvn archetype:create -DgroupId=com.example -Dartif... Three files are created as a result: pom.xml src/main/java/com/example/App.java src/test/java/com/example/AppTest.java This project should be able to build with: mvn package Add facelet API dependencies to pom.xml : <project xmlns="http://maven.apache.org/POM/4.... The compiler plugin section is optional. Remove src/main/java/com/example/App.java , create a new Java class as the facelet Tag Handler ( HelloTagHandler.java ): package com.example; import java.io.IOExcep... This tag handler simply prints a "Hello" message. Create facelet tag declaration file src/main/resources/META-INF/hello.taglib.xml : <?xml version="1.0" encoding="UTF-8"?> <facelet... Build the JAR with mvn clean package Optionally, install it to the local repository: mvn install To use the taglib, simply drop the...
Created by freyo on May 13, 2011 15:45:29    Last update: September 20, 2011 08:08:12
This is an Android app that dumps any binarized xml file as plain text - to the sdcard on the device or emulator. build.xml : <?xml version="1.0" encoding="UTF-8"?> <project... AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <man... res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <Lin... res/values/strings.xml : <?xml version="1.0" encoding="utf-8"?> <res... src/com/android/xmltool/DumpXml.java package com.android.xmltool; import java.ut... Screenshot Pre-built APK can be downloaded from: http://code.google.com/p/android-binxml-dump/
Created by freyo on May 24, 2011 09:15:14    Last update: May 24, 2011 09:15:14
Java built-in X.509 certificate factory reads CertPath objects encoded in PkiPath or PKCS7 formats. The META-INF/<key_alias>.RSA file generated by Java jarsigner is in PKCS7 format. Example code: import java.util.*; import java.io.*; import... PKCS7 files can also be generated by openssl from certificate file(s): openssl crl2pkcs7 -nocrl -certfile Certs.pem -out ... Convert PKCS7 from DER to PEM: openssl pkcs7 -in certs.pk7 -inform DER -out certs... Sample PKCS7 file: -----BEGIN PKCS7----- MIIERwYJKoZIhvcNAQcCoIIEO...
Created by freyo on April 07, 2011 15:29:01    Last update: April 07, 2011 15:29:01
Format Name Description PKCS #7 Cryptographic Message Syntax Standard A PKCS #7 file can be used to store certificates, which is a SignedData structure without data (just the certificates). The file name extension is usually .p7b , .p7c PKCS #8 Private-Key Information Syntax Standard. Used to carry private certificate keypairs (encrypted or unencrypted). PKCS #12 Personal Information Exchange Syntax Standard. Defines a file format commonly used to store private keys with accompanying public key certificates, protected with a password-based symmetric key. It is the successor to PFX from Microsoft. DER Distinguished Encoding Rules A binary format for keys or certificates. It is a message transfer syntax specified by the ITU in X.690. PEM Privacy Enhanced Mail Base64 encoded DER certificates or keys, with additional header...
Created by alfa on April 06, 2011 12:48:44    Last update: April 06, 2011 12:48:44
package com.demo.io; import java.io.*; ...
Created by Dr. Xi on January 14, 2010 00:28:27    Last update: March 30, 2011 15:37:44
A task that a Java developer does so frequently is to find out where a certain class can be found - to resolve compilation errors, classpath issues, or version conflicts of the same class introduced by multiple class loaders. A long while back I wrote a simple Perl script to perform the task. Later I was informed that there are Swing based Jar Browser and Jars Browser . Then, there are a couple of shell one-liners: # one liner 1 find -name "*.jar" -print0 | xarg... But all of them share the same problem: if a class is in a jar nested in another jar, it cannot be found. Such is the case for a class inside a jar under the WEB-INF/lib directory of a...
Previous  1 2 Next