3 __author__
= "Florian Friesdorf <flo@chaoflow.net>"
4 __docformat__
= "plaintext"
6 from StringIO
import StringIO
8 from Products
.CMFCore
.utils
import getToolByName
9 from Products
.PluggableAuthService
.interfaces
.plugins \
10 import IAuthenticationPlugin
11 from Products
.PlonePAS
.Extensions
.Install
import activatePluginInterfaces
13 from zope
.app
.security
.interfaces
import IAuthentication
14 from zope
.component
import getUtility
16 from paula
.pasplugins
.plugins
.auth
import paula_auth_ifs
17 from paula
.pasplugins
.plugins
.groups
import paula_groups_ifs
18 from paula
.pasplugins
.plugins
.properties
import paula_properties_ifs
20 # only for testing purposes
21 #from paula.pasplugins.tests.fake_pau_ap import AUTHPLUG_NAME
23 def _setupPlugins(portal
, out
):
25 Install and prioritize the Paula PAS plug-ins.
27 uf
= getToolByName(portal
, 'acl_users')
29 paula
= uf
.manage_addProduct
['paula.pasplugins']
32 def _move_to_top(interface
, name
):
33 while not plugins
.listPlugins(
36 plugins
.movePluginsUp(interface
, [name
])
38 existing
= uf
.objectIds()
40 if 'paula_auth' not in existing
:
41 paula
.addAuthenticationPlugin('paula_auth')
42 print >> out
, "Added Paula PAS Authentication Plugin."
43 activatePluginInterfaces(portal
, 'paula_auth', out
)
44 for x
in paula_auth_ifs
:
45 _move_to_top(x
, 'paula_auth')
47 if 'paula_properties' not in existing
:
48 paula
.addPropertiesPlugin('paula_properties')
49 print >> out
, "Added Paula PAS Properties Plugin."
50 activatePluginInterfaces(portal
, 'paula_properties', out
)
51 for x
in paula_properties_ifs
:
52 _move_to_top(x
, 'paula_properties')
54 if 'paula_groups' not in existing
:
55 paula
.addGroupsPlugin('paula_groups')
56 print >> out
, "Added Paula PAS Groups Plugin."
57 activatePluginInterfaces(portal
, 'paula_groups', out
)
58 for x
in paula_groups_ifs
:
59 _move_to_top(x
, 'paula_groups')
61 credplugname
= 'Paula: PAU CredentialsFromMappingPlugin'
62 pau
= getUtility(IAuthentication
)
63 if credplugname
not in pau
.credentialsPlugins
:
64 pau
.credentialsPlugins
= tuple(
65 list(pau
.credentialsPlugins
) + [credplugname
]
67 # only for testing purposes
68 #pau.authenticatorPlugins = (AUTHPLUG_NAME,)
71 def setupPlugins(context
):
72 """initialize paula plugins
74 if context
.readDataFile('paula-pasplugins-setup-plugins.txt') is None:
77 portal
= context
.getSite()
79 _setupPlugins(portal
, out
)
80 logger
= context
.getLogger("plugins")
81 logger
.info(out
.getvalue())