# Path: flumotion/common/log.py
# def init():


import os
from twisted.internet import reactor
from zope.interface import Interface
from flumotion.common import log
        from OpenSSL import SSL
        from flumotion.common import common
    def __init__(self, servable):
        """
        I expose a servable to the network using TCP or SSL.

        @type servable: an implemtor of L{IServable}
        """
        self._servable = servable

    def startSSL(self, host, port, pemFile, configDir):
        """
        Listen as the given host and on the given port using SSL.
        Use the given .pem file, or look for it in the config directory.

        @param pemFile:   File containing the SSL certificate.
                          If it's a full path, respects the full path.
                          If not, looks in configDir for this file.
        @param configDir: directory where .pem file is stored
        @returns: {twisted.internet.interfaces.IListeningPort} on which
        we are listening; call .stopListening() to stop.
        """
        common.assertSSLAvailable()

        # if no path in pemFile, then look for it in the config directory
        if not os.path.split(pemFile)[0]:
            pemFile = os.path.join(configDir, pemFile)
        if not os.path.exists(pemFile):
            self.error(".pem file %s does not exist.\n" \
                "For more information, see \n" \
                "http://www.flumotion.net/doc/flumotion/manual/html/" \
                "chapter-security.html" % pemFile)

# Path: flumotion/common/log.py
# def init():


# Path: flumotion/common/server.py
import os
from twisted.internet import reactor
from zope.interface import Interface
from flumotion.common import log
        from OpenSSL import SSL
        from flumotion.common import common

    def __init__(self, servable):
        """
        I expose a servable to the network using TCP or SSL.

        @type servable: an implemtor of L{IServable}
        """
        self._servable = servable

    def startSSL(self, host, port, pemFile, configDir):
        """
        Listen as the given host and on the given port using SSL.
        Use the given .pem file, or look for it in the config directory.

        @param pemFile:   File containing the SSL certificate.
                          If it's a full path, respects the full path.
                          If not, looks in configDir for this file.
        @param configDir: directory where .pem file is stored
        @returns: {twisted.internet.interfaces.IListeningPort} on which
        we are listening; call .stopListening() to stop.
        """
        common.assertSSLAvailable()

        # if no path in pemFile, then look for it in the config directory
        if not os.path.split(pemFile)[0]:
            pemFile = os.path.join(configDir, pemFile)
        if not os.path.exists(pemFile):
            self.error(".pem file %s does not exist.\n" \
                "For more information, see \n" \
                "http://www.flumotion.net/doc/flumotion/manual/html/" \
                "chapter-security.html" % pemFile)

        log.debug('manager', 'Using PEM certificate file %s' % pemFile)