Java client, Security control, Conventions and constraints – HP Intelligent Management Center Licenses User Manual

Page 29: Java client security control

Advertising
background image

1.

Event messages are separated with a blank line. Once the server reads a blank line, it decides
that it has read a complete event and should process the event. After complete processing the
event, the server continues to read subsequent events.

2.

The server sends a heartbeat message "#HEART_BEAT" every minute, which can be ignored
by the client

3.

The received events are represented in strings, which can be converted into class entities with
JAXB or other libraries as needed.

Java client

If you use Java to access iMC-RS real-time events, integrate file EventClient.java into your
source codes, and register or receive iMC-RS real-time event notifications with the following method:

EventClient client = new EventClient(
new URL("http://localhost:8080/imcrs/events?type=1"), SampleEntity.class) {
@Override
public void onMessage(SampleEntity entity) {
// Receive a real-time event. Process the event.
......
}
@Override
public void onError(Throwable t) {
// An error occurs (such as network connection interrupts) when the real-time event is received.
You can call client.start () again as needed.
......
}
};
// Start event registration and receipt.
if (client.start()) {
// Successfully connect to the server. Start to receive events.
......
// Stop receiving events from the server as needed.
client.stop();
}

Security control

The iMC-RS event notification framework maintains a long connection with the client for receiving
events in real time, and uses a security control mechanism different from iMC-RS security mechanism.

When the event notification framework registers or receives an event, it does not authenticate the
identity of the operator that uses the client. Instead, the framework implements iMC-RS event access
control based on the client addresses.

By default, iMC-RS only allows the server (127.0.0.1) to access iMC-RS events. To allow a client
to access iMC-RS events, open file web\apps\imcrs\WEB-INF\web.xml in the iMC installation
path, and locate the following contents:

<servlet>
<servlet-name>Events Registration</servlet-name>
<servlet-class>com.h3c.imc.rs.ext.event.EventRegistrationServlet</servlet-class>
<init-param>
<param-name>com.h3c.imc.rs.ext.event.config.PermittedRemoteAddrRegex</param-name>
<param-value>127.0.0.1</param-value>
</init-param>
</servlet>

Replace 127.0.0.1 with the client address expressed in a regular expression. For more information,
see Javadoc in java.util.regex.Pattern.

If the client address is not allowed to access iMC-RS events, the server returns the 403 (Forbidden)
status code.

Conventions and Constraints

This section describes the conventions and constraints in iMC-RS interfaces.

Conventions and Constraints

29

Advertising