Back to index

plone3  3.1.7
Functions | Variables
PlonePAS.Extensions.Install Namespace Reference

Functions

def activatePluginInterfaces
def installProducts
def setupRoles
def registerPluginType
def registerPluginTypes
def setupPlugins
def setupAuthPlugins
def configurePlonePAS
def grabUserData
def restoreUserData
def grabGroupData
def restoreGroupData
def setupTools
def migratePloneTool
def migrateMembershipTool
def migrateGroupsTool
def migrateGroupDataTool
def migrateMemberDataTool
def modActions
def updateProperties
def updateProp
def grabLDAPFolders
def restoreLDAP
def replaceUserFolder
def addPAS
def goForMigration
def migrate_root_uf
def pas_fixup
def challenge_chooser_setup
def install

Variables

 CAN_LDAP = True

Function Documentation

def PlonePAS.Extensions.Install.activatePluginInterfaces (   portal,
  plugin,
  out,
  disable = [] 
)

Definition at line 60 of file Install.py.

00060 
00061 def activatePluginInterfaces(portal, plugin, out, disable=[]):
00062     pas = portal.acl_users
00063     plugin_obj = pas[plugin]
00064 
00065     activatable = []
00066 
00067     for info in plugin_obj.plugins.listPluginTypeInfo():
00068         interface = info['interface']
00069         interface_name = info['id']
00070         if plugin_obj.testImplements(interface):
00071             if interface_name in disable:
00072                 disable.append(interface_name)
00073                 print >> out, " - Disabling: " + info['title']
00074             else:
00075                 activatable.append(interface_name)
00076                 print >> out, " - Activating: " + info['title']
00077     plugin_obj.manage_activateInterfaces(activatable)
00078     print >> out, plugin + " activated."
00079 

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.addPAS (   portal,
  out 
)

Definition at line 731 of file Install.py.

00731 
00732 def addPAS(portal, out):
00733     print >> out, " - Adding PAS user folder"
00734     portal.manage_addProduct['PluggableAuthService'].addPluggableAuthService()
00735 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 818 of file Install.py.

00818 
00819 def challenge_chooser_setup(self, out):
00820     uf = getToolByName(self, 'acl_users')
00821     plugins = uf['plugins']
00822     pas = uf.manage_addProduct['PluggableAuthService']
00823 
00824     # Only install plugins if available
00825     req = ('addChallengeProtocolChooserPlugin',
00826            'addRequestTypeSnifferPlugin')
00827     for m in req:
00828         if getattr(pas, m, None) is None:
00829             print >> out, 'Needed plugins have not been found, ignoring'
00830             return
00831 
00832     found = uf.objectIds(['Challenge Protocol Chooser Plugin'])
00833     if not found:
00834         print >> out, 'Adding Challenge Protocol Chooser Plugin.'
00835         pas.addChallengeProtocolChooserPlugin(
00836             'chooser',
00837             mapping=config.DEFAULT_PROTO_MAPPING)
00838         activatePluginInterfaces(self, 'chooser', out)
00839     else:
00840         assert len(found) == 1, 'Found extra plugins %s' % found
00841         print >> out, 'Found existing Challenge Protocol Chooser Plugin.'
00842         plugin = uf[found[0]]
00843         plugin.manage_updateProtocolMapping(mapping=config.DEFAULT_PROTO_MAPPING)
00844         activatePluginInterfaces(self, found[0], out)
00845 
00846     found = uf.objectIds(['Request Type Sniffer Plugin'])
00847     if not found:
00848         print >> out, 'Adding Request Type Sniffer Plugin.'
00849         pas.addRequestTypeSnifferPlugin('sniffer')
00850         activatePluginInterfaces(self, 'sniffer', out)
00851     else:
00852         assert len(found) == 1, 'Found extra plugins %s' % found
00853         print >> out, 'Found existing Request Type Sniffer Plugin.'
00854         activatePluginInterfaces(self, found[0], out)
00855 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.configurePlonePAS (   portal,
  out 
)
Add the necessary objects to make a usable PAS instance

Definition at line 284 of file Install.py.

00284 
00285 def configurePlonePAS(portal, out):
00286     """Add the necessary objects to make a usable PAS instance
00287     """
00288     installProducts(portal, out)
00289     registerPluginTypes(portal.acl_users)
00290     setupPlugins(portal, out)
00291 #    setupRoles( portal )
00292 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.goForMigration (   portal,
  out 
)
Checks for supported configurations.
Other configurations might work. The migration code is pretty generic.

Should provide some way to extend this check.

Definition at line 736 of file Install.py.

00736 
00737 def goForMigration(portal, out):
00738     """Checks for supported configurations.
00739     Other configurations might work. The migration code is pretty generic.
00740 
00741     Should provide some way to extend this check.
00742     """
00743     if not canAutoMigrate(portal.acl_users):
00744         msg = ("Your user folder is in a configuration not supported "
00745                "by the migration script.\nOnly GroupUserFolders with "
00746                "basic UserFolder and LDAPUserFolder sources can be "
00747                "migrated at this time.\nAny other setup will require "
00748                "custom migration. You may install PlonePAS empty by "
00749                "deleting you current UserFolder.")
00750         raise Exception, msg
00751 
00752     return 1

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.grabGroupData (   portal,
  out 
)
Return a list of (id, roles, groups, properties) tuples for the
users of the system and a mapping of group ids to a list of group
members.

Definition at line 371 of file Install.py.

00371 
00372 def grabGroupData(portal, out):
00373     """Return a list of (id, roles, groups, properties) tuples for the
00374     users of the system and a mapping of group ids to a list of group
00375     members.
00376     """
00377     print >> out, "\nExtract Group information..."
00378 
00379     groupdata = ()
00380     groupmemberships = {}
00381     gdtool = getToolByName(portal, 'portal_groupdata', None)
00382     gtool = getToolByName(portal, 'portal_groups', None)
00383 
00384     if gdtool is None or gtool is None:
00385         print >> out, ('\nGroup-aware tools not found. Skipping '
00386                        'group data migration.')
00387         return groupdata, groupmemberships
00388 
00389     props = gdtool.propertyIds()
00390 
00391     uf = getToolByName(portal, 'acl_users')
00392     if hasattr(uf, 'getGroups'):
00393         # Must be a GRUF for this to work.
00394         groups = gtool.listGroups()
00395         for group in groups:
00396             id = group.getGroupName()  # in GRUF 2, getGroupId is prefixed!
00397             print >> out, " : %s" % id
00398             roles = [role for role in group.getRoles() if role != 'Authenticated']
00399             print >> out, "with roles %s" % roles
00400             properties = {}
00401             has_groups = [] # we take care of this with the
00402                             # groupmemberships stuff
00403             for propid in props:
00404                 properties[propid] = group.getProperty(propid, None)
00405             groupdata += ((id, roles, has_groups, properties),)
00406             groupmemberships[id] = group.getGroupMemberIds()
00407 
00408     print >> out, "...extract done"
00409     return groupdata, groupmemberships
00410 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.grabLDAPFolders (   portal,
  out 
)
Get hold of any existing LDAPUserFolders so that we can put
them into LDAPMultiPlugins later.

Definition at line 638 of file Install.py.

00638 
00639 def grabLDAPFolders(portal, out):
00640     """Get hold of any existing LDAPUserFolders so that we can put
00641     them into LDAPMultiPlugins later.
00642     """
00643     print >> out, "\nPreserving LDAP folders, if any:"
00644 
00645     user_sources = portal.acl_users.listUserSources()
00646     group_source = portal.acl_users.Groups.acl_users
00647 
00648     ldap_ufs = []
00649     ldap_gf = None
00650 
00651     for uf in user_sources:
00652         if uf.meta_type == "LDAPUserFolder":
00653             print >> out, " - LDAPUserFolder %s" % uf.title
00654             ldap_ufs.append(uf)
00655 
00656     if group_source.meta_type == "LDAPGroupFolder %s" % group_source.title:
00657         print >> out, " - LDAPGroupFolder"
00658         ldap_gf = group_source
00659 
00660     print >> out, "...done"
00661     return ldap_ufs, ldap_gf
00662 

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.grabUserData (   portal,
  out 
)
Return a list of (id, password, roles, domains, properties)
tuples for the users of the system.

Password may be encypted or not: addUser will figure it out.

Definition at line 293 of file Install.py.

00293 
00294 def grabUserData(portal, out):
00295     """Return a list of (id, password, roles, domains, properties)
00296     tuples for the users of the system.
00297 
00298     Password may be encypted or not: addUser will figure it out.
00299     """
00300     print >> out, "\nExtract Member information..."
00301 
00302     userdata = ()
00303     try:
00304         mdtool = getToolByName(portal, "portal_memberdata")
00305         mtool = getToolByName(portal, "portal_membership")
00306     except ComponentLookupError:
00307         return userdata
00308 
00309     props = mdtool.propertyIds()
00310     members = mtool.listMembers()
00311     userids=set()
00312     for member in members:
00313         id = member.getId()
00314         print >> out, " : %s" % id
00315         password = member.getPassword()
00316         roles = [role for role in member.getRoles() if role != 'Authenticated']
00317         print >> out, "with roles %s" % roles
00318         domains = member.getDomains()
00319         properties = {}
00320         for propid in props:
00321             properties[propid] = member.getProperty(propid, None)
00322         portrait=mtool.getPersonalPortrait(id)
00323         if portrait is not None:
00324             portrait=portrait.aq_base
00325         userdata += ((id, password, roles, domains, properties, portrait),)
00326         userids.add(id)
00327 
00328     for (id,data) in mdtool._members.items():
00329         if id not in userids:
00330             userdata+= ((id, None, None, None, data.__dict__, None),)
00331             userids.add(id)
00332 
00333     print >> out, "...extract done"
00334     return userdata
00335 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 856 of file Install.py.

00856 
00857 def install(self):
00858     out = StringIO()
00859     portal = getToolByName(self, 'portal_url').getPortalObject()
00860 
00861     uf = getToolByName(self, 'acl_users')
00862 
00863     EXISTING_UF = 'acl_users' in portal.objectIds()
00864     EXISTING_PAS = IPluggableAuthService.providedBy(uf)
00865 
00866     if EXISTING_PAS:
00867         # Fix possible missing PAS plugins registration.
00868         pas_fixup(self, out)
00869 
00870         # Register PAS Plugin Types
00871         registerPluginTypes(uf)
00872 
00873     ldap_ufs, ldap_gf = None, None
00874     userdata=groupdata=memberships=()
00875 
00876     if not EXISTING_UF:
00877         userdata = grabUserData(portal, out)
00878         addPAS(portal, out)
00879     elif not EXISTING_PAS:
00880         # We've got a existing user folder, but it's not a PAS
00881         # instance.
00882 
00883         goForMigration(portal, out)
00884 
00885         userdata = grabUserData(portal, out)
00886         groupdata, memberships = grabGroupData(portal, out)
00887 
00888         ldap_ufs, ldap_gf = grabLDAPFolders(portal, out)
00889         if (ldap_ufs or ldap_gf) and not CAN_LDAP:
00890             raise Exception, ("LDAPUserFolders present, but LDAPMultiPlugins "
00891                           "not present. To successfully auto-migrate, "
00892                           "the LDAPMultiPlugins product must be installed. "
00893                           "(%s, %s):%s" % (ldap_ufs, ldap_gf, CAN_LDAP))
00894 
00895         replaceUserFolder(portal, out)
00896 
00897     # Configure Challenge Chooser plugin if available
00898     challenge_chooser_setup(self, out)
00899 
00900     configurePlonePAS(portal, out)
00901 
00902     setupTools(portal, out)
00903 
00904     if (EXISTING_UF and CAN_LDAP
00905         and ldap_gf is not None
00906         and ldap_ufs is not None):
00907         restoreLDAP(portal, out, ldap_ufs, ldap_gf)
00908 
00909     if not EXISTING_PAS:
00910         restoreUserData(portal, out, userdata)
00911         restoreGroupData(portal, out, groupdata, memberships)
00912 
00913     # XXX Why do we need to do this?
00914     migrate_root_uf(self, out)
00915 
00916     print >> out, "\nSuccessfully installed %s." % config.PROJECTNAME
00917     return out.getvalue()
00918 
00919 
00920 # Future refactor notes:
00921 #  we cannot tell automatically between LDAP and AD uses of LDAPUserFolder
00922 #    - except maybe sAMAccountName
00923 #    - so some sort of UI is necessary
00924 #  should have some sort of facility for allowing easy extension of migration of UFs
00925 #    - register grab and restore methods, or something
00926 #  cannot currently handle LDAPGroupsFolder
00927 #  can probably handle multiple LDAPUserFolders, but not tested

Here is the call graph for this function:

def PlonePAS.Extensions.Install.installProducts (   portal,
  out 
)

Definition at line 80 of file Install.py.

00080 
00081 def installProducts(portal, out):
00082     print >> out, "\nInstalling other products"
00083     qi = getToolByName(portal, 'portal_quickinstaller')
00084 
00085     print >> out, " - PasswordResetTool"
00086     qi.installProduct('PasswordResetTool')
00087 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 753 of file Install.py.

00753 
00754 def migrate_root_uf(self, out):
00755     # Acquire parent user folder.
00756     parent = self.getPhysicalRoot()
00757     uf = getToolByName(parent, 'acl_users')
00758     if IPluggableAuthService.providedBy(uf):
00759         # It's a PAS already, fixup if needed.
00760         pas_fixup(parent, out)
00761 
00762         # Configure Challenge Chooser plugin if available
00763         challenge_chooser_setup(parent, out)
00764         return
00765 
00766     if not uf.meta_type == 'User Folder':
00767         # It's not a standard User Folder at the root. Nothing we can do.
00768         return
00769 
00770     # It's a standard User Folder, replace it.
00771     replace_acl_users(parent, out)
00772 
00773     # Get the new uf
00774     uf = getToolByName(parent, 'acl_users')
00775 
00776     pas = uf.manage_addProduct['PluggableAuthService']
00777     plone_pas = uf.manage_addProduct['PlonePAS']
00778     # Setup authentication plugins
00779     setupAuthPlugins(parent, pas, plone_pas, out,
00780                      deactivate_basic_reset=False,
00781                      deactivate_cookie_challenge=True)
00782 
00783     # Activate *all* interfaces for user manager. IUserAdder is not
00784     # activated for some reason by default.
00785     activatePluginInterfaces(parent, 'users', out)
00786 
00787     # Configure Challenge Chooser plugin if available
00788     challenge_chooser_setup(parent, out)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 529 of file Install.py.

00529 
00530 def migrateGroupDataTool(portal, out):
00531     # this could be somewhat combined with migrateMemberDataTool, but
00532     # I don't think it's worth it
00533 
00534     print >> out, "GroupData Tool (portal_groupdata)"
00535     # We only want the physical object in the portal, getToolByName could give
00536     # us a registered utility as well
00537     gt = getattr(portal, 'portal_groupdata', None)
00538 
00539     HAS_GT = gt is not None
00540 
00541     if HAS_GT:
00542         print >> out, " ...copying actions"
00543         actions = getattr(gt, '_actions', None)
00544 
00545         print >> out, " ...extracting data"
00546         properties = gt._properties
00547         for elt in properties:
00548             elt['value'] = gt.getProperty(elt['id'])
00549 
00550         print >> out, " - Removing Default"
00551         portal.manage_delObjects(['portal_groupdata'])
00552 
00553     print >> out, " - Installing PAS Aware"
00554     portal._setObject(GroupDataTool.id, GroupDataTool())
00555     gt = getToolByName(portal, 'portal_groupdata')
00556 
00557     if HAS_GT:
00558         if actions is not None:
00559             print >> out, " ...restoring actions"
00560             gt._actions = actions
00561 
00562         print >> out, " ...restoring data"
00563         
00564         updateProperties(gt, properties)
00565 
00566     print >> out, " ...done"
00567 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.migrateGroupsTool (   portal,
  out 
)

Definition at line 488 of file Install.py.

00488 
00489 def migrateGroupsTool(portal, out):
00490     print >> out, "Groups Tool (portal_groups)"
00491     # We only want the physical object in the portal, getToolByName could give
00492     # us a registered utility as well
00493     gt = getattr(portal, 'portal_groups', None)
00494 
00495     HAS_GT = gt is not None
00496 
00497     if HAS_GT:
00498         print >> out, " ...copying settings"
00499         groupworkspaces_id = gt.getGroupWorkspacesFolderId()
00500         groupworkspaces_title =  gt.getGroupWorkspacesFolderTitle()
00501         groupWorkspacesCreationFlag =  gt.getGroupWorkspacesCreationFlag()
00502         groupWorkspaceType =  gt.getGroupWorkspaceType()
00503         groupWorkspaceContainerType =  gt.getGroupWorkspaceContainerType()
00504 
00505         print >> out, " ...copying actions"
00506         actions = getattr(gt, '_actions', None)
00507 
00508         print >> out, " - Removing Default"
00509         portal.manage_delObjects(['portal_groups'])
00510 
00511     print >> out, " - Installing PAS Aware"
00512     portal._setObject(GroupsTool.id, GroupsTool())
00513 
00514     gt = getToolByName(portal, 'portal_groups')
00515 
00516     if HAS_GT:
00517         print >> out, " ...restoring settings"
00518         gt.setGroupWorkspacesFolder(groupworkspaces_id, groupworkspaces_title)
00519         gt.groupWorkspacesCreationFlag = groupWorkspacesCreationFlag
00520         gt.setGroupWorkspaceType(groupWorkspaceType)
00521         gt.setGroupWorkspaceContainerType(groupWorkspaceContainerType)
00522 
00523         if actions is not None:
00524             print >> out, " ...restoring actions"
00525             gt._actions = actions
00526 
00527     print >> out, " ...done"
00528 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 568 of file Install.py.

00568 
00569 def migrateMemberDataTool(portal, out):
00570     print >> out, "MemberData Tool (portal_memberdata)"
00571 
00572     print >> out, " ...copying actions"
00573     actions = getattr(portal.portal_memberdata, '_actions', None)
00574 
00575     print >> out, "  ...extracting data"
00576     mdtool = portal.portal_memberdata
00577     properties = mdtool._properties
00578     for elt in properties:
00579         elt['value'] = mdtool.getProperty(elt['id'])
00580 
00581     mdtool = None
00582     print >> out, " - Removing existing portal_memberdata tool"
00583     portal.manage_delObjects(['portal_memberdata'])
00584 
00585     print >> out, " - Installing PAS Aware tool"
00586     portal._setObject(MemberDataTool.id, MemberDataTool())
00587 
00588     if actions is not None:
00589         print >> out, " ...restoring actions"
00590         portal.portal_memberdata._actions = actions
00591 
00592     print >> out, " ...restoring data"
00593     mdtool = portal.portal_memberdata
00594     
00595     updateProperties(mdtool, properties)
00596 
00597     print >> out, " ...done"
00598 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 453 of file Install.py.

00453 
00454 def migrateMembershipTool(portal, out):
00455     print >> out, "Membership Tool (portal_membership)"
00456 
00457     mt = getToolByName(portal, "portal_membership")
00458     print >> out, " ...copying settings"
00459     memberareaCreationFlag = mt.getMemberareaCreationFlag()
00460     role_map = getattr(mt, 'role_map', None)
00461     membersfolder_id = mt.membersfolder_id
00462 
00463     print >> out, " ...copying actions"
00464     actions = getattr(mt, '_actions', None)
00465 
00466     print >> out, " - Removing Default"
00467     portal.manage_delObjects(['portal_membership'])
00468 
00469     print >> out, " - Installing PAS Aware"
00470     portal._setObject(MembershipTool.id, MembershipTool())
00471 
00472     # Get new tool.
00473     mt = getToolByName(portal, 'portal_membership')
00474 
00475     print >> out, " ...restoring settings"
00476     mt.memberareaCreationFlag = memberareaCreationFlag
00477     if role_map:
00478         mt.role_map = role_map
00479     if membersfolder_id:
00480         mt.membersfolder_id = membersfolder_id
00481 
00482     if actions is not None:
00483         print >> out, " ...restoring actions"
00484         mt._actions = actions
00485 
00486     print >> out, " ...done"
00487 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.migratePloneTool (   portal,
  out 
)

Definition at line 441 of file Install.py.

00441 
00442 def migratePloneTool(portal, out):
00443     print >> out, "Plone Tool (plone_utils)"
00444     pt = portal.plone_utils
00445     if pt.meta_type == 'PlonePAS Utilities Tool':
00446         from Products.CMFPlone.PloneTool import PloneTool
00447         print >> out, " - Removing obsolete PlonePAS version of the Plone Tool"
00448         portal.manage_delObjects(['plone_utils'])
00449         print >> out, " - Installing standard tool"
00450         portal._setObject(PloneTool.id, PloneTool())
00451     print >> out, " ...done"
00452 

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.modActions (   portal,
  out 
)
Change any actions necessary to support PAS.

Definition at line 599 of file Install.py.

00599 
00600 def modActions(portal, out):
00601     """Change any actions necessary to support PAS."""
00602     # condition "set password" on capability
00603     cp = getToolByName(portal, 'portal_controlpanel', None)
00604     _actions = cp._cloneActions()
00605     for action in _actions:
00606         if action.id=='MemberPassword':
00607             action.condition = Expression("python:member.canPasswordSet()")
00608     cp._actions=_actions
00609 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.pas_fixup (   self,
  out 
)

Definition at line 789 of file Install.py.

00789 
00790 def pas_fixup(self, out):
00791     from Products.PluggableAuthService.PluggableAuthService \
00792          import _PLUGIN_TYPE_INFO, PluggableAuthService
00793 
00794     pas = getToolByName(self, 'acl_users')
00795     if not IPluggableAuthService.providedBy(pas):
00796         print >> out, 'PAS UF not found, skipping PAS fixup'
00797         return
00798 
00799     plugins = pas['plugins']
00800 
00801     plugin_types = list(Set(plugins._plugin_types))
00802     for key, id, title, description in _PLUGIN_TYPE_INFO:
00803         if key in plugin_types:
00804             print >> out, "Plugin type '%s' already registered." % id
00805             continue
00806         print >> out, "Plugin type '%s' was not registered." % id
00807         plugin_types.append(key)
00808         plugins._plugin_type_info[key] = {
00809             'id': id,
00810             'title': title,
00811             'description': description,
00812             }
00813     # Make it ordered
00814     plugin_types.sort()
00815 
00816     # Re-assign because it's a non-persistent property.
00817     plugins._plugin_types = plugin_types

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.registerPluginType (   pas,
  plugin_type,
  plugin_info 
)

Definition at line 94 of file Install.py.

00094 
00095 def registerPluginType(pas, plugin_type, plugin_info):
00096     # Make sure there's no dupes in _plugin_types, otherwise your PAS
00097     # will *CRAWL*
00098     plugin_types = list(Set(pas.plugins._plugin_types))
00099     if not plugin_type in plugin_types:
00100         plugin_types.append(plugin_type)
00101 
00102     # Order doesn't seem to matter, but let's store it ordered.
00103     plugin_types.sort()
00104 
00105     # Re-assign to the object, because this is a non-persistent list.
00106     pas.plugins._plugin_types = plugin_types
00107 
00108     # It's safe to assign over a existing key here.
00109     pas.plugins._plugin_type_info[plugin_type] =  plugin_info
00110 

Here is the caller graph for this function:

Definition at line 111 of file Install.py.

00111 
00112 def registerPluginTypes(pas):
00113 
00114     PluginInfo = {
00115         'id' : 'IUserManagement',
00116         'title': 'user_management',
00117         'description': ("The User Management plugins allow the "
00118                         "Pluggable Auth Service to add/delete/modify users")
00119         }
00120 
00121     registerPluginType(pas, IUserManagement, PluginInfo)
00122 
00123     PluginInfo = {
00124         'id' : 'IUserIntrospection',
00125         'title': 'user_introspection',
00126         'description': ("The User Introspection plugins allow the "
00127                         "Pluggable Auth Service to provide lists of users")
00128         }
00129 
00130     registerPluginType(pas, IUserIntrospection, PluginInfo)
00131 
00132     PluginInfo = {
00133         'id' : 'IGroupManagement',
00134         'title': 'group_management',
00135         'description': ("Group Management provides add/write/deletion "
00136                         "of groups and member management")
00137         }
00138 
00139     registerPluginType(pas, igroup.IGroupManagement, PluginInfo)
00140 
00141     PluginInfo = {
00142         'id' : 'IGroupIntrospection',
00143         'title': 'group_introspection',
00144         'description': ("Group Introspection provides listings "
00145                         "of groups and membership")
00146         }
00147 
00148     registerPluginType(pas, igroup.IGroupIntrospection, PluginInfo)
00149 
00150     PluginInfo = {
00151         'id' : 'ILocalRolesPlugin',
00152         'title': 'local_roles',
00153         'description': "Defines Policy for getting Local Roles"
00154         }
00155 
00156     registerPluginType(pas, ILocalRolesPlugin, PluginInfo)
00157 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.replaceUserFolder (   portal,
  out 
)

Definition at line 720 of file Install.py.

00720 
00721 def replaceUserFolder(portal, out):
00722     print >> out, "\nUser folder replacement:"
00723 
00724     print >> out, " - Removing existing user folder"
00725     portal.manage_delObjects(['acl_users'])
00726 
00727     addPAS(portal, out)
00728 
00729     print >> out, "...replace done"
00730 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.restoreGroupData (   portal,
  out,
  groupdata,
  groupmemberships 
)

Definition at line 411 of file Install.py.

00411 
00412 def restoreGroupData(portal, out, groupdata, groupmemberships):
00413     print >> out, "\nRestoring Group information..."
00414 
00415     # re-add groups
00416     gtool = getToolByName(portal, 'portal_groups')
00417     for g in groupdata:
00418         print >> out, " : adding group '%s' with members: " % g[0]
00419         gtool.addGroup(*g)
00420 
00421         # restore group memberships
00422         gid = g[0]
00423         group = gtool.getGroupById(gid)
00424         for mid in groupmemberships[gid]:
00425             group.addMember(mid)
00426             print >> out, "%s " % mid
00427 
00428     print >> out, "...restore done"
00429 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.restoreLDAP (   portal,
  out,
  ldap_ufs,
  ldap_gf 
)
Create appropriate plugins to replace destroyed LDAP user
folders.

Definition at line 663 of file Install.py.

00663 
00664 def restoreLDAP(portal, out, ldap_ufs, ldap_gf):
00665     """Create appropriate plugins to replace destroyed LDAP user
00666     folders.
00667     """
00668     if not (ldap_ufs or ldap_gf):
00669         print >> out, "\nNo LDAP auth sources to restore. Skipping."
00670     else:
00671         print >> out, "\nRestoring LDAP auth sources:"
00672         pas = portal.acl_users
00673 
00674         x = ""
00675         if len(ldap_ufs) > 1:
00676             x = 0
00677         for lduf in ldap_ufs:
00678             id = 'ad_multi%s' % x
00679             title = 'ActiveDirectory Multi-plugin %s' % x
00680             LDAP_server = lduf.LDAP_server + ":" + `lduf.LDAP_port`
00681             login_attr = lduf._login_attr
00682             uid_attr = lduf._uid_attr
00683             users_base = lduf.users_base
00684             users_scope = lduf.users_scope
00685             roles = lduf._roles
00686             groups_base = lduf.groups_base
00687             groups_scope = lduf.groups_scope
00688             binduid = lduf._binduid
00689             bindpwd = lduf._bindpwd
00690             binduid_usage = lduf._binduid_usage
00691             rdn_attr = lduf._rdnattr
00692             local_groups = lduf._local_groups
00693             use_ssl = lduf._conn_proto == 'ldaps'
00694             encryption = lduf._pwd_encryption
00695             read_only = lduf.read_only
00696 
00697             # attribute over-rides
00698             uid_attr = login_attr = "sAMAccountName"
00699 
00700             ldapmp = pas.manage_addProduct['LDAPMultiPlugins']
00701             ldapmp.manage_addActiveDirectoryMultiPlugin(
00702                 id, title,
00703                 LDAP_server, login_attr,
00704                 uid_attr, users_base, users_scope, roles,
00705                 groups_base, groups_scope, binduid, bindpwd,
00706                 binduid_usage=1, rdn_attr='cn', local_groups=0,
00707                 use_ssl=0 , encryption='SHA', read_only=0)
00708             getattr(pas,id).groupid_attr = 'cn'
00709 
00710             print >> out, "Added ActiveDirectoryMultiPlugin %s" % x
00711             x = x or 0 + 1
00712 
00713             activatePluginInterfaces(portal, id, out)
00714             # turn off groups
00715             pas.plugins.deactivatePlugin(IGroupsPlugin, id)
00716             pas.plugins.deactivatePlugin(IGroupEnumerationPlugin, id)
00717             # move properties up
00718             pas.plugins.movePluginsUp(IPropertiesPlugin, [id])
00719 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.restoreUserData (   portal,
  out,
  userdata 
)

Definition at line 336 of file Install.py.

00336 
00337 def restoreUserData(portal, out, userdata):
00338     print >> out, "\nRestoring Member information..."
00339 
00340     # re-add users
00341     # Password may be encypted or not: addUser will figure it out.
00342     mdtool = getToolByName(portal, "portal_memberdata")
00343     mtool = getToolByName(portal, "portal_membership")
00344     emerg = portal.acl_users._emergency_user.getId()
00345     for u in userdata:
00346         if u[0] == emerg:
00347             print >> out, (" : WARNING! member '%s' has name of "
00348                            "emergency user. Not migrated." % u[0])
00349             print >> out, ("You can undo the install if you want "
00350                            "to fix this condition.")
00351             continue  # skip Emergency User, if present
00352 
00353         # be careful of non-ZODB member sources, like LDAP
00354         member = mtool.getMemberById(u[0])
00355         if member is None:
00356             if u[1] is not None:
00357                 mtool.addMember(*u[:5])
00358                 print >> out, " : adding member '%s'" % u[0]
00359             else:
00360                 print >> out, " : ignored member '%s' without password." % u[0]
00361         else:
00362             # set any properties. do we need anything else? roles, maybe?
00363             member.setMemberProperties(u[4])
00364             print >> out, " : setting props on member '%s'" % member.getId()
00365 
00366         if u[5] is not None:
00367             mdtool._setPortrait(u[5], u[0])
00368 
00369     print >> out, "...restore done"
00370 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.setupAuthPlugins (   portal,
  pas,
  plone_pas,
  out,
  deactivate_basic_reset = True,
  deactivate_cookie_challenge = False 
)

Definition at line 219 of file Install.py.

00219 
00220                      deactivate_cookie_challenge=False):
00221     uf = portal.acl_users
00222     print >> out, " cookie plugin setup"
00223 
00224     login_path = 'login_form'
00225     logout_path = 'logged_out'
00226     cookie_name = '__ac'
00227 
00228     crumbler = getToolByName(portal, 'cookie_authentication', None)
00229     if crumbler is not None:
00230         login_path = crumbler.auto_login_page
00231         logout_path = crumbler.logout_page
00232         cookie_name = crumbler.auth_cookie
00233 
00234     # note: old versions of PlonePAS (< 0.4.2) may leave a 'Cookie
00235     #       Auth Helper' by the same name
00236     found = uf.objectIds(['Cookie Auth Helper'])
00237     if found and 'credentials_cookie_auth' in found:
00238         print >> out, " old credentials_cookie_auth found; removing"
00239         login_path = uf.credentials_cookie_auth.login_path
00240         cookie_name = uf.credentials_cookie_auth.cookie_name
00241         uf.manage_delObjects(['credentials_cookie_auth'])
00242 
00243     found = uf.objectIds(['Extended Cookie Auth Helper'])
00244     if not found:
00245         plone_pas.manage_addExtendedCookieAuthHelper('credentials_cookie_auth',
00246                                                      cookie_name=cookie_name)
00247     print >> out, "Added Extended Cookie Auth Helper."
00248     if deactivate_basic_reset:
00249         disable=['ICredentialsResetPlugin', 'ICredentialsUpdatePlugin']
00250     else:
00251         disable=[]
00252     activatePluginInterfaces(portal, 'credentials_cookie_auth', out,
00253             disable=disable)
00254 
00255     credentials_cookie_auth = uf._getOb('credentials_cookie_auth')
00256     if 'login_form' in credentials_cookie_auth.objectIds():
00257         credentials_cookie_auth.manage_delObjects(ids=['login_form'])
00258         print >> out, "Removed default login_form from credentials cookie auth."
00259     credentials_cookie_auth.cookie_name = cookie_name
00260     credentials_cookie_auth.login_path = login_path
00261 
00262     # remove cookie crumbler(s)
00263     if 'cookie_authentication' in portal.objectIds():
00264         portal.manage_delObjects(['cookie_authentication'])
00265 
00266     ccs = portal.objectValues('Cookie Crumbler')
00267     assert not ccs, "Extra cookie crumblers found."
00268     print >> out, "Removed old Cookie Crumbler"
00269 
00270     found = uf.objectIds(['HTTP Basic Auth Helper'])
00271     if not found:
00272         pas.addHTTPBasicAuthHelper('credentials_basic_auth',
00273                                title="HTTP Basic Auth")
00274     print >> out, "Added Basic Auth Helper."
00275     activatePluginInterfaces(portal, 'credentials_basic_auth', out)
00276 
00277     if deactivate_basic_reset:
00278         uf.plugins.deactivatePlugin(ICredentialsResetPlugin,
00279                                      'credentials_basic_auth')
00280     if deactivate_cookie_challenge:
00281         uf.plugins.deactivatePlugin(IChallengePlugin,
00282                                      'credentials_cookie_auth')
00283 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.setupPlugins (   portal,
  out 
)

Definition at line 158 of file Install.py.

00158 
00159 def setupPlugins(portal, out):
00160     uf = portal.acl_users
00161     print >> out, "\nPlugin setup"
00162 
00163     pas = uf.manage_addProduct['PluggableAuthService']
00164     plone_pas = uf.manage_addProduct['PlonePAS']
00165 
00166     setupAuthPlugins(portal, pas, plone_pas, out)
00167 
00168     found = uf.objectIds(['User Manager'])
00169     if not found:
00170         plone_pas.manage_addUserManager('source_users')
00171         print >> out, "Added User Manager."
00172     activatePluginInterfaces(portal, 'source_users', out)
00173 
00174     found = uf.objectIds(['Group Aware Role Manager'])
00175     if not found:
00176         plone_pas.manage_addGroupAwareRoleManager('portal_role_manager')
00177         print >> out, "Added Group Aware Role Manager."
00178         activatePluginInterfaces(portal, 'portal_role_manager', out)
00179 
00180     found = uf.objectIds(['Local Roles Manager'])
00181     if not found:
00182         plone_pas.manage_addLocalRolesManager('local_roles')
00183         print >> out, "Added Group Aware Role Manager."
00184         activatePluginInterfaces(portal, 'local_roles', out)
00185 
00186     found = uf.objectIds(['Group Manager'])
00187     if not found:
00188         plone_pas.manage_addGroupManager('source_groups')
00189         print >> out, "Added ZODB Group Manager."
00190         activatePluginInterfaces(portal, 'source_groups', out)
00191 
00192     found = uf.objectIds(['Plone User Factory'])
00193     if not found:
00194         plone_pas.manage_addPloneUserFactory('user_factory')
00195         print >> out, "Added Plone User Factory."
00196         activatePluginInterfaces(portal, "user_factory", out)
00197 
00198     found = uf.objectIds(['ZODB Mutable Property Provider'])
00199     if not found:
00200         plone_pas.manage_addZODBMutablePropertyProvider('mutable_properties')
00201         print >> out, "Added Mutable Property Manager."
00202         activatePluginInterfaces(portal, "mutable_properties", out)
00203 
00204     found = uf.objectIds(['Automatic Group Plugin'])
00205     if not found:
00206         plone_pas.manage_addAutoGroup('auto_group', "Automatic Group Provider",
00207                 "AuthenticatedUsers", "Authenticated Users (Virtual Group)")
00208         print >> out, "Added Automatic Group."
00209         activatePluginInterfaces(portal, "auto_group", out)
00210 
00211     found = uf.objectIds(['Plone Session Plugin'])
00212     if not found:
00213         manage_addSessionPlugin(plone_pas, 'session')
00214         print >> out, "Added Plone Session Plugin."
00215         activatePluginInterfaces(portal, "session", out)
00216 

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 88 of file Install.py.

00088 
00089 def setupRoles(portal):
00090     rmanager = portal.acl_users.role_manager
00091     rmanager.addRole('Member', title="Portal Member")
00092     rmanager.addRole('Reviewer', title="Content Reviewer")
00093 

def PlonePAS.Extensions.Install.setupTools (   portal,
  out 
)

Definition at line 430 of file Install.py.

00430 
00431 def setupTools(portal, out):
00432     print >> out, "\nTools:"
00433 
00434     migratePloneTool(portal, out)
00435     migrateMembershipTool(portal, out)
00436     migrateGroupsTool(portal, out)
00437     migrateMemberDataTool(portal, out)
00438     migrateGroupDataTool(portal, out)
00439     modActions(portal, out)
00440 

Here is the call graph for this function:

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.updateProp (   prop_manager,
  prop_dict 
)
Provided a PropertyManager and a property dict of {id, value,
type}, set or update that property as applicable.

Doesn't deal with existing properties changing type.

Definition at line 619 of file Install.py.

00619 
00620 def updateProp(prop_manager, prop_dict):
00621     """Provided a PropertyManager and a property dict of {id, value,
00622     type}, set or update that property as applicable.
00623 
00624     Doesn't deal with existing properties changing type.
00625     """
00626     id = prop_dict['id']
00627     value = prop_dict['value']
00628     type = prop_dict['type']
00629     if type in ('selection', 'multiple selection'):
00630         value = prop_dict['select_variable']
00631     if prop_manager.hasProperty(id):
00632         prop_manager._updateProperty(id, value)
00633     else:
00634         prop_manager._setProperty(id, value, type)
00635     if type in ('selection', 'multiple selection'):
00636         prop_manager._updateProperty(id, prop_dict['value'])
00637 

Here is the caller graph for this function:

def PlonePAS.Extensions.Install.updateProperties (   tool,
  properties 
)

Definition at line 610 of file Install.py.

00610 
00611 def updateProperties(tool, properties):
00612     propsWithNoDeps = [prop for prop in properties if prop['type'] not in ('selection', 'multiple selection')]
00613     propsWithDeps = [prop for prop in properties if prop['type'] in ('selection', 'multiple selection')]
00614     for prop in propsWithNoDeps:
00615         updateProp(tool, prop)
00616     for prop in propsWithDeps:
00617         updateProp(tool, prop)
00618 

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 55 of file Install.py.