Recent Notes
Displaying keyword search results 1 - 12
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 freyo on February 23, 2011 13:38:23
Last update: February 23, 2011 13:38:23
The Java keytool utility does not support importing a private key directly from a file. But it does support merging a keystore with the -importkeystore command. So, for a private key generated with OpenSSL in PEM format, you first convert the PEM key into PKCS12 format , then merge the one-key PKCS12 store with the Java KeyStore:
C:\>keytool -importkeystore -srckeystore openssl_c...
Created by Dr. Xi on November 08, 2010 20:44:12
Last update: November 08, 2010 20:44:12
Key points:
Java String.matches() matches the entire string, not a partial string. Use java.util.regex.Matcher.find() to match a partial String.
For case insensitive match, use Pattern.compile with case insensitive flags:
// Case insensitive for ASCII
Pattern p = P...
Use (?i) or (?iu) (for unicode) to inline case-insensitive flag:
boolean b = "StringToMatchAgainst".matches("(?...
Test code:
import java.util.regex.*;
public class Test...
Created by woolf on September 17, 2010 19:31:06
Last update: September 17, 2010 19:31:06
From http://hardware.slashdot.org/story/10/09/17/0247246/HDCP-Master-Key-Is-Legitimate-Blu-ray-Is-Cracked : MakeMKV rips most Blu-Rays very easily. If you want to re-encode with compression like x264, Handbrake will do it easily (though it takes about 6 hours at "20" quality on my i7 HTPC). The audio is a little tricky, but with MKVmerge you can just take the stream that MakeMKV gave you and mux it into the video stream Handbrake spat out. Subtitles are tougher because of the way they're done on Blu-Ray, but I find that opensubtitles.org usually has a perfectly-timed SRT file for my rips, most often from a guy called Shoocat. With newer codecs, the text is super-smooth and often looks better than the subtitles on the blu-ray. The only really hellacious problem I've had with moving my Blu-Ray...
Created by Fang on August 03, 2010 19:50:51
Last update: August 03, 2010 19:50:51
The tags <fmt:message> Writes out a formatted message for the current locale and resource bundle, or stores the resulting message to a scoped variable (when the var attribute is specified). Syntax:
<fmt:message key="messageKey" [bundle="resourc... Or, with parameters in body: <fmt:message key="messageKey" [bundle="resourc... <fmt:bundle> Creates a resource bundle for the contained body. Syntax: <fmt:bundle basename="basename" [prefix="prefi... <fmt:setBundle> Sets a resource bundle in a scoped variable, which may be used later by <fmt:message> . Syntax: <fmt:setBundle basename="basename" [var="varNa... <fmt:param> This is used inside a <fmt:message> tag to specify a replacement parameter. <fmt:param value="theParameterValue"/> or <fmt:param>The Parameter Value</fmt:param> Test it Make these additions to the expanded test application : Create 3 resource bundles and place them under src\main\resources . messages_en.properties : label.login=Login label.username=User Name ... messages_es.properties :...
Created by voodoo on July 11, 2009 15:14:55
Last update: July 29, 2010 22:45:48
cURL is a command line tool for transferring files with URL syntax. The main purpose and use for cURL is to automate unattended file transfers or sequences of operations.
It's really easy to see HTTP headers with curl:
C:\>curl --head http://www.google.com
HTTP/1.0 ...
or, headers and page together (dump headers to stdout):
$ curl --dump-header - http://www.google.com HTTP/...
Download openssl from openssl.org:
curl http://www.openssl.org/source/openssl-0.9.6m....
C:\>curl --help
Usage: curl [options...] <url>
...
Created by Dr. Xi on July 19, 2010 21:58:34
Last update: July 23, 2010 21:37:23
Parsing XML in Java is really simple:
import java.io.*; import javax.xml.parsers.Docu... The parser implementation details are hidden behind the JAXP API. In case you want to know which parser implementation is used, this is what the JavaDoc for DocumentBuilderFactory.newInstance says: Use the javax.xml.parsers.DocumentBuilderFactory system property. Use the properties file " lib/jaxp.properties " in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to...
Created by Dr. Xi on June 20, 2010 14:35:17
Last update: June 20, 2010 14:35:17
This XML signature validator comes from the Apache XML Security project. It validates the signature according to the core validation processing rules .
It does not verify that the key used to generate the signature is a trusted key. You can override the KeySelector class to make sure that the signing key is from a trusted store.
import javax.xml.crypto.*;
import javax.xml.cry...
Created by Dr. Xi on June 19, 2010 04:34:01
Last update: June 19, 2010 04:39:13
Java SE 6 contains built-in utilities to generate XML signatures. This is an example that generates XML signatures using a Java keystore. It has options to generate signature for the whole document, for an element with a specific ID, or for elements matched by an XPATH expression.
The XML document used to test is taken from Getting Started with XML Security :
<?xml version="1.0"?>
<PatientRecord>
...
This is the Java code:
import java.io.FileInputStream;
import java.io....
However, it looks like the XPATH transform is not working. The digest generated with XPATH filter is exactly the same as that without it (i.e., the whole document)!
Another reference:
Programming With the Java XML Digital Signature API
Created by Dr. Xi on April 30, 2009 23:26:13
Last update: May 01, 2009 17:08:49
ApplicationResources.properties contains these keys:
test.key.1 = Test Key One
test.key.2 = Test Key...
Struts (struts-el):
<%@ page contentType="text/html;charset=UTF-8" lan...
JSTL
<%@ page contentType="text/html;charset=UTF-8" lan...
However, the values for one and two must be passed in from pageScope , requestScope , sessionScope , etc. Values defined by struts bean:define are not interpreted.
Important:
JSTL tags work with servlet spec 2.4 only. So your web.xml must start with this:
<?xml version = '1.0' encoding = 'windows-1252'?> ...
Not this:
<?xml version = '1.0' encoding = 'windows-1252'?>
...
However, the latter does work with struts-el tags.
Created by Dr. Xi on March 16, 2009 22:10:29
Last update: March 16, 2009 22:12:35
Generate the keys
$ ssh-keygen -t rsa
Generating public/private r...
Copy id_rsa.pub to the remote server.
scp .ssh/id_rsa.pub jmann@sleepy:/home/jmann/.ssh/
Logon to the remote host, append id_rsa.pub to authorized_keys . Make sure authorized_keys is writable
only by owner.
$ cd ~/.ssh
$ cat id_rsa.pub >>authorized_keys
...
For putty, you need to convert the private key to putty format using puttygen :
and tell it to use the private key:
Created by Dr. Xi on February 23, 2009 21:04:08
Last update: February 23, 2009 21:04:08
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" ...