Removes the old busted GAE/Java sigserver code

Change-Id: I6f339d3e9770dd38a51b359e6011d0ab94eafcf2
This commit is contained in:
Brett Slatkin 2011-12-04 13:13:59 -08:00
parent 741a59352f
commit cba9c3638e
12 changed files with 0 additions and 323 deletions

View File

@ -1,62 +0,0 @@
<project>
<property name="sdk.dir" location="/tmp/appengine-java-sdk" />
<import file="${sdk.dir}/config/user/ant-macros.xml" />
<path id="project.classpath">
<pathelement path="war/WEB-INF/classes" />
<fileset dir="war/WEB-INF/lib">
<include name="**/*.jar" />
</fileset>
<fileset dir="${sdk.dir}/lib">
<include name="shared/**/*.jar" />
</fileset>
</path>
<target name="copyjars"
description="Copies the App Engine JARs to the WAR.">
<copy
todir="war/WEB-INF/lib"
flatten="true">
<fileset dir="${sdk.dir}/lib/user">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="copylibs"
description="Copies the app-specific libs to the WAR.">
<copy
todir="war/WEB-INF/lib"
flatten="true">
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="compile" depends="copylibs,copyjars"
description="Compiles Java source and copies other source files to the WAR.">
<mkdir dir="war/WEB-INF/classes" />
<copy todir="war/WEB-INF/classes">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac
srcdir="src"
destdir="war/WEB-INF/classes"
classpathref="project.classpath"
debug="on" />
</target>
<target name="runserver" depends="compile"
description="Starts the development server.">
<dev_appserver war="war" port="8080" >
<options>
<arg value="--jvm_flag=-Xdebug"/>
</options>
</dev_appserver>
</target>
</project>

View File

@ -1,12 +0,0 @@
package org.camlistore.sigserver;
import java.io.IOException;
import javax.servlet.http.*;
public class SignServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Hello, world");
}
}

View File

@ -1,138 +0,0 @@
package org.camlistore.sigserver;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.SignatureException;
import java.util.Enumeration;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.*;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonParser;
import org.bouncycastle.bcpg.ArmoredInputStream;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPObjectFactory;
import org.bouncycastle.openpgp.PGPPublicKey;
import org.bouncycastle.openpgp.PGPPublicKeyRingCollection;
import org.bouncycastle.openpgp.PGPSignature;
import org.bouncycastle.openpgp.PGPSignatureList;
import org.bouncycastle.openpgp.PGPUtil;
public class VerifyServlet extends HttpServlet {
private Logger log = Logger.getLogger(VerifyServlet.class.getName());
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String sjson = req.getParameter("sjson");
String keyArmored = req.getParameter("keyarmored"); // Non-standard
resp.setContentType("text/plain");
// Validate the signed JSON object and extract the signature and signer.
int sigIndex = sjson.lastIndexOf(",\"camliSig\":\"");
if (sigIndex == -1) {
resp.getWriter().println("Missing camli object signature");
return;
}
String sigJson = "{" + sjson.substring(sigIndex + 1);
JsonObject sigObj;
try {
sigObj = (new JsonParser()).parse(sigJson).getAsJsonObject();
} catch (JsonParseException e) {
e.printStackTrace();
resp.getWriter().println("Invalid JSON signature object: " + e);
return;
} catch (IllegalStateException e) {
e.printStackTrace();
resp.getWriter().println("Invalid JSON signature object: " + e);
return;
}
if (sigObj.entrySet().size() > 1) {
resp.getWriter().println(
"Signature object contains more than 'camliSig':\n" + sigJson);
return;
}
JsonPrimitive sigPrimative = sigObj.getAsJsonPrimitive("camliSig");
if (sigPrimative == null) {
resp.getWriter().println("'camliSig' missing from top-level");
return;
}
String camliSig;
try {
camliSig = sigPrimative.getAsString();
} catch (ClassCastException e) {
e.printStackTrace();
resp.getWriter().println("Invalid 'camliSig' value: " + e);
return;
}
String camliJson = sjson.substring(0, sigIndex) + "}";
JsonObject camliObj;
try {
camliObj = (new JsonParser()).parse(sjson).getAsJsonObject();
} catch (JsonParseException e) {
e.printStackTrace();
resp.getWriter().println("Invalid JSON object: " + e);
return;
} catch (IllegalStateException e) {
e.printStackTrace();
resp.getWriter().println("Invalid JSON object: " + e);
return;
}
JsonPrimitive signerPrimative = camliObj.getAsJsonPrimitive("camliSigner");
if (signerPrimative == null) {
resp.getWriter().println("'camliSigner' missing from top-level");
return;
}
String camliSigner;
try {
camliSigner = signerPrimative.getAsString();
} catch (ClassCastException e) {
resp.getWriter().println("Invalid 'camliSigner' value: " + e);
return;
}
log.info("camliSig='" + camliSig + "', " +
"camliSigner='" + camliSigner + "', " +
"keyArmored='" + keyArmored + "'");
// Most of this code originally from the Bouncy Castle PGP example app.
try {
PGPObjectFactory pgpFactory = new PGPObjectFactory(
new ArmoredInputStream(
new ByteArrayInputStream(camliSig.getBytes("UTF-8")),
false));
PGPSignatureList signatureList = (PGPSignatureList) pgpFactory.nextObject();
PGPSignature sig = signatureList.get(0);
log.info("Signature found: " + sig);
PGPPublicKeyRingCollection pubKeyRing =
new PGPPublicKeyRingCollection(
new ArmoredInputStream(
new ByteArrayInputStream(keyArmored.getBytes("UTF-8"))));
PGPPublicKey key = pubKeyRing.getPublicKey(sig.getKeyID());
// NOTE(bslatkin): Can't use BouncyCastle's security provider for crypto
// operations because of App Engine bug. Doh.
// http://code.google.com/p/googleappengine/issues/detail?id=1612
sig.initVerify(key, new BouncyCastleProvider());
sig.update(camliJson.getBytes("UTF-8"));
resp.getWriter().println(sig.verify() ? "YES" : "NO");
} catch (IOException e) {
log.log(Level.SEVERE, "Input problem", e);
resp.getWriter().println("Input problem: " + e);
} catch (PGPException e) {
log.log(Level.SEVERE, "PGP problem", e);
resp.getWriter().println("PGP problem: " + e);
} catch (SignatureException e) {
log.log(Level.SEVERE, "Signature problem", e);
resp.getWriter().println("Signature problem: " + e);
}
}
}

View File

@ -1 +0,0 @@
test

View File

@ -1,35 +0,0 @@
-----BEGIN PGP PRIVATE KEY BLOCK-----
Version: GnuPG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fxclCpDMvXhUNbo2J3mfJrkZwdjHj3Bh6F
Kj2S0hQ6mWRas8fgP5PLopeSJ4xBnXzF2TV+XudANklp41cglAeIo3ERABEBAAG0
KVRlc3QgS2V5IChGb3IgdGVzdGluZykgPHRlc3RAZXhhbXBsZS5jb20+iLgEEwEC
ACIFAk07cOICGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEItNsq2Akzzk
8lYD/2g8suWHKfu5gLDzGWHwJs0A1fISJAkkt8vrGxpcjWUVwCbtj8RP5SfsU68T
BRw0u3E8vGlC0PnYabHy9DY8j169RSp01YQrsTlmhLHUEkAPaaVKMuX6swT4YlBd
idmP/cFU9N0kYUtPw5/eUSmZW2sHX2iYTh2EBhc2UTEDvLyruI0ETTtw4gEEAMyJ
x2Ha0Rwu4uHuMGC5ctAf+dmnUUE8id0bgv4XQTnUAXE7N3dtGtzv2NaX836FHGQj
XmWy0q6SE+C46rm7eCfShfxXbPx1F7BywAIqP4OafotL/JbgePCbi/mpT7WFRulD
Y6fzXGg3hwXG9hfzWP/VQVGvXcJG58YTPbDGIABHABEBAAGInwQYAQIACQUCTTtw
4gIbDAAKCRCLTbKtgJM85MBNA/9GAtjrCTFqfAScXVOSSNhd3ObnlwE9RWSbpn63
mxudIxNQoLs4kcZ13dQscmfC3P+IO+6lSqPFZSBcpfQ9he5CuwFFKys2oEH2jxTI
e3K6o8kiXGq89mHCnwlb3ySTQYT93QzBgLHIrm5W3EiklhYqIQdbtbml7mQIbfnL
meGCbA==
=5YOm
-----END PGP PUBLIC KEY BLOCK-----

View File

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>camlisig</application>
<version>1</version>
</appengine-web-app>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">
<servlet>
<servlet-name>signservlet</servlet-name>
<servlet-class>org.camlistore.sigserver.SignServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>verifyservlet</servlet-name>
<servlet-class>org.camlistore.sigserver.VerifyServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>signservlet</servlet-name>
<url-pattern>/camli/sig/sign</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>verifyservlet</servlet-name>
<url-pattern>/camli/sig/verify</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>

View File

@ -1,25 +0,0 @@
<html>
<head>
<title>Test /camli/sig/*</title>
</head>
<body>
<h1>Verify</h1>
<form action="/camli/sig/verify" method="post" accept-charset="utf-8">
<p>
<label for="sjson">Camli object (JSON with "camliSig" and "camliSigner"):</label>
<p>
<textarea id="sjson" name="sjson" rows="10" cols="70"></textarea>
<p>
<label for="keyarmored">Optional armored public key (eg, "-----BEGIN PGP PUBLIC KEY BLOCK"):</label>
<p>
<textarea id="keyarmored" name="keyarmored" rows="10" cols="70"></textarea>
<p>
<input type="submit" value="Verify">
</form>
</body>
</html>