17 # import standard packages |
17 # import standard packages |
18 from persistent.list import PersistentList |
18 from persistent.list import PersistentList |
19 from persistent.dict import PersistentDict |
19 from persistent.dict import PersistentDict |
20 |
20 |
21 # import Zope3 interfaces |
21 # import Zope3 interfaces |
22 from zope.app.authentication.interfaces import IPrincipalInfo |
|
23 from zope.authentication.interfaces import IAuthentication |
22 from zope.authentication.interfaces import IAuthentication |
|
23 from zope.pluggableauth.interfaces import IPrincipalInfo |
24 |
24 |
25 # import local interfaces |
25 # import local interfaces |
26 |
26 |
27 # import Zope3 packages |
27 # import Zope3 packages |
28 from zc.set import Set |
28 from zc.set import Set |
29 from zope.component import getUtility |
29 from zope.component import getUtility |
|
30 from zope.deprecation.deprecation import deprecate |
30 from zope.interface import implements |
31 from zope.interface import implements |
31 from zope.security.proxy import removeSecurityProxy |
32 from zope.security.proxy import removeSecurityProxy |
32 |
33 |
33 # import local packages |
34 # import local packages |
34 |
35 |
50 else: |
51 else: |
51 result = removeSecurityProxy(value) |
52 result = removeSecurityProxy(value) |
52 return result |
53 return result |
53 |
54 |
54 |
55 |
|
56 @deprecate("ztfy.utils.security.MissingPrincipal is deprecated. Use ztfy.security.search.MissingPrincipal class instead.") |
55 class MissingPrincipal(object): |
57 class MissingPrincipal(object): |
56 |
58 |
57 implements(IPrincipalInfo) |
59 implements(IPrincipalInfo) |
58 |
60 |
59 def __init__(self, id): |
61 def __init__(self, id): |
66 @property |
68 @property |
67 def description(self): |
69 def description(self): |
68 return _("This principal can't be found in any authentication utility...") |
70 return _("This principal can't be found in any authentication utility...") |
69 |
71 |
70 |
72 |
|
73 @deprecate("ztfy.utils.security.getPrincipal is deprecated. Use ztfy.security.search.getPrincipal function instead.") |
71 def getPrincipal(uid): |
74 def getPrincipal(uid): |
72 principals = getUtility(IAuthentication) |
75 principals = getUtility(IAuthentication) |
73 try: |
76 try: |
74 return principals.getPrincipal(uid) |
77 return principals.getPrincipal(uid) |
75 except: |
78 except: |