WildFly CLI Implementation Details: Difference between revisions
(Created page with "=Internal= * WildFly CLI") |
|||
(19 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
* [[WildFly CLI#Subjects|WildFly CLI]] | * [[WildFly CLI#Subjects|WildFly CLI]] | ||
* [[WildFly CLI Programmatic Access]] | |||
* [[novaordis-jboss|novaordis-jboss Project]] | |||
=Client Connection= | |||
<tt>org.jboss.as.cli.CommandLineMain.main(…)</tt> is executed first. This invokes <tt>org.jboss.as.cli.impl. CliLauncher.main(…)</tt>. | |||
This one creates a command context and initializes it as follows: | |||
<pre> | |||
CommandContext cmdCtx = | |||
CommandContextFactory.getInstance().newCommandContext(defaultHost, | |||
defaultPort, | |||
username, | |||
password, | |||
disableLocalAuth, | |||
initConsole, | |||
connect, | |||
connectionTimeout); | |||
</pre> | |||
Connection to the CLI server is implemented by invoking: | |||
<pre> | |||
cmdCtx.connectController(); | |||
</pre> | |||
<tt>CommandContextImpl.connectController()</tt> creates the client, which is a <tt>ModelControllerClient</tt> instance, authenticates and installs the client. | |||
The command line loop is implemented in <tt>cmdCtx.interact()</tt>, see [[#Command_Line_Loop|Command Line Loop]] below. | |||
=Authentication= | |||
The CLI client loads implementations of the interface <tt>javax.security.sasl.SaslClientFactory</tt>: | |||
<pre> | |||
package org.xnio.sasl; | |||
public final class SaslUtils { | |||
... | |||
private static <T> Iterator<T> getFactories(Class<T> type, ClassLoader classLoader, boolean includeGlobal) { | |||
Set<T> factories = new LinkedHashSet<T>(); | |||
final ServiceLoader<T> loader = ServiceLoader.load(type, classLoader); | |||
for (T factory : loader) { | |||
factories.add(factory); | |||
} | |||
... | |||
} | |||
</pre> | |||
Local user authentication will be available to CLI is <tt>org.jboss.sasl.localuser.LocalUserClientFactory</tt> is present in the class path. | |||
This materializes if <tt>${JBOSS_HOME}/bin/client/jboss-cli-client.jar</tt> is in the class path. | |||
=Command Line Loop= | |||
<pre> | |||
org.jboss.as.cli.impl.CommandContextImpl.interact() | |||
</pre> | |||
Interactions with the model controller consists in sending ModelNode instances. For example, a ModelNode associated with <tt>:read-attribute(name=release-version)</tt> is: | |||
{ | |||
"address" => [], | |||
"operation" => "read-attribute", | |||
"name" => "release-version" | |||
} | |||
The CommandContextImpl instance has just one “operation request”, which is a ModelNode instance. As part of the sequence of being sent to the server, the ModelInstance is installed in the CommandContextImpl instance map, under the “OP_REQ” key. | |||
Then, the operationHandler.handle() is invoked on the CommandContextImpl instance (CommandContextImpl.java line 638). | |||
OperationRequestHandler instance handle(): | |||
• gets the ModelControllerClient instance from the context | |||
• validates the request | |||
• “executes” the request by invoking client.execute(request) | |||
If the result is a success, it is simply displayed. |
Latest revision as of 04:28, 22 June 2017
Internal
Client Connection
org.jboss.as.cli.CommandLineMain.main(…) is executed first. This invokes org.jboss.as.cli.impl. CliLauncher.main(…).
This one creates a command context and initializes it as follows:
CommandContext cmdCtx = CommandContextFactory.getInstance().newCommandContext(defaultHost, defaultPort, username, password, disableLocalAuth, initConsole, connect, connectionTimeout);
Connection to the CLI server is implemented by invoking:
cmdCtx.connectController();
CommandContextImpl.connectController() creates the client, which is a ModelControllerClient instance, authenticates and installs the client.
The command line loop is implemented in cmdCtx.interact(), see Command Line Loop below.
Authentication
The CLI client loads implementations of the interface javax.security.sasl.SaslClientFactory:
package org.xnio.sasl; public final class SaslUtils { ... private static <T> Iterator<T> getFactories(Class<T> type, ClassLoader classLoader, boolean includeGlobal) { Set<T> factories = new LinkedHashSet<T>(); final ServiceLoader<T> loader = ServiceLoader.load(type, classLoader); for (T factory : loader) { factories.add(factory); } ... }
Local user authentication will be available to CLI is org.jboss.sasl.localuser.LocalUserClientFactory is present in the class path.
This materializes if ${JBOSS_HOME}/bin/client/jboss-cli-client.jar is in the class path.
Command Line Loop
org.jboss.as.cli.impl.CommandContextImpl.interact()
Interactions with the model controller consists in sending ModelNode instances. For example, a ModelNode associated with :read-attribute(name=release-version) is:
{
"address" => [], "operation" => "read-attribute", "name" => "release-version"
}
The CommandContextImpl instance has just one “operation request”, which is a ModelNode instance. As part of the sequence of being sent to the server, the ModelInstance is installed in the CommandContextImpl instance map, under the “OP_REQ” key.
Then, the operationHandler.handle() is invoked on the CommandContextImpl instance (CommandContextImpl.java line 638).
OperationRequestHandler instance handle(): • gets the ModelControllerClient instance from the context • validates the request • “executes” the request by invoking client.execute(request)
If the result is a success, it is simply displayed.