0

I am using the below script to retrieve the datasource properties.

try:
    for server in AdminConfig.list('Server').splitlines():
        serverName = AdminConfig.showAttribute(server, 'name')
        serverType = AdminConfig.showAttribute(server, 'serverType')
        findIndex = serverName.find('myservers')
        if findIndex > 0 and serverType == 'APPLICATION_SERVER':
            dsList = AdminConfig.list('DataSource', server).splitlines()
            for ds in dsList:
                # Get the database details for this data source
                dbName = AdminConfig.showAttribute(ds, 'jndiName')
                try: propSet = AdminConfig.showAttribute(ds, 'propertySet')
                except:
                    print 'Error getting propertySet:'
                else:
                    propList = AdminConfig.list('J2EEResourceProperty', propSet).splitlines()
                    for prop in propList:
                        print  AdminConfig.showAttribute(prop, 'name') + '-' + AdminConfig.showAttribute(prop, 'value')
                # Get the jaas authentication details for this data source
                try: jaasAuthDataSet = AdminConfig.list("JAASAuthData", ds).splitlines()
                except:
                    print 'Error getting Jaas Authentication data'
                else:
                    for jaasAuthData in jaasAuthDataSet:
                        print AdminConfig.showAttribute(jaasAuthData, "alias")
except AdminException, ex:
    print 'Admin Config not available:' + ex
return None

However in the datasource property set i am not able to get the authdatalias property, which defines the component managed authdata alias.

Also i tried to get the JAASAuthData for the Datasource using the below, but without any results:

AdminConfig.list("JAASAuthData", ds).splitlines()

I am able to retrieve the list of all JAASAuthData using the below:

for jsData in AdminConfig.list("JAASAuthData").splitlines():
    print AdminConfig.showAttribute(jsData, "alias") + "-" + AdminConfig.showAttribute(jsData, "userId")

Any pointers on how this can be retrieved will be helpful. Thanks.

muasif80
  • 5,586
  • 4
  • 32
  • 45
Unni Kris
  • 3,081
  • 4
  • 35
  • 57

1 Answers1

1

I have a solution for your problem but this is a function that I created and it works for me. My script is searching in security.xml and decrypt passwords.

def search ( alias, file ):
    list = []
    list.append(alias)
    f=open(file)
    lines=f.readlines()
    for line in lines:
        poz = line.find('/'+alias)
        if poz > 0:
            Line = line
            break

    user = Line[Line.find('userId=')+8:Line.find('\" password')]
    list.append(user)
    password = Line[Line.find('password=')+15:Line.find('\" description')]

    password = decrypt(password)
    list.append(password)
    description = Line[Line.find('description=')+13:Line.find('\"/>')]
    list.append(description)
    authAliasList.append(list)

def decrypt ( word ):
    if not len(word) > 1: exit()
    word = word.replace(':', '')
    value1 = binascii.a2b_base64(word)
    value2 = '_' * len(value1)
    out = ''
    for a, b in zip(value1, value2):
        out = ''.join([out, chr(ord(a) ^ ord(b))])
    return out

#===============================================
#MAIN
#===============================================

#AuthAlias is the Authentication Alias from Websphere.
#secureFile is the path for you security.xml file
search ( AuthAlias, secureFile )

You will get the name of Authentication Alias with next functions:

dbConnList = AdminConfig.list('DataSource', scopeID).split(lineSeparator)
if (len(dbConnList) > 0) :
    for dbConn in dbConnList:
        AuthAlias= AdminConfig.showAttribute(dbConn, "authDataAlias")

The script creats a list of your AuthAlias properties.

authAliasList=[name of AuthAlias, user, password, description]

If you have any problems please let me know. I did some modifications in the code to use in your scope and I didn't have time to test it. So I am waiting for your questions.

adimoise91
  • 558
  • 1
  • 7
  • 26
  • Thanks.. but i think most of the code you posted here will not be required. Though you correctly pointed me on how to get the `authDataAlias` from the `datasource`. I was looking for the attribute on the `J2EEResourceProperty` level, instead it should have on the `datasource` attribute level itself. – Unni Kris Mar 13 '15 at 12:57