|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.nmt.mgp.MgpSession
public class MgpSession
An implementation of the MgpSessionI interface.
| Constructor Summary | |
|---|---|
MgpSession()
|
|
MgpSession(java.lang.String host,
int port,
boolean useSsl)
Construct a new MgpSession object, and connect to the server. |
|
| Method Summary | |
|---|---|
void |
close()
Clears the session by logging off from the server and closing the current connection. |
void |
connect(java.lang.String host,
int port,
boolean useSsl)
Connect to the server. |
java.sql.ResultSet |
dbexec(java.lang.String profile,
java.lang.String sql)
Send an SQL string to be executed on the EMG server. |
void |
deleteMessage(int id)
Delete a message. |
OptionHolder |
execute(int operation,
OptionHolder options)
Send an operation with arguments to the EMG server, and wait for the response. |
int |
getAdminFlags()
Gets the full administration flags for the currently logged in user. |
java.lang.String |
getClientConfig()
Gets the client configuration string. |
OptionHolder |
getLoginOptions()
Gets the current login options. |
int |
getPermissions()
Gets the permissions for the currently logged in user. |
java.lang.String |
getRemoteIp()
The IP number of this client, as seen by the server. |
boolean |
havePermission(int functions)
Checks if the current user has all of the given permissions. |
boolean |
havePermission(int mask,
boolean all)
Checks if the current user has any or all of the given permissions. |
boolean |
isAdmin()
Returns whether user in session is an administrator. |
void |
login(java.lang.String username,
java.lang.String password)
Login to the server using username and password for authentication. |
void |
login(java.lang.String username,
java.lang.String password,
java.lang.String servicetype)
Login to the server using username and password for authentication. |
void |
logoff()
Logoff from the server. |
protected javax.net.ssl.SSLSocket |
openSSL()
Open an SSL connection, allowing any certificate that the server might offer. |
int |
queryMessage(int id)
Query the server for status of a message, identified by the specified id. |
int |
readOperation(OptionHolder options)
Read an operation request from the server and store the options in the provided option holder. |
int |
readResponse()
Read the response to the last command sent to the EMG server. |
void |
reload()
Reload the configuration on the server, while keeping the connection open. |
int |
sendMessage(Message msg)
Send a message. |
void |
sendOperation(int operation,
OptionHolder options)
Send an operation to the EMG server. |
void |
sendOperation(int operation,
OptionHolder options,
boolean doFlush)
Send an operation to the EMG server. |
void |
setDebug(boolean on)
Enables/disables runtime debug output. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MgpSession()
public MgpSession(java.lang.String host,
int port,
boolean useSsl)
throws MgpException
host - the host name to connect toport - the port number to connect touseSsl - true if and only if the communication should use SSL
MgpException - if a communication error occursconnect(java.lang.String, int, boolean)| Method Detail |
|---|
public void connect(java.lang.String host,
int port,
boolean useSsl)
throws MgpException
MgpSessionI
connect in interface MgpSessionIhost - the host name to connect toport - the port number to connect touseSsl - true if and only if the communication should use SSL
MgpException - if a communication error occurs
protected javax.net.ssl.SSLSocket openSSL()
throws java.security.NoSuchAlgorithmException,
java.security.KeyManagementException,
java.io.IOException
java.security.NoSuchAlgorithmException - if no matching algorithm can be found
java.security.KeyManagementException - if no key can be agreed upon
java.io.IOException - if no socket can be opened on the connection
public void close()
throws MgpException
MgpSessionI
close in interface MgpSessionIMgpException
public void sendOperation(int operation,
OptionHolder options,
boolean doFlush)
throws MgpException
MgpSessionI
sendOperation in interface MgpSessionIoperation - the operation number, one of Mgp.MGP_OP_*options - the list of operation parametersdoFlush - true if and only if the socket stream should be flushed
after the operation
MgpExceptionMgp
public void sendOperation(int operation,
OptionHolder options)
throws MgpException
MgpSessionI
This is a simple overload to
MgpSessionI.sendOperation(int,OptionHolder,boolean),
with true used as the third argument.
sendOperation in interface MgpSessionIoperation - the operation number, one of Mgp.MGP_OP_*options - the list of operation parameters
MgpException
public int readOperation(OptionHolder options)
throws MgpException
MgpSessionI
readOperation in interface MgpSessionIoptions - an empty OptionHolder, which will get filled
with the parameters to the operation
MgpException - if a communication error occurs
public int readResponse()
throws MgpException
MgpSessionI
Calls MgpSessionI.readOperation(OptionHolder), extracts the return code
(Mgp.MGP_OPTION_RETCODE) and returns the value as an int.
readResponse in interface MgpSessionIMgpException - if an error occurs when reading from the streamMgp
public OptionHolder execute(int operation,
OptionHolder options)
throws MgpException
MgpSessionI
execute in interface MgpSessionIoperation - the operation number, as one of MGP_OP_*
from Mgpoptions - the input parameters, to be sent to the server
MgpException - if a communication error occurs
public void login(java.lang.String username,
java.lang.String password,
java.lang.String servicetype)
throws MgpException
MgpSessionI
login in interface MgpSessionIusername - the EMG username, sent as Mgp.MGP_OPTION_USERNAMEpassword - the EMG password, sent as Mgp.MGP_OPTION_PASSWORDservicetype - the systemtype, sent as Mgp.MGP_OPTION_SYSTEMTYPE
MgpException - if a communication error occurs
public void login(java.lang.String username,
java.lang.String password)
throws MgpException
login(String,String,String),
using null as the system type.
login in interface MgpSessionIMgpException
public void logoff()
throws MgpException
Sends the operation Mgp.MGP_OP_LOGOFF to the EMG server.
logoff in interface MgpSessionIMgpException
public void reload()
throws MgpException
Sends the operation Mgp.MGP_OP_RELOAD to the EMG server.
reload in interface MgpSessionIMgpException
public int sendMessage(Message msg)
throws MgpException
MgpSessionIDestination address and message data is mandatory. This is checked before the message is sent. If the message is not valid an exception is thrown.
Returns the message id on success, otherwise an MgpException is thrown.
sendMessage in interface MgpSessionImsg - A message with message text, destination address etc set
MgpException - if a communication error occurs
public int queryMessage(int id)
throws MgpException
MgpSessionIReturns message status on success, otherwise an MgpException is thrown.
queryMessage in interface MgpSessionIid - the unique identifier of the message, returned by
MgpSessionI.sendMessage(Message)
MgpException - if the message isn't found on the server,
or a communication error occurs
public void deleteMessage(int id)
throws MgpException
MgpSessionIShortcut for deleting the message identified by the specified id.
Returns message status on success, otherwise an MgpException is thrown.
deleteMessage in interface MgpSessionIid - the unique identifier of the message, returned by
MgpSessionI.sendMessage(Message)
MgpException - if the message isn't found on the server,
or a communication error occurs
public java.sql.ResultSet dbexec(java.lang.String profile,
java.lang.String sql)
throws MgpException,
java.sql.SQLException
MgpSessionI
dbexec in interface MgpSessionIprofile - the database profile namesql - the SQL string
INSERT
or UPDATE).
MgpException
java.sql.SQLExceptionpublic boolean isAdmin()
MgpSessionI
isAdmin in interface MgpSessionIpublic int getAdminFlags()
MgpSessionI
getAdminFlags in interface MgpSessionIpublic int getPermissions()
MgpSessionI
The value is a combined bitmask of MGP_ACCESS_*
from Mgp.
getPermissions in interface MgpSessionIpublic boolean havePermission(int functions)
MgpSessionI
havePermission in interface MgpSessionIMgpSessionI.havePermission(int, boolean)
public boolean havePermission(int mask,
boolean all)
MgpSessionIMGP_ACCESS_*
constants in Mgp.
havePermission in interface MgpSessionImask - the bitmask of permissionsall - true if all permissions must be presentpublic java.lang.String getClientConfig()
MgpSessionI
getClientConfig in interface MgpSessionIpublic void setDebug(boolean on)
MgpSessionI
setDebug in interface MgpSessionIon - true for debug out, false if notpublic OptionHolder getLoginOptions()
MgpSessionI
getLoginOptions in interface MgpSessionIpublic java.lang.String getRemoteIp()
MgpSessionI
getRemoteIp in interface MgpSessionI
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||