1 # Copyright (c) 2008 by Florian Friesdorf
3 # GNU Affero General Public License (AGPL)
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as
7 # published by the Free Software Foundation; either version 3 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public
16 # License along with this program. If not, see
17 # <http://www.gnu.org/licenses/>.
20 __author__
= "Florian Friesdorf <flo@chaoflow.net>"
21 __docformat__
= "plaintext"
23 from StringIO
import StringIO
25 from Products
.CMFCore
.utils
import getToolByName
27 from Products
.PluggableAuthService
.interfaces
.plugins \
28 import IAuthenticationPlugin
30 from Products
.PlonePAS
.Extensions
.Install
import activatePluginInterfaces
32 from plone
.app
.content
.container
import Container
34 #from zope.component import getUtility
36 from zope
.app
.authentication
.interfaces
import IPluggableAuthentication
37 from paula
.authentication
.interfaces
import ILocalAuthenticatorPlugin
38 from paula
.authentication
.interfaces
import ICredentialsFromMappingPlugin
39 from paula
.authentication
.interfaces
import IAuthProviders
40 from paula
.groups
.interfaces
import IMemberships
41 from paula
.properties
.interfaces
import IPropertyProviders
43 from paula
import suite
46 def _setupPlugins(portal
, out
):
48 Install and prioritize the Paula PAS plug-ins.
50 uf
= getToolByName(portal
, 'acl_users')
52 paula
= uf
.manage_addProduct
['paula.plonepas']
53 existing
= uf
.objectIds()
55 if 'paula_auth' not in existing
:
56 paula
.addAuthenticationPlugin('paula_auth')
57 print >> out
, "Added Paula PAS Authentication Plugin."
58 activatePluginInterfaces(portal
, 'paula_auth', out
)
61 #plugins.movePluginsUp(IAuthenticationPlugin, ['paula'])
63 if 'paula_properties' not in existing
:
64 paula
.addPropertiesPlugin('paula_properties')
65 print >> out
, "Added Paula PAS Properties Plugin."
66 activatePluginInterfaces(portal
, 'paula_properties', out
)
68 if 'paula_groups' not in existing
:
69 paula
.addGroupsPlugin('paula_groups')
70 print >> out
, "Added Paula PAS Groups Plugin."
71 activatePluginInterfaces(portal
, 'paula_groups', out
)
74 def setupPlugins(context
):
75 """initialize paula plugins
77 if context
.readDataFile('paula-plonepas-setup-plugins.txt') is None:
80 portal
= context
.getSite()
82 _setupPlugins(portal
, out
)
83 logger
= context
.getLogger("plugins")
84 logger
.info(out
.getvalue())
87 def _createPaulaSuite(portal
, out
):
90 #suite.createPaulaSuite(portal, create_pau=True, create_credplugin=True,
91 # ContainerType=Container)
93 # (IPluggableAuthentication,
95 # (ILocalAuthenticatorPlugin,
96 # 'Paula PAU AuthenticatorPlugin'),
97 # (ICredentialsFromMappingPlugin,
98 # 'Paula PAU CredentialsFromMappingPlugin'),
101 # (IPropertyProviders,
105 # util = getUtility(x, name=name, context=portal)
106 # if not util.__parent__:
107 # util.__parent__ = portal
108 # pau = getUtility(IPluggableAuthentication, context=portal)
109 # # these three don't work ?! - hardcoded now in utils.py
110 # # probably something about persistency
111 # pau.authenticatorPlugins = ('Paula PAU AuthenticatorPlugin',)
112 # pau.credentialsPlugins = ('Paula PAU CredentialsFromMappingPlugin',)
114 print >> out
, "Added Paula Suite to Portal."
116 def createPaulaSuite(context
):
119 if context
.readDataFile('paula-plonepas-create-paula-suite.txt') is None:
122 portal
= context
.getSite()
124 _createPaulaSuite(portal
, out
)
125 logger
= context
.getLogger("plugins")
126 logger
.info(out
.getvalue())