Merge pull request #133 from kuba/zope.interface

zope.interface
This commit is contained in:
James Kasten
2014-12-21 20:25:39 -08:00
9 changed files with 63 additions and 60 deletions
-5
View File
@@ -1,5 +0,0 @@
:mod:`letsencrypt.client.configurator`
--------------------------------------
.. automodule:: letsencrypt.client.configurator
:members:
+5
View File
@@ -0,0 +1,5 @@
:mod:`letsencrypt.client.interfaces`
------------------------------------
.. automodule:: letsencrypt.client.interfaces
:members:
-5
View File
@@ -1,5 +0,0 @@
:mod:`letsencrypt.client.validator`
-----------------------------------
.. automodule:: letsencrypt.client.validator
:members:
+2 -25
View File
@@ -5,29 +5,6 @@ import sys
from letsencrypt.client import CONFIG from letsencrypt.client import CONFIG
class Challenge(object):
"""Let's Encrypt challenge."""
def __init__(self, configurator):
self.config = configurator
def perform(self, quiet=True):
"""Perform the challange.
:param bool quiet: TODO
"""
raise NotImplementedError()
def generate_response(self):
"""Generate response."""
raise NotImplementedError()
def cleanup(self):
"""Cleanup."""
raise NotImplementedError()
def gen_challenge_path(challenges, combos=None): def gen_challenge_path(challenges, combos=None):
"""Generate a plan to get authority over the identity. """Generate a plan to get authority over the identity.
@@ -101,13 +78,13 @@ def _find_smart_path(challenges, combos):
def _find_dumb_path(challenges): def _find_dumb_path(challenges):
"""Find challange path without server hints. """Find challenge path without server hints.
Should be called if the combinations hint is not included by the Should be called if the combinations hint is not included by the
server. This function returns the best path that does not contain server. This function returns the best path that does not contain
multiple mutually exclusive challenges. multiple mutually exclusive challenges.
:param list challanges: A list of challenges from ACME "challenge" :param list challenges: A list of challenges from ACME "challenge"
server message to be fulfilled by the client in order to prove server message to be fulfilled by the client in order to prove
possession of the identifier. possession of the identifier.
+7 -3
View File
@@ -1,12 +1,13 @@
import textwrap import textwrap
import dialog import dialog
import zope.interface
from letsencrypt.client import challenge from letsencrypt.client import interfaces
class InteractiveChallenge(challenge.Challenge): class InteractiveChallenge(object):
"""Interactive challange. """Interactive challenge.
Interactive challenge displays the string sent by the CA formatted Interactive challenge displays the string sent by the CA formatted
to fit on the screen of the client. The Challenge also adds proper to fit on the screen of the client. The Challenge also adds proper
@@ -14,9 +15,12 @@ class InteractiveChallenge(challenge.Challenge):
process. process.
""" """
zope.interface.implements(interfaces.IChallenge)
BOX_SIZE = 70 BOX_SIZE = 70
def __init__(self, string): def __init__(self, string):
super(InteractiveChallenge, self).__init__()
self.string = string self.string = string
def perform(self, quiet=True): def perform(self, quiet=True):
+36 -1
View File
@@ -1,6 +1,8 @@
"""Interfaces.""" """Let's Encrypt client interfaces."""
import zope.interface import zope.interface
# pylint: disable=no-self-argument,no-method-argument
class IAuthenticator(zope.interface.Interface): class IAuthenticator(zope.interface.Interface):
"""Generic Let's Encrypt Authenticator. """Generic Let's Encrypt Authenticator.
@@ -16,6 +18,23 @@ class IAuthenticator(zope.interface.Interface):
"""Revert changes and shutdown after challenges complete.""" """Revert changes and shutdown after challenges complete."""
class IChallenge(zope.interface.Interface):
"""Let's Encrypt challenge."""
def perform(quiet=True):
"""Perform the challenge.
:param bool quiet: TODO
"""
def generate_response():
"""Generate response."""
def cleanup():
"""Cleanup."""
class IInstaller(zope.interface.Interface): class IInstaller(zope.interface.Interface):
"""Generic Let's Encrypt Installer Interface. """Generic Let's Encrypt Installer Interface.
@@ -89,3 +108,19 @@ class IInstaller(zope.interface.Interface):
def restart(): def restart():
"""Restart or refresh the server content.""" """Restart or refresh the server content."""
class IValidator(object):
"""Configuration validator."""
def redirect(name):
pass
def ocsp_stapling(name):
pass
def https(names):
pass
def hsts(name):
pass
@@ -8,19 +8,22 @@ import time
import dialog import dialog
import requests import requests
import zope.interface
from letsencrypt.client import challenge from letsencrypt.client import interfaces
class RecoveryContact(challenge.Challenge): class RecoveryContact(object):
"""Recovery Contact Identitifier Validation Challange. """Recovery Contact Identitifier Validation Challenge.
Based on draft-barnes-acme, section 6.3. Based on draft-barnes-acme, section 6.3.
""" """
zope.interface.implements(interfaces.IChallenge)
def __init__(self, activation_url="", success_url="", contact="", def __init__(self, activation_url="", success_url="", contact="",
poll_delay=3): poll_delay=3):
super(RecoveryContact, self).__init__()
self.token = "" self.token = ""
self.activation_url = activation_url self.activation_url = activation_url
self.success_url = success_url self.success_url = success_url
@@ -3,19 +3,22 @@
.. note:: This challenge has not been implemented into the project yet .. note:: This challenge has not been implemented into the project yet
""" """
from letsencrypt.client import challenge import zope.interface
from letsencrypt.client import display from letsencrypt.client import display
from letsencrypt.client import interfaces
class RecoveryToken(challenge.Challenge): class RecoveryToken(object):
"""Recovery Token Identifier Validation Challenge. """Recovery Token Identifier Validation Challenge.
Based on draft-barnes-acme, section 6.4. Based on draft-barnes-acme, section 6.4.
""" """
zope.interface.implements(interfaces.IChallenge)
def __init__(self, configurator): def __init__(self):
super(RecoveryToken, self).__init__(configurator) super(RecoveryToken, self).__init__()
self.token = "" self.token = ""
def perform(self, quiet=True): def perform(self, quiet=True):
-14
View File
@@ -1,14 +0,0 @@
class Validator(object):
"""Configuration validator."""
def redirect(self, name):
raise NotImplementedError()
def ocsp_stapling(self, name):
raise NotImplementedError()
def https(self, names):
raise NotImplementedError()
def hsts(self, name):
raise NotImplementedError()