4.2.3. 默认配置方法
默认配置方法完全依赖于 Elytron Client 提供的配置:
//create your runnable for establishing a connection
Runnable runnable =
new Runnable() {
public void run() {
try {
//Establish your connection and do some work
} catch (Exception e) {
e.printStackTrace();
}
}
};
// run runnable directly
runnable.run();
为提供默认配置,Elytron 客户端会尝试自动发现文件系统上的 wildfly-config.xml 文件。它位于以下位置:
-
由
wildfly.config.url系统属性在客户端代码之外设置的位置。 - classpath 根目录。
-
类路径上的
META-INF目录。 - 当前用户的主目录。
- 当前工作目录。
您可以使用以下示例作为客户端 wildfly-config.xml 文件的基本配置。
Basic wildfly-config.xml
<configuration>
<authentication-client xmlns="urn:elytron:client:1.2">
<authentication-rules>
<rule use-configuration="default" />
</authentication-rules>
<authentication-configurations>
<configuration name="default">
<sasl-mechanism-selector selector="#ALL" />
<set-mechanism-properties>
<property key="wildfly.sasl.local-user.quiet-auth" value="true" />
</set-mechanism-properties>
<providers>
<use-service-loader/>
</providers>
</configuration>
</authentication-configurations>
</authentication-client>
</configuration>
注意
ANONYMOUS 机制不支持 非匿名用户 的授权。这意味着 set-authorization-name 不可用于 Elytron 客户端配置文件中的 set-anonymous。相反,如果您配置 set-authorization-name,还必须为授权身份指定 set-user-name。