To use the JMP connection with the JNIOR, you must have the proper privileges. You must either be
logged in to the correct account or authentication must be disabled. We HIGHLY
recommend using proper security best practices. Disabling authentication should only
be used for testing and not used in production.
Once the connection has been established the JMP connection will send a "empty" message.
It really does not matter what the "empty" message is. The message is sent to
solicit an Unauthorized Error message from the JNIOR. That Unauthorized Error
message contains a NONCE that will be used in conjuction with the username and
password to build a digest for logging in.
The logic in the JmpLib will attempt the provided username and password in the
Connection Properties. The default username and password are used unless
they are changed by the developer. This is how the username and password can be
defined before passing the Connection Properties to the
Create Connection function.
1234
// define the connection properties for the target jniorconstipg::connection_propertiesconnection_props={.ip_address="10.0.0.96",.port=9222,.username="username_here",.password="password_here"};
123456
// When defining the username and password for theconnection properties, // you'll use the .setCredentials function.varconnectionProperties=newConnectionProperties("10.0.0.96")SetCredentials("username_here","password_here");// If you don't use the setCredentials function call, the username and // password used by default is 'jnior', 'jnior'.
123456
// When defining the username and password for theconnection properties, // you'll use the .setCredentials function.ConnectionPropertiescp=newConnectionProperties("10.0.0.96");cp.setCredentials("username_here","password_here");// If you don't use the setCredentials function call, the username and // password used by default is 'jnior', 'jnior'.
123456
# When defining the username and password for theconnection properties, # you'll use the .set_credentials function.connection_properties=jmplib_py.ConnectionProperties("10.0.0.96").set_credentials("username_here","password_here")# If you don't use the set_credentials function call, the username and # password used by default is 'jnior', 'jnior'.
Here is an example of an initial authentication exchange at the beginning on a connection.
You can wait for the authentication to either login, or timeout. The waitForAuthentication function call will return the status of the
connection at the time of the return.
sequenceDiagram
autonumber
Application->>authentication_monitor_object: Wait for authentication
Note right of Application: Application thread blocks until the<br>authentication is made/fails or the timeout expires
loop
authentication_monitor_object->>authentication_monitor_object: 2 second timeout
end
JmpConnection-->>authentication_monitor_object: Authenticated / Authentication Failed
Note right of Application: returns the status of the authentication
authentication_monitor_object->>Application: <Authentication Status>
Note right of Application: Application continues...
123456789
// wait for the connection to either connect or fail. this call will// return the current status of the connectionintconnection_result=ipg::wait_for_connection(5);// we can use the result to get a textual description for the // connection statechar*status_description[32];ipg::get_connection_status_description(constchar*uuid,char*status_description);std::cout<<"The connection is "<<status_description<<std::endl;
123
// This will wait to proceed further in the code until it resolves // the status of the JMP Authentication._jmpConnection.WaitForAuthentication();
123
// This will wait to proceed further in the code until it resolves // the status of the JMP Authentication.jmpConnection.waitForAuthentication();
123
# This will wait to proceed further in the code until it resolves # the status of the JMP Authentication.jmp_connection.wait_for_authentication()
Alternatively, you can get a string description for state of the connection's authentication by using the Get Authentication Status Description function.
1
comingsoon...
123
// This will give us a STATUS Code that will represent the state of the // authentication._jmpConnection.GetAuthenticationStatusDescription()
123
// This will give us a STATUS Code that will represent the state of the // authentication.jmpConnection.getAuthenticationStatusDescription()
123
# This will give us a STATUS Code that will represent the state of the # authentication.jmp_connection.get_authentication_status_description()
Optionally, a callback can be assigned that will be alerted when ever there is a change to any of
the connection authentication. In order for the callback to be effective, it must be defined
before any connections are defined. To define the call back we can do the following...
123456789
// Define callback method. This function will get called when the status of // the connections authentication changesinton_auth_changed(constchar*sessionId,constchar*status_description){std::cout<<std::string(sessionId)+": "+status_description<<std::endl;return0;}// Add the callback to the libraryipg::add_on_auth_callback(connection_callback);
1 2 3 4 5 6 7 8 91011
// Defines the callback method that runs when the JMP connection's status // changesprivatestaticvoidAuthenticationStatusChange(stringuuid,intstatusCode,stringstatusDescription){Console.WriteLine($"{uuid}: Authentication status is ({statusCode}) {statusDescription}");}// Once the AuthenticationStatusChange function is defined, you can// now add the authentication listener to enable the callback.// This will check for changes to the JMP authentication, and run the // AuthenticationStatusChange function when they occur.JmpLib.add_authentication_callback(AuthenticationStatusChange);
1 2 3 4 5 6 7 8 9101112
// Defines the callback method that runs when the JMP connection's status // changes@OverridepublicvoidonAuthenticationStatusChange(jmpConnectionintstatusCode,StringstatusDescription){System.out.println("Authentication Status Code = "+statusCode+", Authentication Status Description = "+statusDescription);}// Once the OnAuthenticationStatusChange function is defined, you can// now add the authentication listener to enable the callback.// This will check for changes to the JMP authentication, and run the // onAuthenticationStatusChange function when they occur.JmpLib.addAuthenticationListener(this);
1 2 3 4 5 6 7 8 910
# Defines the callback method that runs when the JMP connection's status # changesdefon_authentication_status_change(jmp_connection,status_code:int,status_description:str):print(f"Authentication status code: {status_code}. Authentication status description: {status_description}")# Once the on_authentication_status_change function is defined, you can# now add the authentication listener to enable the callback.# This will check for changes to the JMP authentication, and run the # on_authentication_status_change function when they occur.jmplib_py.add_authentication_status_callback(on_authentication_status_change)