为了完成这个练习,我必须去修改和加密(给定用户输入)standalone.xml 的安全/密码部分中的密码。
我最初的方法是这样的,但我总是遇到诸如“重复资源”、“没有为地址注册资源定义”等错误。
@echo off
REM Read user input for new database password
set /p new_password="Enter new database password: "
REM Check if the alias exists
echo /subsystem=elytron/credential-store=mycredstore:read-resource(recursive=true) > update_password.cli
REM Remove the newDbPassword alias from the credential store
echo /subsystem=elytron/credential-store=mycredstore/alias=newDbPassword:remove >> update_password.cli
REM Encrypt new password and add to credential store
echo /subsystem=elytron/credential-store=mycredstore:add-alias(alias=newDbPassword, secret-value=%new_password%) >> update_password.cli
REM Update dbPassword alias to reference new password
echo /subsystem=elytron/credential-store=mycredstore/alias=dbPassword:remove >> update_password.cli
echo /subsystem=elytron/credential-store=mycredstore:add-alias(alias=dbPassword, credential-reference={store=mycredstore, alias=newDbPassword}) >> update_password.cli
REM Remove the newDbPassword alias from the credential store
echo /subsystem=elytron/credential-store=mycredstore/alias=newDbPassword:remove >> update_password.cli
C:\Wildfly\bin\jboss-cli.bat --connect --file=update_password.cli
REM Restart WildFly server
net stop WildFly
net start WildFly
我在 Wildfly 中不是那么敏锐,所以它变得非常难以完成。