我使用一些脚本来配置Keycloak。
到目前为止,我使用的是Keycloak 2.5.5.Final。我刚刚升级到Keycloak 4.5.0。最终,我遇到了问题。
我的脚本被这样称呼:
try this
import android.support.v7.view.menu.MenuBuilder;
@SuppressLint("RestrictedApi")
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (menu instanceof MenuBuilder) {
((MenuBuilder) menu).setOptionalIconsVisible(true);
}
getMenuInflater().inflate(R.menu.menu, menu);
return super.onCreateOptionsMenu(menu);
}
Keycloak-cli.bat是:
E:\...\scripts>keycloak-cli.bat --connect --controller=localhost:9990
-DdeployDir=E:\\...\\config\bin -DmysqlHost=localhost -DmysqlPort=3306
-DmysqlUser=KeycloakSQL -DmysqlPwd=somepwd -DadminPort=9991 -DhttpPort=8081
-DhttpsPort=8444 --file=E:\...\cli\keycloak_wildfly.cli
和keycloak_wildfly.cli是:
@echo off
REM set NOPAUSe to avoid to block the cmd when a wildfly cli script is executed
set NOPAUSE=true
REM set the java_home environment variable
set JAVA_HOME=E:\...\jdk
call "E:\...\keycloak\bin\jboss-cli.bat" %*
效果很好。
在4.5.0.Keycloak的最终版本中,运行脚本时出现以下错误:
#batch
#---------------------------------------------------------------------------
# Create db datasource
#---------------------------------------------------------------------------
if (outcome != success) of /subsystem=datasources/jdbc-driver=mariadb:read-resource
/subsystem=datasources/jdbc-driver=mariadb:add(driver-name=mariadb,driver-module-name=org.mariadb,driver-xa-datasource-class-name=org.mariadb.jdbc.Driver)
end-if
if (outcome != success) of /subsystem=security/security-domain=KeycloakDatabaseLogin/:read-resource
/subsystem=security/security-domain=KeycloakDatabaseLogin/:add(cache-type=default)
/subsystem=security/security-domain=KeycloakDatabaseLogin/authentication=classic:add(login-modules=[{"code"=>"SecureIdentity", "flag"=>"required", "module-options"=>[("username"=>"${mysqlUser}"),("password"=>"-123456789")]}])
end-if
# Modify the default datasource (if already exist) to use our mariaDB
if (outcome == success) of /subsystem=datasources/data-source=KeycloakDS:read-resource
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="jta",value="false")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="use-ccm",value="false")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="enabled",value="true")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="jndi-name",value="java:jboss/datasources/KeycloakDS")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="max-pool-size",value="10")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="min-pool-size",value="5")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="driver-name",value="mariadb")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="connection-url",value="jdbc:mysql://${mysqlHost}:${mysqlPort}/KeycloakDB")
/subsystem=datasources/data-source=KeycloakDS:undefine-attribute(name="password")
/subsystem=datasources/data-source=KeycloakDS:undefine-attribute(name="user-name")
/subsystem=datasources/data-source=KeycloakDS:write-attribute(name="security-domain",value="KeycloakDatabaseLogin")
end-if
# Else create a new datasource if not available
if (outcome != success) of /subsystem=datasources/data- source=KeycloakDS:read-resource
/subsystem=datasources/data-source="KeycloakDS":add(jta="false",use-ccm="false",enabled="true",jndi-name=java:jboss/datasources/KeycloakDS,max-pool-size=10,min-pool-size=5,driver-name=mariadb,connection-url=jdbc:mysql://${mysqlHost}:${mysqlPort}/KeycloakDB,security-domain="KeycloakDatabaseLogin")
end-if
#---------------------------------------------------------------------------
# Change IP settings
#---------------------------------------------------------------------------
#Public interface listen on all IPs
/interface=public:write-attribute(name="inet-address",value="${jboss.bind.address:0.0.0.0}")
# Change http and https ports
/socket-binding-group=standard-sockets/socket-binding="management- http":write-attribute(name="port",value="${adminPort}")
/socket-binding-group=standard-sockets/socket-binding="http":write-attribute(name="port",value="${httpPort}")
/socket-binding-group=standard-sockets/socket-binding="https":write-attribute(name="port",value="${httpsPort}")
它不会将$ {xxx}替换为在命令行中作为-D传递的值。
我不明白为什么。
谁能帮我吗?
谢谢
Seb