public class ConnectionManager
extends java.lang.Object
Connection
sConstructor and Description |
---|
ConnectionManager(int port)
Initiates the connection manager.
|
ConnectionManager(int port,
java.net.InetAddress address)
Initiates the connection manager.
|
ConnectionManager(Messenger messenger)
Initiates the connection manager.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes all open connections and disconnects
UdpListener . |
void |
closeConnection(int index)
Closes the connection with the given index.
|
int |
createConnection(java.net.InetAddress address)
Creates and initiates
Connection to the remote host with the
default ping frequency. |
int |
createConnection(java.net.InetAddress address,
int pingPeriod)
Creates and initiates
Connection to the remote host. |
static void |
freeTag(int tag)
Frees the sessionless tag for further use
|
static int |
generateSessionId()
The session ID generated by the
ConnectionManager . |
static int |
generateSessionlessTag()
The tag for messages sent outside the session generated by the
ConnectionManager . |
java.util.List<CipherSuite> |
getAvailableCipherSuites(int connection)
Gets from the managed system supported
CipherSuite s. |
GetChannelAuthenticationCapabilitiesResponseData |
getChannelAuthenticationCapabilities(int connection,
CipherSuite cipherSuite,
PrivilegeLevel requestedPrivilegeLevel)
Queries the managed system for the details of the authentification
process.
|
Connection |
getConnection(java.net.InetAddress address)
Returns first
Connection associated with the address |
Connection |
getConnection(int index)
Returns
Connection identified by index. |
void |
registerListener(int connection,
ConnectionListener listener)
Registers the listener so it will receive notifications from connection
|
void |
startSession(int connection,
CipherSuite cipherSuite,
PrivilegeLevel privilegeLevel,
java.lang.String username,
java.lang.String password,
byte[] bmcKey)
Initiates the session with the managed system.
|
public ConnectionManager(int port) throws java.io.IOException
port
- - the port at which UdpListener
will workjava.io.IOException
- when properties file was not foundpublic ConnectionManager(int port, java.net.InetAddress address) throws java.io.IOException
port
- - the port at which UdpListener
will workaddress
- - the IP interface UdpListener
will bind tojava.io.IOException
- when properties file was not foundpublic void close()
UdpListener
.public static int generateSessionId()
ConnectionManager
.
Auto-incremented.public static int generateSessionlessTag()
ConnectionManager
. Auto-incremented.public static void freeTag(int tag)
tag
- - tag to freepublic Connection getConnection(int index)
Connection
identified by index.index
- - index of the connection to returnpublic void closeConnection(int index)
public Connection getConnection(java.net.InetAddress address)
Connection
associated with the addressaddress
- - InetAddress
of the remote host to get connection
with.Connection
to the address or null if none foundpublic int createConnection(java.net.InetAddress address, int pingPeriod) throws java.io.FileNotFoundException, java.io.IOException
Connection
to the remote host.address
- - InetAddress
of the remote hostpingPeriod
- - frequency of the no-op commands that will be sent to keep up
the sessionjava.io.IOException
- - when properties file was not foundjava.io.FileNotFoundException
- - when properties file was not foundpublic int createConnection(java.net.InetAddress address) throws java.io.FileNotFoundException, java.io.IOException
Connection
to the remote host with the
default ping frequency.address
- - InetAddress
of the remote hostjava.io.IOException
- when properties file was not foundjava.io.FileNotFoundException
- when properties file was not foundpublic java.util.List<CipherSuite> getAvailableCipherSuites(int connection) throws java.lang.Exception
CipherSuite
s. Should be
performed only immediately after createConnection(java.net.InetAddress, int)
.connection
- - index of the connection to get available Cipher Suites fromCipherSuite
s supported by the managed system.ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system failspublic GetChannelAuthenticationCapabilitiesResponseData getChannelAuthenticationCapabilities(int connection, CipherSuite cipherSuite, PrivilegeLevel requestedPrivilegeLevel) throws java.lang.Exception
getAvailableCipherSuites(int)
connection
- - index of the connection to get Channel Authentication
Capabilities fromcipherSuite
- - CipherSuite
requested for the sessionrequestedPrivilegeLevel
- - PrivilegeLevel
requested for the sessionGetChannelAuthenticationCapabilitiesResponseData
ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system failspublic void startSession(int connection, CipherSuite cipherSuite, PrivilegeLevel privilegeLevel, java.lang.String username, java.lang.String password, byte[] bmcKey) throws java.lang.Exception
getChannelAuthenticationCapabilities(int, CipherSuite, PrivilegeLevel)
connection
- - index of the connection that starts the sessioncipherSuite
- - CipherSuite
that will be used during the sessionprivilegeLevel
- - requested PrivilegeLevel
- most of the time it will
be PrivilegeLevel.User
username
- - the usernamepassword
- - the password matching the usernamebmcKey
- - the key that should be provided if the two-key
authentication is enabled, null otherwise.ConnectionException
- when connection is in the state that does not allow to
perform this operation.java.lang.Exception
- when sending message to the managed system or initializing
one of the cipherSuite's algorithms failspublic void registerListener(int connection, ConnectionListener listener)
connection
- - index of the Connection
to listen tolistener
- - ConnectionListener
to notify