当前位置: 首页>>代码示例>>Python>>正文


Python portal.Portal类代码示例

本文整理汇总了Python中twisted.cred.portal.Portal的典型用法代码示例。如果您正苦于以下问题:Python Portal类的具体用法?Python Portal怎么用?Python Portal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Portal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

 def setUp(self):
     self.realm = Realm()
     portal = Portal(self.realm)
     portal.registerChecker(MockChecker())
     self.authServer = userauth.SSHUserAuthServer()
     self.authServer.transport = FakeTransport(portal)
     self.authServer.serviceStarted()
开发者ID:axray,项目名称:dataware.dreamplug,代码行数:7,代码来源:test_userauth.py

示例2: deploy

def deploy(iface, port, dbLocation, dbType, dbUsername=None, dbPassword=None,
           ssl=False, sslRedirect=False, sslPrivate=None, sslCert=None,
           sslPort=None):

    if dbUsername and dbPassword:
        searchService = searchServices[dbType](
            dbLocation, dbUsername, dbPassword)
    else:
        searchService = searchServices[dbType](dbLocation)

    portal = Portal(PublicHTMLRealm(searchService), [AllowAnonymousAccess()])
    portal.registerChecker(QuasselChecker(searchService), IUsernameHashedPassword)
    portal.registerChecker(SessionChecker(), ISessionCredentials)

    application = service.Application("Querryl")
    site = server.Site(BasicWrapper(portal, []))
    site.sessionFactory = LongSession

    if ssl:
        ctx = DefaultOpenSSLContextFactory(sslPrivate, sslCert)
        ssl_sv = internet.SSLServer(sslPort, site, ctx, interface=iface)
        ssl_sv.setServiceParent(application)

        if sslRedirect:
            site = server.Site(RedirectFromRequest(port=sslPort))

    sv = internet.TCPServer(port, site, interface=iface)
    sv.setServiceParent(application)
    return sv
开发者ID:ddormer,项目名称:Querryl,代码行数:29,代码来源:deployment.py

示例3: setUp

    def setUp(self):
        super(RootTests, self).setUp()

        self.docroot = self.mktemp()
        os.mkdir(self.docroot)

        RootResource.CheckSACL = FakeCheckSACL(sacls={"calendar": ["dreid"]})

        directory = XMLDirectoryService({"xmlFile" : xmlFile})
        augment.AugmentService = augment.AugmentXMLDB(
            xmlFiles=(augmentsFile.path,)
        )

        principals = DirectoryPrincipalProvisioningResource(
            "/principals/",
            directory
        )

        root = RootResource(self.docroot, principalCollections=[principals])

        root.putChild("principals",
                      principals)

        portal = Portal(auth.DavRealm())
        portal.registerChecker(directory)

        self.root = auth.AuthenticationWrapper(
            root,
            portal,
            credentialFactories=(basic.BasicCredentialFactory("Test realm"),),
            loginInterfaces=(auth.IPrincipal,))

        self.site = server.Site(self.root)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:33,代码来源:test_root.py

示例4: main_ssh2http

def main_ssh2http():
    portal = Portal(ExampleRealm())
    c_port = 5022
    factory = SSH2HTTPConverterFactory(c_port)
    portal.registerChecker(factory)
    SSH2HTTPConverterFactory.portal = portal
    reactor.listenTCP(c_port, factory)
开发者ID:matanmaz,项目名称:SshTelnetProxy,代码行数:7,代码来源:twisted-mitm.py

示例5: makeService

    def makeService(self, options):
        class LongSession(Session):
            sessionTimeout = 3600

        if options['steamkey'] is None:
            raise ValueError('Must specify steam API key.')
        if options['strport'] is None:
            raise ValueError('Must specify strport description.')
        if options['dbdir'] is None:
            raise ValueError('Must specify database path.')
        steamAPI = API(key=options['steamkey'])

        store = Store(options['dbdir'])
        keyPath = FilePath(options['dbdir']).child('fernet.key')

        database = Database(store)

        loginRedirect = '/'
        portal = Portal(MapListRealm(database, options['bundle-path'],
                                     steamAPI, loginRedirect))
        portal.registerChecker(PreauthenticatedChecker())
        portal.registerChecker(AllowAnonymousAccess())

        root = HTTPOpenIDAuthSessionWrapper(portal, [], loginRedirect, keyPath,
                                            database)

        site = Site(root)
        site.sessionFactory = LongSession
        return strports.service(options['strport'], site)
开发者ID:jsza,项目名称:jump-map-list,代码行数:29,代码来源:map_list_service.py

示例6: createPortal

 def createPortal(self, realmFactory=None):
     if realmFactory is None:
         realmFactory = SillyRealm
     r = realmFactory()
     p = Portal(r)
     p.registerChecker(AllowAnonymousAccess(), IAnonymous)
     return p
开发者ID:StetHD,项目名称:nevow,代码行数:7,代码来源:test_guard.py

示例7: portal

 def portal(self):
   portal = Portal(self.realm())
   for checker in self.auth_checkers():
     portal.registerChecker(checker)
   if len(self.auth_checkers()) == 0:
     portal.registerChecker(checkers.AllowAnonymousAccess())
   return portal
开发者ID:sbusso,项目名称:smtp-relay,代码行数:7,代码来源:config.py

示例8: makeService

def makeService(config):
    components.registerAdapter(
        GitSession,
        GitAvatar,
        session.ISession)

    with open(config['conf']) as f:
        conf = yaml.load(f.read())

    port = int(conf.get('port', 22))
    host_key = conf.get('host_key')
    driver_key = conf.get('driver', 'example')

    log.msg('Using driver: \'%s\'' % driver_key)

    mgr = driver.DriverManager(
        namespace='gitserver.driver',
        name=driver_key,
        invoke_on_load=False
    )

    portal = Portal(GitRealm(mgr))
    portal.registerChecker(GitPublicKeyChecker(mgr))

    # factory.SSHFactory takes no arguments, so unlike the
    # websocket server, we will assign portal on the class
    # rather than through the constructor.
    # TypeError: this constructor takes no arguments
    # is raised if we pass portal GitFactory(portal)
    GitFactory.portal = portal
    GitSession.driver_key = driver_key

    return internet.TCPServer(port, GitFactory(host_key=host_key))
开发者ID:aventurella,项目名称:gitserver,代码行数:33,代码来源:server.py

示例9: test_unencryptedConnectionWithoutPasswords

    def test_unencryptedConnectionWithoutPasswords(self):
        """
        If the L{SSHUserAuthServer} is not advertising passwords, then an
        unencrypted connection should not cause any warnings or exceptions.
        This is a white box test.
        """
        # create a Portal without password authentication
        portal = Portal(self.realm)
        portal.registerChecker(PrivateKeyChecker())

        # no encryption
        clearAuthServer = userauth.SSHUserAuthServer()
        clearAuthServer.transport = FakeTransport(portal)
        clearAuthServer.transport.isEncrypted = lambda x: False
        clearAuthServer.serviceStarted()
        clearAuthServer.serviceStopped()
        self.assertEqual(clearAuthServer.supportedAuthentications,
                          ['publickey'])

        # only encrypt incoming (the direction the password is sent)
        halfAuthServer = userauth.SSHUserAuthServer()
        halfAuthServer.transport = FakeTransport(portal)
        halfAuthServer.transport.isEncrypted = lambda x: x == 'in'
        halfAuthServer.serviceStarted()
        halfAuthServer.serviceStopped()
        self.assertEqual(clearAuthServer.supportedAuthentications,
                          ['publickey'])
开发者ID:GunioRobot,项目名称:twisted,代码行数:27,代码来源:test_userauth.py

示例10: __init__

 def __init__(self, conf):
     self._init_keys(conf)
     config = cwconfig.instance_configuration(conf.get('cubicweb-instance'))
     repo = Repository(config, TasksManager(), vreg=None)
     portal = Portal(CubicWebSFTPRealm(repo, conf))
     portal.registerChecker(CubicWebCredentialsChecker(repo))
     self.portal = portal
开发者ID:DimitriPapadopoulos,项目名称:rql_download,代码行数:7,代码来源:server.old.py

示例11: listen

	def listen(self, port):
		'''
		Starts listening on the specified port.
		'''
		portal = Portal(credentials.Realm())
		portal.registerChecker(credentials.PasswordChecker(self.__passwd))
		reactor.listenTCP(port, ServerProtocolFactory(portal, self.userlist))
开发者ID:Resplendent-Digital-Assistant,项目名称:RDAServer,代码行数:7,代码来源:network.py

示例12: create_portal

def create_portal(a):
    """I'm responsible for creating the authenticated portal"""
    realm = AggregatorRealm(a)
    portal = Portal(realm)
    checker = InMemoryUsernamePasswordDatabaseDontUse()
    checker.addUser(version.apiversion, a.getPassword())
    portal.registerChecker(checker)
    return portal
开发者ID:pwarren,项目名称:AGDeviceControl,代码行数:8,代码来源:aggregator.py

示例13: makeService

def makeService(options):
    """
    Makes a new swftp-ftp service. The only option is the config file
    location. The config file has the following options:
     - host
     - port
     - auth_url
     - num_persistent_connections
     - connection_timeout
     - welcome_message
    """
    from twisted.protocols.ftp import FTPFactory
    from twisted.web.client import HTTPConnectionPool
    from twisted.cred.portal import Portal

    from swftp.ftp.server import SwiftFTPRealm
    from swftp.auth import SwiftBasedAuthDB
    from swftp.utils import print_runtime_info

    print('Starting SwFTP-ftp %s' % VERSION)

    c = get_config(options['config_file'], options)
    ftp_service = service.MultiService()

    # Add statsd service
    if c.get('ftp', 'log_statsd_host'):
        try:
            from swftp.statsd import makeService as makeStatsdService
            makeStatsdService(
                c.get('ftp', 'log_statsd_host'),
                c.getint('ftp', 'log_statsd_port'),
                sample_rate=c.getfloat('ftp', 'log_statsd_sample_rate'),
                prefix=c.get('ftp', 'log_statsd_metric_prefix')
            ).setServiceParent(ftp_service)
        except ImportError:
            log.err('Missing Statsd Module. Requires "txstatsd"')

    pool = HTTPConnectionPool(reactor, persistent=True)
    pool.maxPersistentPerHost = c.getint('ftp', 'num_persistent_connections')
    pool.cachedConnectionTimeout = c.getint('ftp', 'connection_timeout')

    authdb = SwiftBasedAuthDB(auth_url=c.get('ftp', 'auth_url'),
                              verbose=c.getboolean('ftp', 'verbose'))

    ftpportal = Portal(SwiftFTPRealm())
    ftpportal.registerChecker(authdb)
    ftpfactory = FTPFactory(ftpportal)
    ftpfactory.welcomeMessage = c.get('ftp', 'welcome_message')
    ftpfactory.allowAnonymous = False

    signal.signal(signal.SIGUSR1, print_runtime_info)
    signal.signal(signal.SIGUSR2, print_runtime_info)

    internet.TCPServer(
        c.getint('ftp', 'port'),
        ftpfactory,
        interface=c.get('ftp', 'host')).setServiceParent(ftp_service)
    return ftp_service
开发者ID:smerritt,项目名称:swftp,代码行数:58,代码来源:service.py

示例14: StartServices

def StartServices(username,password):
    from md5 import md5
    password = md5(password).digest()
    
    portal = Portal(SimpleRealm())
    checker = InMemoryUsernamePasswordDatabaseDontUse()
    checker.addUser(username,password)
    portal.registerChecker(checker)
    reactor.listenTCP(7001,pb.PBServerFactory(portal))
开发者ID:carriercomm,项目名称:solinia_depreciated,代码行数:9,代码来源:charservices.py

示例15: createDocumentRoot

    def createDocumentRoot(self):
        docroot = self.mktemp()
        os.mkdir(docroot)

        userResource = TestDAVPrincipalResource("/principals/users/user01")
        userResource.writeDeadProperty(TwistedPasswordProperty("user01"))

        principalCollection = TestPrincipalsCollection(
            "/principals/",
            children={"users": TestPrincipalsCollection(
                    "/principals/users/",
                    children={"user01": userResource})})

        rootResource = self.resource_class(
            docroot, principalCollections=(principalCollection,))

        portal = Portal(DavRealm())
        portal.registerChecker(TwistedPropertyChecker())

        credentialFactories = (basic.BasicCredentialFactory(""),)

        loginInterfaces = (IPrincipal,)

        self.site = Site(AuthenticationWrapper(
            rootResource,
            portal,
            credentialFactories,
            credentialFactories,
            loginInterfaces
        ))

        rootResource.setAccessControlList(self.grant(element.All()))

        for name, acl in (
            ("none"       , self.grant()),
            ("read"       , self.grant(element.Read())),
            ("read-write" , self.grant(element.Read(), element.Write())),
            ("unlock"     , self.grant(element.Unlock())),
            ("all"        , self.grant(element.All())),
        ):
            filename = os.path.join(docroot, name)
            if not os.path.isfile(filename):
                file(filename, "w").close()
            resource = self.resource_class(filename)
            resource.setAccessControlList(acl)

        for name, acl in (
            ("nobind" , self.grant()),
            ("bind"   , self.grant(element.Bind())),
            ("unbind" , self.grant(element.Bind(), element.Unbind())),
        ):
            dirname = os.path.join(docroot, name)
            if not os.path.isdir(dirname):
                os.mkdir(dirname)
            resource = self.resource_class(dirname)
            resource.setAccessControlList(acl)
        return docroot
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:57,代码来源:test_acl.py


注:本文中的twisted.cred.portal.Portal类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。