?? security-server,v
字號(hào):
head 1.1;
access;
symbols;
locks
cbbrowne:1.1; strict;
comment @# @;
1.1
date 2000.06.09.12.32.50; author cbbrowne; state Exp;
branches;
next ;
desc
@@
1.1
log
@Initial revision
@
text
@#!/usr/bin/env python
import CORBA
import sys
import regex
import string
from string import split, strip
class USERAUTH: # interface
def validate(self, user, capability):
if capabilities.has_key(user):
caplist = split(capabilities[user], ',')
if (caplist.occurrences(capability) == 0):
raise USERAUTH.NOTAUTHENTICATED
if not tokens.has_key(user):
raise USERAUTH.NOTAUTHENTICATED
def login (self, user, password):
if pwtable.has_key(user):
if (password == pwtable[user]):
print "Authenticated", user
tokens[user] = currtoken
currtoken = currtoken * 2 + 533
if currtoken > 12000:
currtoken = currtoken - 12000
print "Latest token:", currtoken
return tokens[user]
else:
print "Bad password!"
print "ID:", user, "PW:", password
raise USERAUTH.NOTAUTHENTICATED
else:
print "Bad user!"
print "ID:", user, "PW:", password
raise USERAUTH.NOTAUTHENTICATED
def submit(self, msg):
print "Message Received from:", msg.fr
print "Message for:", msg.to
for line in msg.body:
print line
self.msgs = self.msgs + 1
print "Messages: ", self.msgs
## First, load in the IDs.
f=open("/brownes/knuth/local/src/ORBit/others/dvdcorba/server/ids.txt")
pwtable={}
tokens={}
capabilities={}
currtoken=252
while 1:
line=f.readline()
if not line: break
if not (line[0] == "#"):
(id, password, caps) = split( line, ':')
id=strip(id)
pwtable[id] = strip(password)
capabilities[id]=strip(caps)
for id in pwtable.keys():
print "ID:", id, " --> ", pwtable[id]
CORBA.load_idl("security.idl")
CORBA.load_idl("/usr/share/idl/name-service.idl")
orb = CORBA.ORB_init((), CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
servant = POA.SECURITY.USERAUTH(USERAUTH())
poa.activate_object(servant)
ref = poa.servant_to_reference(servant)
open("./security-server.ior", "w").write(orb.object_to_string(ref))
poa.the_POAManager.activate()
orb.run()
@
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -