通过修改jdbc配置文件方式修改Weblogic数据源密码(3)

Both patches are released for generic platforms. If you are having a hard time identifying these patches in the new My Oracle Support site, please check out this post for instructions on how to find “old style” Weblogic patches in My Oracle Support.

Then, there are a few workarounds that you can quickly apply based on your needs:

1. The quickest solution is to switch your domain to Development mode. This will allow you to start the administration server, but take into consideration the implications that this change has on the runtime of the server, such as different logging levels and runtime performance.

2. Another way you can solve this issue is to simply copy the value of the empty tag from another instance in your domain. Locate another instance in the config.xml for which you have the <password-encrypted> tag correctly defined and copy it to the empty tag.

<password-encrypted>{AES}ve8cqLahYHyy8prbAudZTIyRvk4rNG+7kKvANZdaJzU=</password-encrypted>

3. If you simply do not have the encrypted password, you can encrypt it yourself using a utility provided by Weblogic:

– Run $DOMAIN_HOME/bin/setDomainEnv.sh so set the environment variables for your domain

– Execute: ‘java weblogic.security.Encrypt’

– Enter the password in clear text and the encrypted value will be returned in the output. Copy that in the empty tag in the config.xml and restart the administration server.

因为我所使用的weblogic版本是10.3.6.0,所以不是缺陷的问题。这里给出了三种建议,第一种是切换domain到开发模式,显然不合适;第二种是从其他实例拷贝密码标签的值,因为数据库中每个用户的密码都是不一样的,显然不适用;第三种是使用weblogic提供的工具将明文转化成为密文,然后进行替换,这是一种可行的方案。

(3)按照上述第三种方法执行【再次遇到错误】

[cams@mymc1 bin]$ cd /home/cams/bea/middleware/user_projects/domains/cams/bin

[cams@mysc1 bin]$ setDomainEnv.sh

[cams@mymc1 bin]$ java weblogic.security.Encrypt

Exception in thread "main" java.lang.NoClassDefFoundError: weblogic/security/Encrypt

Caused by: java.lang.ClassNotFoundException: weblogic.security.Encrypt

    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)

    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

Could not find the main class: weblogic.security.Encrypt. Program will exit.


(4)接着查找该问题的处理方案【成功执行并生成了新的密文】

encrypting password in weblogic (get java.lang.ClassNotFoundException:)

if you need to encrypt password and get java.lang.ClassNotFoundException: weblogic.security.Encrypt then use this way /app/bea/WLS1031/jdk/bin/java -cp /app/bea/WLS1031/wlserver_10.3/server/lib/weblogic.jar:$java weblogic.security.Encrypt yourpassword

PS: i have called java cause it was not in my env.

if you already have java in your env then /opt/bea/WLS1031/wlserver_10.3/server/lib/weblogic.jar:$java weblogic.security.Encrypt yourpassword

参考上文,执行命令如下:【注:标黄的password处输入真实的明文密码,可自动输出为密文】

[cams@mymc1 ~]$ cp /home/cams/bea/middleware/wlserver_10.3/server/lib/weblogic.jar /home/cams/bea/middleware/user_projects/domains/cams/

[cams@mymc1 ~]$ cd /home/cams/bea/middleware/user_projects/domains/cams/

[cams@mymc1 cams]$ java -cp weblogic.jar weblogic.security.Encrypt password

这里得到数据源CAMSDB的密码的密文为:【注:相同的明文在不同的weblogic下生成的密文不同】

{AES}dUH3nDtUg3LfPBCngOAAPFgsIW4gVRPyD25aibk4zVQ=

这里测试在另外一个weblogic下生成的密文为:

{AES}GA2sa2jSBeEtCoyt2g6NxJS3JPIWth70Z7s6dmIJ1uM=


显然两个相同密码在不同weblogic下生成的密文大不相同。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/50ca57218c36e42176e443ff25dfb78a.html