Recent Notes
Displaying keyword search results 1 - 10
Created by Dr. Xi on August 15, 2012 12:05:39
Last update: August 15, 2012 12:05:39
Use OpenSSL's s_client command to fetch a page manually:
$ openssl s_client -connect localhost:443 -state -...
Sample session for Google:
$ openssl s_client -connect www.google.com:443 -st...
Resource: SSL/TLS Strong Encryption: FAQ
Created by Dr. Xi on May 25, 2012 15:47:34
Last update: May 25, 2012 15:49:33
Steps to configure SSL for Apache HTTPD server on Windows:
In Apache2.2/conf/httpd.conf , load mod_ssl and include httpd-ssl.conf :
LoadModule ssl_module modules/mod_ssl.so
...
In Apache2.2/conf/extra/httpd-ssl.conf , make sure the paths for the cert files point to the cert and key you want to use:
# Server Certificate:
# Point SSLCertificat...
Start up Apache. If it fails, use the command line to see what the error is. There won't be any log in error.log if there are errors in the conf files:
C:\Program Files (x86)\Apache Software Foundation\...
I corrected the previous error by using the alternative line for SSLSessionCache :
# Inter-Process Session Cache:
# Configure ...
Created by Fang on March 15, 2012 10:24:35
Last update: March 15, 2012 10:24:35
Suppose that I have an email field annotated with:
@NotEmpty(message="Please enter email address")
...
Bean validation will trigger two errors when no email address is entered:
the email field is empty
an empty email field is not a valid email address
Displaying both errors to the user with <form:errors> would be redundant and confusing:
<%@ taglib uri="http://www.springframework.org/tag...
This is how to display the first error only:
<spring:bind path="emailAddress">
<c:if test="$...
Created by Fang on February 27, 2012 12:19:19
Last update: February 27, 2012 12:19:19
Mapping Java objects to Jackson JSON is pretty simple. But if you name a JSON field wrong, you'll get the "Unrecognized field ... (Class ...), not marked as ignorable" error. The rule for mapping a Java bean attribute name to a JSON field name is: lower all leading capital letters until the first lower case letter .
For example, this Java class:
package com.example;
public class Person {
...
maps to this JSON string:
{
"firstName": "Jane",
"lastName": "...
Test code:
package com.example;
import java.net.URL;
...
Created by Dr. Xi on July 11, 2011 12:24:10
Last update: July 11, 2011 12:25:44
This code snippet
import java.util.*;
public class UncheckedCast ...
fails with a compilation error and a warning:
$ javac -Xlint:unchecked UncheckedCast.java
Unc...
Because List<String> is not a reifiable type, the Java Runtime does not have enough information to verify the type or do the type casting. This is fixed by changing List<String> to List<?> (or to the raw type List ):
public static void main(String[] args) {
Ob...
Created by freyo on May 17, 2011 11:13:17
Last update: May 17, 2011 11:13:17
This is an odd-ball content provider in that it doesn't provide database records, but provides a resource as a stream. It can be used to provide media files or XML resources. Start the project with:
tools/android create project --package com.android... Create assets directory and add an XML file ( assets/demo.xml ): <? xml version="1.0" encoding="UTF-8"?> <people... Edit the layout ( res/layout/main.xml ): <?xml version="1.0" encoding="utf-8"?> <LinearL... Edit src/com/android/cptest/Dummy.java : package com.android.cptest; import java.io.... Add content provider ( src/com/android/cptest/XmlResource.java ): package com.android.cptest; import java.io.... Update AndroidManifest.xml : <?xml version="1.0" encoding="utf-8"?> <manifes... Add this section to the end of build.xml : <target name="-package-resources"> <ech... Build and install: ant install Screenshot: Remove the Dummy activity ( AndroidManifest.xml ): <?xml version="1.0" encoding="utf-8"?> <manifes... Create a new project for...
Created by jinx on April 28, 2011 20:52:45
Last update: April 29, 2011 13:27:31
This is normally a syntax error just before some variable. Try some of these:
Missing operator before a variable:
<?php
$a = 'ab';
echo('Missing conca...
Missing semicolon at end of line:
<?php
echo('Missing semicolon at end of lin...
Missing ( and ) in for loop:
<?php
foreach $a as $i {
echo "$i\n";
...
Missing keyword before class variable:
<?php
class A {
// should be var $a;
...
Created by freyo on April 20, 2011 12:26:08
Last update: April 20, 2011 12:26:08
When you create a new key with Java keytool , it wraps the public key in a self signed certificate. You can generate a certificate signing request with the keytool -certreq command. After a certificate authority (CA) signs the certificate request, you can import the certificate received (a .crt file) back into the key store. Instead of using a CA, you can sign the certificate request with another key (with openssl, for example). If the certificate is not signed by a CA, you'll receive an error:
$ keytool -import -alias android-root -file androi... To fix the problem, import the certificate of the signer: $ keytool -import -trustcacerts -file openssl.crt ... Import the certificate again (alias is the alias of the private key whose certificate was...
Created by freyo on April 18, 2011 15:08:21
Last update: April 18, 2011 15:12:20
Generate android project
$ ~/android-sdk-linux_86/tools/android create proj...
Create XML file res/xml/books.xml :
<?xml version="1.0"?>
<catalog>
<book id=...
Edit layout ( res/layout/main.xml ):
<?xml version="1.0" encoding="utf-8"?>
<Lin...
Edit code ( src/com/android/xmlres/XMLResource.java ):
package com.android.xmlres;
import java.io....
Change activity label from app_name to booklist ( AndroidManifest.xml ):
<?xml version="1.0" encoding="utf-8"?>
<manifes...
Add value for string resource ( res/values/string.xml ):
<?xml version="1.0" encoding="utf-8"?>
<resourc...
Deploy and test:
ant install
Created by freyo on February 23, 2011 13:21:12
Last update: February 23, 2011 13:21:12
I tried to convert a private key from PEM to PKCS12 with OpenSSL and got this error:
C:\myworks>openssl pkcs12 -export -in openssl_ca3....
The problem was that the -in parameter expects both private key and certificate in the same input file, i.e., openssl_ca3.pem in the above example. Appending the certificate file to the key fixed the problem:
C:\myworks>cat openssl_ca3.crt >>openssl_ca3.pem
...