Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to match latest library, addition of
raw signature tester (/rawsignatures) git-svn-id: http://salmon-protocol.googlecode.com/svn/trunk@76 0c3e17fe-a321-11de-97f0-97815e7b2756
- Loading branch information
johnrobertpanzer
committed
Mar 16, 2010
1 parent
ce73dd1
commit 5bb21f8
Showing
5 changed files
with
192 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<html> | ||
<head> | ||
<title>Raw Signatures Test</title> | ||
<link type="text/css" rel="stylesheet" href="/static/setup_proxy.css"/> | ||
<style type="text/css"> | ||
.entry { margin-bottom: .8em; } | ||
.replies { margin-left: 2em; } | ||
.reply { margin-bottom: 0em; } | ||
</style> | ||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | ||
</head> | ||
<body> | ||
|
||
<div id="header"> | ||
<div class="right"><a href="/oauth/revoke_token">logout</a></div> | ||
<div class="left"><img src="/static/salmon.jpeg" style="float:left"> Raw | ||
Signature Tester</div> | ||
<div id="status" class="hidden"><span class="text">blah blah</span></div> | ||
</div> | ||
|
||
<div id="content"> | ||
<p>Input a raw string to sign (exact bytes entered will be signed):</p> | ||
<form> | ||
<TEXTAREA id='text' rows=12 cols=120></TEXTAREA> | ||
<a title="Sign" href="javascript:sign_text($('#text').val())">Sign</a> | ||
</form> | ||
</div> | ||
<div> | ||
<p>Output:</p> | ||
<TEXTAREA id='output' rows=6 cols=120></TEXTAREA> | ||
</div> | ||
<script> | ||
|
||
// Grab user input and create a signed magic envelope from it: | ||
function sign_text(text) { | ||
showStatus("Signing..."); | ||
$('#output').val('working...'); | ||
$.ajax({ | ||
type: "POST", | ||
url: "/rawsignatures", | ||
data: "data="+encodeURIComponent(text), | ||
success: function(response){ | ||
$('#output').val(response); | ||
showStatusAndHideAfterFiveSecs("Signed!"); | ||
}, | ||
error: function(xhr, statusText, errorThrown){ | ||
$('#output').val("Error "+xhr.status+": "+xhr.responseText); | ||
showStatusAndHideAfterFiveSecs("Error!"); | ||
}, | ||
}); | ||
} | ||
|
||
function showStatus(msg) { | ||
// Move to visible portion of window | ||
$("#status span").css("position", "relative"); | ||
$("#status span").css("top", $("body").scrollTop()); | ||
$('#status span.text').text(msg); | ||
$('#status').fadeIn(); | ||
} | ||
|
||
function hideStatus() { | ||
hideTimer = 0; | ||
$('#status').fadeOut(); | ||
} | ||
|
||
hideTimoutID = 0; | ||
function showStatusAndHideAfterFiveSecs(msg) { | ||
showStatus(msg); | ||
if (hideTimoutID) {clearTimeout(hideTimoutID);} | ||
hideTimoutID = setTimeout(hideStatus, 5000); | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/env python | ||
# | ||
# Copyright 2009 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
"""Test out low level signature API.""" | ||
|
||
import imports | ||
|
||
import logging | ||
import random | ||
import datetime | ||
import wsgiref.handlers | ||
import dumper | ||
import cgi | ||
import sys | ||
|
||
from string import strip | ||
|
||
from google.appengine.ext import webapp | ||
from google.appengine.ext.webapp.util import login_required | ||
from google.appengine.ext.webapp import template | ||
from google.appengine.ext import db | ||
from google.appengine.api import users | ||
import feedparser | ||
import userdb | ||
|
||
import magicsig.magicsigalg as magicsigalg | ||
|
||
from utils import * | ||
import base64 | ||
|
||
class RawSignaturesHandler(webapp.RequestHandler): | ||
"""Handles request to sign a string with a test keypair. | ||
""" | ||
|
||
signing_key = ('RSA.mVgY8RN6URBTstndvmUUPb4UZTdwvwmddSKE5z_jvKUEK6yk1' | ||
'u3rrC9yN8k6FilGj9K0eeUPe2hf4Pj-5CmHww==' | ||
'.AQAB' | ||
'.Lgy_yL3hsLBngkFdDw1Jy9TmSRMiH6yihYetQ8jy-jZXdsZXd8V5' | ||
'ub3kuBHHk4M39i3TduIkcrjcsiWQb77D8Q==') | ||
|
||
@aclRequired | ||
def get(self): | ||
"""Handles initial display of page.""" | ||
data = dict() | ||
logging.info('Raw signatures') | ||
self.response.out.write(template.render('rawsignatures.html', data)) | ||
self.response.set_status(200) | ||
|
||
@aclRequired | ||
def post(self): | ||
"""Handles posting back of data and returns a result via XHR. | ||
Just for demo purposes. Accepts a string as data. | ||
""" | ||
|
||
data = self.request.get('data') | ||
if data: | ||
logging.info('posted raw string = [%s]', data) | ||
sig = magicsigalg.SignatureAlgRsaSha256(self.signing_key).Sign(data) | ||
|
||
logging.info('resulting signature: [%s]', sig) | ||
|
||
self.response.set_status(200) # The default | ||
self.response.out.write('Signed [%s]\n' % data) | ||
self.response.out.write('With key [%s]\n' % self.signing_key) | ||
self.response.out.write('Yielding signature [%s]\n' % sig) | ||
else: | ||
self.response.set_status(400) |