weblogic wlst connect 加密连接

weblogic WLST 管理的连接方法一般使用明文密码, 如果需要隐藏, 可用如下方法

I will start out with a series of short posts about WLST. I have recently written a bunch of scripts and these tips would have saved me some time had a known them beforehand.

You can connect to a running Weblogic server like this:

1
2
3
. /app/oracle/domains/wlsTestDomain/bin/setDomainEnv.sh
java weblogic.WLST
connect(username='weblogic', password='mypw', url='t3://testwls01:7001')
But if you are writing a script you don’t really want to store a clear text password. Instead you can encrypt the user name and password:

1
2
3
4
5
6
. /app/oracle/domains/wlsTestDomain/bin/setDomainEnv.sh
java weblogic.WLST
connect(username='weblogic', password='mypw', url='t3://testwls01:7001')
storeUserConfig(userConfigFile='/app/oracle/scripts/userconfig.secure',
                userKeyFile='/app/oracle/scripts/userkey.secure',
                nm='false')
This will save a file that contains the encrypted user name and password. The other file contains the key that is used when decrypting.

Now you can connect to the server like this:

1
2
3
4
5
. /app/oracle/domains/wlsTestDomain/bin/setDomainEnv.sh
java weblogic.WLST
connect(userConfigFile='/app/oracle/scripts/userconfig.secure',
        userKeyFile='/app/oracle/scripts/userkey.secure',
        url='t3://testwls01:7001')
This is of cause not a perfect solution and you must ensure that that they key file is kept secure. But it is much better than clear text passwords.

It is also possible to use this when connecting to a Node Manager:

1
2
3
4
5
nmConnect(username='nodemgr', password='mypw',
          domainName='wlsTestDomain', port='5556', nmType='plain')
storeUserConfig(userConfigFile='/app/oracle/scripts/userconfigNM.secure',
                userKeyFile='/app/oracle/scripts/userkeyNM.secure',
                nm='true')
Now connect using the key file:

1
2
3
nmConnect(userConfigFile='/app/oracle/scripts/userconfigNM.secure',
          userKeyFile='/app/oracle/scripts/userkeyNM.secure',
          domainName='wlsTestDomain', port='5556', nmType='plain')
Please be aware that the code snippets in this post has been formatted for easy reading and cannot be executed directly without reformatting!


转发来自 http://theheat.dk/blog/?p=157

猜你喜欢

转载自thinkact.iteye.com/blog/2061843