Skip to content

Instantly share code, notes, and snippets.

View jankronquist's full-sized avatar

Jan Kronquist jankronquist

View GitHub Profile
@jankronquist
jankronquist / GameCreatedEvent.json
Created September 8, 2013 16:11
EventStore JSON example
{
"title": "0@game-123",
"id": "http://192.168.0.16:2113/streams/game-123/0",
"updated": "2013-09-08T16:07:53.5242492Z",
"author": {
"name": "EventStore"
},
"summary": "com_jayway_rps_domain_GameCreatedEvent",
"content": {
"eventStreamId": "game-123",
@jankronquist
jankronquist / client-certificate-authentication.md
Last active January 24, 2021 13:49
Java certificate authentication for both server and client using shared trusted CA.

Certificates

CA and trust keystore

keytool -genkeypair -keyalg RSA -keysize 2048 -validity 365 -alias ca -dname "CN=ca,O=HMS,S=SE" -keystore ca.jks -storepass password
keytool -exportcert -rfc -alias ca -keystore ca.jks -storepass password > ca.pem
cat ca.pem | keytool -importcert -alias ca -noprompt -keystore trust.jks -storepass password

server cert

@jankronquist
jankronquist / SpringAutowiringEntityInterceptor.java
Created December 7, 2011 14:58
Autowiring Morphia entities
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import com.google.code.morphia.AbstractEntityInterceptor;
import com.google.code.morphia.Morphia;
import com.google.code.morphia.mapping.Mapper;
import com.mongodb.DBObject;
@jankronquist
jankronquist / SimpleXPath.java
Created May 10, 2011 14:47
Simple, thread-safe xpath with namespace support
/**
* Thread-safe xpath with namespace support.
*/
public class SimpleXPath {
private final String expression;
public SimpleXPath(String expression) {
this.expression = expression;
}
import java.io.StringReader;
import java.io.StringWriter;
import javax.xml.transform.Templates;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class SimpleXslt {
private Templates templates;