本文整理汇总了Python中twisted.cred.checkers.InMemoryUsernamePasswordDatabaseDontUse类的典型用法代码示例。如果您正苦于以下问题:Python InMemoryUsernamePasswordDatabaseDontUse类的具体用法?Python InMemoryUsernamePasswordDatabaseDontUse怎么用?Python InMemoryUsernamePasswordDatabaseDontUse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InMemoryUsernamePasswordDatabaseDontUse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
yield SMPPClientTestCases.setUp(self)
# Init SMPPServerPB
SMPPServerPBConfigInstance = SMPPServerPBConfig()
SMPPServerPBInstance = SMPPServerPB(SMPPServerPBConfigInstance)
SMPPServerPBInstance.addSmpps(self.smpps_factory)
p = portal.Portal(JasminPBRealm(SMPPServerPBInstance))
c = InMemoryUsernamePasswordDatabaseDontUse()
c.addUser('smppsadmin', md5('smppspwd').digest())
p.registerChecker(c)
jPBPortalRoot = JasminPBPortalRoot(p)
self.SMPPServerPBInstanceServer = reactor.listenTCP(SMPPServerPBConfigInstance.port,
pb.PBServerFactory(jPBPortalRoot))
# Init SMPPServerPBClient and connect it to SMPPServerPB
SMPPServerPBClientConfigInstance = SMPPServerPBClientConfig()
self.SMPPServerPBProxyInstance = SMPPServerPBProxy()
yield self.SMPPServerPBProxyInstance.connect(
SMPPServerPBClientConfigInstance.host,
SMPPServerPBClientConfigInstance.port,
SMPPServerPBClientConfigInstance.username,
SMPPServerPBClientConfigInstance.password,
retry=False)
# Lower the timeout config to pass the timeout tests quickly
self.DLRThrower.config.timeout = 2
self.DLRThrower.config.retry_delay = 1
self.DLRThrower.config.max_retries = 2
# Most important thing:
# Swap default direct smpps access to perspectivebroker smpps access:
self.DLRThrower.addSmpps(self.SMPPServerPBProxyInstance)
开发者ID:balsagoth,项目名称:jasmin,代码行数:34,代码来源:test_standalone_throwers_dlr.py
示例2: startSMPPClientManagerPBService
def startSMPPClientManagerPBService(self):
"Start SMPP Client Manager PB server"
SMPPClientPBConfigInstance = SMPPClientPBConfig(self.options["config"])
self.components["smppcm-pb-factory"] = SMPPClientManagerPB()
self.components["smppcm-pb-factory"].setConfig(SMPPClientPBConfigInstance)
# Set authentication portal
p = portal.Portal(JasminPBRealm(self.components["smppcm-pb-factory"]))
if SMPPClientPBConfigInstance.authentication:
c = InMemoryUsernamePasswordDatabaseDontUse()
c.addUser(SMPPClientPBConfigInstance.admin_username, SMPPClientPBConfigInstance.admin_password)
p.registerChecker(c)
else:
p.registerChecker(AllowAnonymousAccess())
jPBPortalRoot = JasminPBPortalRoot(p)
# Add service
self.components["smppcm-pb-server"] = reactor.listenTCP(
SMPPClientPBConfigInstance.port,
pb.PBServerFactory(jPBPortalRoot),
interface=SMPPClientPBConfigInstance.bind,
)
# AMQP Broker is used to listen to submit_sm queues and publish to deliver_sm/dlr queues
self.components["smppcm-pb-factory"].addAmqpBroker(self.components["amqp-broker-factory"])
self.components["smppcm-pb-factory"].addRedisClient(self.components["rc"])
开发者ID:Koulio,项目名称:jasmin,代码行数:27,代码来源:jasmind.py
示例3: startRouterPBService
def startRouterPBService(self):
"Start Router PB server"
RouterPBConfigInstance = RouterPBConfig(self.options['config'])
self.components['router-pb-factory'] = RouterPB()
self.components['router-pb-factory'].setConfig(RouterPBConfigInstance)
# Set authentication portal
p = portal.Portal(JasminPBRealm(self.components['router-pb-factory']))
if RouterPBConfigInstance.authentication:
c = InMemoryUsernamePasswordDatabaseDontUse()
c.addUser(RouterPBConfigInstance.admin_username,
RouterPBConfigInstance.admin_password)
p.registerChecker(c)
else:
p.registerChecker(AllowAnonymousAccess())
jPBPortalRoot = JasminPBPortalRoot(p)
# Add service
self.components['router-pb-server'] = reactor.listenTCP(
RouterPBConfigInstance.port,
pb.PBServerFactory(jPBPortalRoot),
interface=RouterPBConfigInstance.bind)
# AMQP Broker is used to listen to deliver_sm/dlr queues
return self.components['router-pb-factory'].addAmqpBroker(self.components['amqp-broker-factory'])
开发者ID:ktosiu,项目名称:jasmin,代码行数:26,代码来源:jasmind.py
示例4: setUp
def setUp(self, authentication = False):
# Initiating config objects without any filename
# will lead to setting defaults and that's what we
# need to run the tests
self.RouterPBConfigInstance = RouterPBConfig()
# Launch the router server
self.pbRoot_f = RouterPB()
# Mock callbacks
# will be used for assertions
self.pbRoot_f.bill_request_submit_sm_resp_callback = mock.Mock(wraps = self.pbRoot_f.bill_request_submit_sm_resp_callback)
self.pbRoot_f.deliver_sm_callback = mock.Mock(wraps = self.pbRoot_f.deliver_sm_callback)
self.pbRoot_f.setConfig(self.RouterPBConfigInstance)
p = portal.Portal(JasminPBRealm(self.pbRoot_f))
if not authentication:
p.registerChecker(AllowAnonymousAccess())
else:
c = InMemoryUsernamePasswordDatabaseDontUse()
c.addUser('test_user', md5('test_password').digest())
p.registerChecker(c)
jPBPortalRoot = JasminPBPortalRoot(p)
self.PBServer = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot))
self.pbPort = self.PBServer.getHost().port
开发者ID:MeherBouhdid,项目名称:jasmin,代码行数:25,代码来源:test_router.py
示例5: setUp
def setUp(self, authentication=False):
"This will launch InterceptorPB and provide a client connected to it."
# Launch a client in a disconnected state
# it will be connected on demand through the self.ipb_connect() method
self.ipb_client = InterceptorPBProxy()
yield ProvisionWithoutInterceptorPB.setUp(self)
# Initiating config objects without any filename
# will lead to setting defaults and that's what we
# need to run the tests
InterceptorPBConfigInstance = InterceptorPBConfig()
# Launch the interceptor server
pbInterceptor_factory = InterceptorPB()
pbInterceptor_factory.setConfig(InterceptorPBConfigInstance)
# Configure portal
p = portal.Portal(JasminPBRealm(pbInterceptor_factory))
if not authentication:
p.registerChecker(AllowAnonymousAccess())
else:
c = InMemoryUsernamePasswordDatabaseDontUse()
c.addUser("test_user", md5("test_password").digest())
p.registerChecker(c)
jPBPortalRoot = JasminPBPortalRoot(p)
self.pbInterceptor_server = reactor.listenTCP(0, pb.PBServerFactory(jPBPortalRoot))
self.pbInterceptor_port = self.pbInterceptor_server.getHost().port
开发者ID:hunterfu,项目名称:jasmin,代码行数:28,代码来源:test_router_http_interception.py
示例6: manhole_factory
def manhole_factory(namespace, username, password):
"""
Produces a factory object which can be used to listen for telnet
connections to the manhole.
"""
assert isinstance(namespace, dict)
assert isinstance(username, STRING_TYPES)
assert isinstance(password, STRING_TYPES)
assert TelnetRealm.NAMESPACE is None, "namespace already set"
# TODO: we should try to use the system to authorize users instead
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser(username, password)
# Setup the namespace
namespace = namespace.copy()
namespace.setdefault("pp", pprint)
namespace.setdefault("show", show)
realm = TelnetRealm()
TelnetRealm.NAMESPACE = namespace
portal = Portal(realm, [checker])
factory = ServerFactory()
factory.protocol = TransportProtocolFactory(portal)
return factory
开发者ID:xlhtc007,项目名称:pyfarm-agent,代码行数:25,代码来源:manhole.py
示例7: main
def main(reactor, duration):
chunkSize = 16384
server = BenchmarkSSHFactory()
server.portal = Portal(BenchmarkRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.users = {b"username": b"password"}
server.portal.registerChecker(checker)
port = reactor.listenTCP(0, server)
tcpServer = TCP4ClientEndpoint(reactor, '127.0.0.1', port.getHost().port)
sshServer = SSHCommandClientEndpoint(
b'chargen', tcpServer,
lambda command:
SSHPasswordUserAuth(b'username', b'password', command))
client = Client(reactor, sshServer)
d = client.run(duration, chunkSize)
def cleanup(passthrough):
d = port.stopListening()
d.addCallback(lambda ignored: passthrough)
return d
d.addCallback(cleanup)
return d
开发者ID:twisted-infra,项目名称:twisted-benchmarks,代码行数:26,代码来源:ssh_throughput.py
示例8: 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
示例9: main
def main():
from twisted.cred.portal import Portal
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
portal = Portal(SimpleRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("benchmark", "benchmark")
portal.registerChecker(checker)
reactor.listenTCP(8787, pb.PBServerFactory(portal))
reactor.run()
开发者ID:BillAndersan,项目名称:twisted,代码行数:9,代码来源:pbbenchserver.py
示例10: 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
示例11: StartServices
def StartServices():
#fire up the World Stuff
portal = Portal(SimpleRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
from md5 import md5
password = md5("daemon").digest()
for x in range(0,100):
checker.addUser(str(x), password)
portal.registerChecker(checker)
reactor.listenTCP(7000,pb.PBServerFactory(portal))
开发者ID:carriercomm,项目名称:solinia_depreciated,代码行数:10,代码来源:worldservices.py
示例12: main
def main():
from twisted.internet import reactor
from twisted.cred.portal import Portal
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
portal = Portal(SimpleRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("guest", "guest")
portal.registerChecker(checker)
reactor.listenTCP(pb.portno, pb.PBServerFactory(portal))
reactor.run()
开发者ID:Almad,项目名称:twisted,代码行数:10,代码来源:pbecho.py
示例13: main
def main():
"""
Start the AMP server and the reactor.
"""
startLogging(stdout)
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("testuser", "examplepass")
realm = AdditionRealm()
factory = CredAMPServerFactory(Portal(realm, [checker]))
reactor.listenTCP(7805, factory)
reactor.run()
开发者ID:pombredanne,项目名称:epsilon,代码行数:11,代码来源:auth_server.py
示例14: setServiceParent
def setServiceParent(self, parent):
service.MultiService.setServiceParent(self, parent)
portal = Portal(PbRealm(parent))
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("guest", "guest")
portal.registerChecker(checker)
s = strports.service("unix:%s" % self.socket, pb.PBServerFactory(portal))
s.setServiceParent(self)
开发者ID:isotoma,项目名称:badgerproxy,代码行数:11,代码来源:pb.py
示例15: WrapResourceTestCase
class WrapResourceTestCase(TestCase):
def setUp(self):
self.checker = InMemoryUsernamePasswordDatabaseDontUse()
self.checker.addUser("joe", "blow")
def test_wrapResourceWeb(self):
from twisted.web.resource import IResource, Resource
root = Resource()
wrapped = wrapResource(root, [self.checker])
self.assertTrue(IResource.providedBy(wrapped))
开发者ID:rockstar,项目名称:txjsonrpc,代码行数:11,代码来源:test_auth.py
示例16: setup
def setup():
from twisted.internet import reactor
from twisted.cred.checkers import InMemoryUsernamePasswordDatabaseDontUse
portal = Portal(SimpleRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("guest", "password")
portal.registerChecker(checker)
reactor.listenTCP(7777, ConsoleSMTPFactory(portal))
开发者ID:firemark,项目名称:EmailCatcher,代码行数:11,代码来源:smtp.py
示例17: test_setupSiteWithProtectedHook
def test_setupSiteWithProtectedHook(self):
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("guest", "password")
self.svc.setupSite(self.makeConfig(change_hook_dialects={"base": True}, change_hook_auth=[checker]))
site = self.svc.site
# check that it has the right kind of resources attached to its
# root
root = site.resource
req = mock.Mock()
self.assertIsInstance(root.getChildWithDefault("change_hook", req), HTTPAuthSessionWrapper)
开发者ID:stefanseefeld,项目名称:buildbot,代码行数:12,代码来源:test_www_service.py
示例18: __init__
def __init__(self, port=8787):
BaseService.__init__(self)
boiler = None
portal = Portal(PbRealm(boiler))
checker = InMemoryUsernamePasswordDatabaseDontUse()
checker.addUser("guest", "guest")
portal.registerChecker(checker)
service = strports.service("tcp:%d" % port, pb.PBServerFactory(portal))
service.setServiceParent(self)
开发者ID:isotoma,项目名称:boiler,代码行数:12,代码来源:pb.py
示例19: StartServices
def StartServices(callback):
global IMPCONNECTED_CALLBACK
IMPCONNECTED_CALLBACK = callback
# fire up the World Stuff
portal = Portal(SimpleRealm())
checker = InMemoryUsernamePasswordDatabaseDontUse()
from md5 import md5
password = md5("imp").digest()
for x in range(0, 100):
checker.addUser(str(x), password)
portal.registerChecker(checker)
reactor.listenTCP(7005, pb.PBServerFactory(portal))
开发者ID:mixxit,项目名称:solinia_depreciated,代码行数:13,代码来源:worldimp.py
示例20: test_requestAvatarId
def test_requestAvatarId(self):
"""
L{SSHProtocolChecker.requestAvatarId} should defer to one if its
registered checkers to authenticate a user.
"""
checker = SSHProtocolChecker()
passwordDatabase = InMemoryUsernamePasswordDatabaseDontUse()
passwordDatabase.addUser('test', 'test')
checker.registerChecker(passwordDatabase)
d = checker.requestAvatarId(UsernamePassword('test', 'test'))
def _callback(avatarId):
self.assertEquals(avatarId, 'test')
return d.addCallback(_callback)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:13,代码来源:test_checkers.py
注:本文中的twisted.cred.checkers.InMemoryUsernamePasswordDatabaseDontUse类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论