0 Replies Latest reply: Aug 7, 2013 7:06 AM by nielsvanderbeke RSS

    reorder weblogic authentication providers

    nielsvanderbeke

      I have a properties file containing a list of weblogic authentication providers in a certain order.

       

      example properties file :

       

          ### realm components ###

          AuthenticationProvider=DefaultAuthenticator,DefaultIdentityAsserter,IPlanetAuthenticator,WaliSAMLAuthenticator,UmoeAuthenticator,MooseAuthenticator

       

      and a wlst jython script who uses this properties file as an argument to create and reorders the authentication providers in the security realm.

       

      wlst code to create AuthenticationProviders :

       

           ########################################################################################

           #                                      realm config                                    #

           ########################################################################################

          

           for a in AuthenticationProvider:

               print 'Config AuthenticationProvider ' + a

               if a == "IDMx509IdentityAsserter":

                   print 'Creating AuthenticationProvider IDMx509IdentityAsserter'

                   createIDMx509IdentityAsserter()

               elif a == "SAMLIdentityAsserterV2":

                   print 'Creating AuthenticationProvider SAMLIdentityAsserterV2'

                   createSAMLIdentityAsserterV2()

               elif a == "IDMSamlAuthenticationProvider":

                   print 'Creating AuthenticationProvider IDMSamlAuthenticationProvider'

                   createIDMSamlAuthenticationProvider()

               elif a == "WaliSAMLAuthenticator":

                   print 'Creating AuthenticationProvider WaliSAMLAuthenticator'

                   createWaliSAMLAuthenticator()

               elif a == "UAMPepRoleMapper":

                   print 'Creating AuthenticationProvider UAMPepRoleMapper'

                   providerUrl = prop.get(a + '.ProviderUrl')

                   createUAMPepRoleMapper(providerUrl)

               else:

                   print '!Problem creating AuthenticationProvider , don\'t know how to create ' + a

          setOrderAuthenticationProvider(AuthenticationProvider,domainName)

       

      the methode to set the order:

       

          def setOrderAuthenticationProvider(listAuthenticationProvider,domainname):

              try:     

                  cd('/SecurityConfiguration/' + domainname + '/DefaultRealm/myrealm/')

                  arrayAuthenticationProviders = get('AuthenticationProviders')

                  lengt = len(arrayAuthenticationProviders)+1

                  for x in xrange(1,lengt):

                      arrayAuthenticationProviders.pop(len(arrayAuthenticationProviders)-1)

              except:

                 print '!Problem while trying to cleanup arrayAuthenticationProviders'

              try:

                  for a in listAuthenticationProvider:

                      print 'add ' + a + ' to authenticatorArray'

                      cd('/SecurityConfiguration/' + domainname + '/DefaultRealm/myrealm/AuthenticationProviders/' + a )

                      currentAuthenticator = cmo

                      arrayAuthenticationProviders.append(currentAuthenticator)

              except:

                  print '!Problem while trying to construct list of autehticators'

                  dumpStackRollback()

              try:

                  cd('/SecurityConfiguration/' + domainname + '/Realms/myrealm')

                  set('AuthenticationProviders',arrayAuthenticationProviders)

              except:

                  print '!Problem while setting order AuthenticatoionProviders'

                  dumpStackRollback()

       

      The problem is when I call the methode i get an exception saying arrayAuthenticatorionProvider has not the correct type.

       

      a correct example to set the order correct is this:

       

          set('AuthenticationProviders',jarray.array([ObjectName('Security:Name=myrealmDefaultIdentityAsserter'), ObjectName('Security:Name=myrealmDefaultAuthenticator'), ObjectName('Security:Name=myrealmMooseAuthenticator'), ObjectName('Security:Name=myrealmIDMx509IdentityAsserter'), ObjectName('Security:Name=myrealmSAMLIdentityAsserterV2'), ObjectName('Security:Name=myrealmIDMSamlAuthenticationProvider'), ObjectName('Security:Name=myrealmWaliSAMLAuthenticator'), ObjectName('Security:Name=myrealmUmoeAuthenticator'), ObjectName('Security:Name=myrealmIPlanetAuthenticator')], ObjectName))

       

      Can somme one tell me how i can adopt my code to create a correct jarray with ObjectName type objects.