1 #!/usr/bin/env python 2 3 class AccessControlContext(object): 4 def __init__(self): 5 # NOTE: Python-only method. 6 self.acc = None 7 self.combiner = None 8 self.context = None 9 def init__acc_combiner(self, acc, combiner): 10 self.acc = acc 11 self.combiner = combiner 12 self.context = None 13 def init__context(self, context): 14 self.acc = None 15 self.combiner = None 16 self.context = context 17 def checkPermission(self, perm): 18 # NOTE: Implement properly. 19 pass 20 checkPermission___java__security__Permission = checkPermission 21 def equals(self, obj): 22 return self.context == obj.context 23 equals___java__lang__Object = equals 24 def getDomainCombiner(self): 25 return self.combiner 26 getDomainCombiner___java__security__DomainCombiner = getDomainCombiner 27 def hashCode(self): 28 # NOTE: Using Python hash function. 29 return hash(self) 30 hashCode___ = hashCode 31 32 setattr(AccessControlContext, "__init_____java__security__AccessControlContext___java__security__DomainCombiner", 33 AccessControlContext.init__acc_combiner) 34 setattr(AccessControlContext, "__init_____java__security__ProtectionDomain_array_", AccessControlContext.init__context) 35 36 class AccessController(object): 37 def checkPermission(perm): 38 # NOTE: Implement properly. 39 pass 40 checkPermission___java__security__Permission = staticmethod(checkPermission) 41 def doPrivileged(action, context=None): 42 # NOTE: Implement properly. 43 return action.run___() 44 doPrivileged___java__security__PrivilegedAction = staticmethod(doPrivileged) 45 doPrivileged___java__security__PrivilegedAction___java__security__AccessControlContext = staticmethod(doPrivileged) 46 def getContext(): 47 # NOTE: Implement properly. 48 return AccessControlContext() 49 50 # vim: tabstop=4 expandtab shiftwidth=4