Skip to content

Commit

Permalink
Front page now shows the number of stored keys instead of a
Browse files Browse the repository at this point in the history
ComponentLookupError message.
  • Loading branch information
mgedmin committed Sep 4, 2008
1 parent e092a59 commit 594c95b
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ CHANGES

- Sample server shows how to enable SSL

- Front page now shows the number of stored keys instead of a
ComponentLookupError message.

- Command-line client for testing a remote Key Management Server

- Bugfix: LocalKeyManagementFacility was broken (AttributeError: 'RESTClient'
Expand Down
13 changes: 11 additions & 2 deletions src/keas/kmi/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The REST API of the master key management facility defines the communication
with the local facility. When a new encryption key pair is created, we simply
make a `POST` call to the following URL::

http://server:port/master/new
http://server:port/new

The request should have no body and the response is simply the key encrypting
key.
Expand Down Expand Up @@ -235,7 +235,7 @@ The key is available in the facility of course:

We can now fetch the encryption key pair using a `POST` call to this URL::

http://server:port/master/key
http://server:port/key

The request sends the key encrypting key in its body. The response is the
encryption key string:
Expand All @@ -251,6 +251,15 @@ encryption key string:
>>> len(encKey)
32

A `GET` request to the root shows us a server status page

>>> request = TestRequest()
>>> request.method = 'GET'

>>> newCall = rest.StatusView(keys, request)
>>> print newCall()
KMS server holding 3 keys


The Testing Key Management Facility
-----------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/keas/kmi/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/>
<require
permission="keas.kmi.AccessKey"
attributes="getEncryptionKey"
attributes="getEncryptionKey __len__"
/>
</class>

Expand Down
6 changes: 6 additions & 0 deletions src/keas/kmi/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def __call__(self):
return 'Method not allowed.'
return getattr(self, method)()

class StatusView(RestView):

def GET(self):
self.request.response.setHeader('content-type', 'text/plain')
return 'KMS server holding %d keys' % len(self.context)

class NewView(RestView):

def POST(self):
Expand Down
12 changes: 12 additions & 0 deletions src/keas/kmi/rest.zcml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<configure xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser">

<browser:defaultView
for=".interfaces.IKeyManagementFacility"
name="index.html"
/>

<browser:page
for=".interfaces.IKeyManagementFacility"
name="index.html"
class=".rest.StatusView"
permission="zope.Public"
/>

<browser:page
for=".interfaces.IKeyManagementFacility"
name="new"
Expand Down

0 comments on commit 594c95b

Please sign in to comment.