|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--moses.member.Member
This class represents the communication interface between an agent and its controller.
A java program becoming part of a community (a proper agent) has to instantiate
this class. In general, an interaction session consists from a call to the
adopt() or reconnect() method, followed by sending
and receiving messages through one of the corresponding methods, and ending
in a call to the close method.
Member m = new Member(...);
m.adopt(...);
m.send_lg(...);
m.receive_lg();
m.close();
Beside the methods that handle the above steps, there are several methods dedicated
to submitting certificates either as individual messages or as part of the adoption process.
The constructors are responsible for initializing this object's field variables regarding the
moses addressing scheme and other aspects of the interaction with the controller.
As this object offers the means of communication between agents within a community, a large part
of the functionality is dedicated to sending and receiving methods. The sending method is overloaded
such that it accomodates various data types: String, byte[],and Object , as well as
XML-formated strings.
In order to allow a convenient method of treating export operations
(sending messages to agents operating under different laws - see Moses manual for details) all the sending
methods allow an extra String argument representing the law name of the destination agent.
The name of the law is interpreted according to the portal field (see Distinguished Control State DCS)
of the source agent.
This object implements three receiving methods, distinguished by the data type of the result: String,
XML-formatted String, and moses.member.Answer . The last method, the most general of all, returns a
wrapper class that allows extraction of messages of various data types. The String method is
implemented for convenience and for maintaining compatibility with previous moses.member implementations.
The XML method allows retrieval of messages in XML format.
| Field Summary | |
java.lang.String |
controllerHost
Variable maintaining the name of the controller host. |
java.lang.String |
controllerLongName
Variable maintaining the long name of the controller host. |
int |
controllerPort
Variable maintaining the port of the controller. |
java.lang.String |
law
Variable maintaining the law this agent operates under. |
java.lang.String |
longName
Variable maintaining the full name of an agent. |
static int |
MAX_NACK
Constant specifying the maximum number of unacknowledged message at any moment of time. |
static int |
MAX_SLEEP
Constant specifying the maximum amount of time (in milli-seconds ) elapsed without acknowledging a message. |
java.lang.String |
shortName
Variable maintaining the short name of an agent. |
| Constructor Summary | |
Member(java.lang.String law,
int lawType,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName)
Shorter version of the previous constructor, where no certifying authority public key is supplied. |
|
Member(java.lang.String law,
int lawType,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName,
java.security.PublicKey controllerAuPk)
Creates a new member instance. |
|
Member(java.lang.String lawurl,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName)
The shortest form of the constructor. |
|
| Method Summary | |
void |
addCertificate(moses.security.LGICert cert,
byte[] sign)
Appends a |
int |
adopt(java.lang.String passwd,
java.lang.String args)
This method request a TCPIP connection between this member object and the controller. |
int |
changePassword(java.lang.String newPass,
java.lang.String oldPass)
This method is one of the two methods used by an agent to change its reconnecting password. |
void |
clearCertificateList()
Clears the list of certificates to be submitted during adoption An agent can submit a list of certificates to its controller as part of the adoption/connection procedure. |
void |
close()
|
moses.member.Answer |
generic_receive_lg()
This method is the main method used by an agent for receiving messages. |
static void |
main(java.lang.String[] args)
|
java.lang.String |
receive_lg()
This method is designed mainly to maintain backwards compatibility with previous versions of Moses system. |
moses.member.Answer |
receiveXML_lg()
This method is mostly similar to the previous receive_lg method. |
int |
reconnect(java.lang.String passwd)
This method attempts to reestablish a connection with a controller, given that the controller maintains the state for this agent. |
void |
run()
Thread that runs in background and acknowledge messages each MAX_SLEEP ms. |
boolean |
send_lg(byte[] bmessage,
java.lang.String destination)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
send_lg(byte[] bmessage,
java.lang.String destination,
java.lang.String lname)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
send_lg(java.lang.Object omessage,
java.lang.String destination)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
send_lg(java.lang.Object omessage,
java.lang.String destination,
java.lang.String lname)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
send_lg(java.lang.String message,
java.lang.String destination)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
send_lg(java.lang.String message,
java.lang.String destination,
java.lang.String lname)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
int |
sendCertificate(moses.security.LGICert cert)
This method is used by an agent to submit an LGI certificate to its controller. |
int |
sendSelfCertificate(moses.security.LGICert cert,
byte[] mySign)
This method is used by an agent to submit an LGI self certificate to its controller. |
boolean |
sendXML_lg(java.lang.String message,
java.lang.String destination)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
sendXML_lg(java.lang.String message,
java.lang.String destination,
java.lang.String lname)
This method is used by any agent that is curently connected to a controller in order to send LGI (regulated) messages. |
boolean |
test(java.lang.String firstArg,
java.lang.String secondArg)
This method sends a special TEST - type message to the controller. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public java.lang.String shortName
public java.lang.String longName
public java.lang.String law
public java.lang.String controllerHost
public java.lang.String controllerLongName
public int controllerPort
public static final int MAX_NACK
public static final int MAX_SLEEP
| Constructor Detail |
public Member(java.lang.String law,
int lawType,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName,
java.security.PublicKey controllerAuPk)
law - specifies the law an agent wants to operate under after adoption.
Depending on the value of the lawType argument, this argument stores either
the text of the law or the absolute URL where the text of the law can be retrieved from.
The law can be published by any server following HTTP 1.1 protocol.lawType - is a modifier argument, specifying the way the law argument is interpreted.
Acceptable values are moses.util.Const.URL_LAW ( int value 0 ) or moses.util.Const.IMM_LAW
( i.e. immediate law, int value 1 ).controllerHost - represents the fully qualified host name of the controller.controllerPort - represents the port number the controller waits for agents to connect.
The default value for the controller port number is 9000.shortName - the name an agent wants to bear as a member of the community. Since agent
names are globally unique, the adoption of the agent can fail because of a poor name choice.controllerAuPk - public key of the certifying authority that certifies this controller
as a "certifiedController" (as defined by moses.util.Const.ATTRIBUTES). This public key is used
in order to verify the certificate a controller submits during the connection phase, as a
proof of trust for the agent.
public Member(java.lang.String law,
int lawType,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName)
law - specifies the law an agent wants to operate under after adoption.
Depending on the value of the lawType argument, this argument stores either
the text of the law or the absolute URL where the text of the law can be retrieved from.
The law can be published by any server following HTTP 1.1 protocol.lawType - is a modifier argument, specifying the way the law argument is interpreted.
Acceptable values are moses.util.Const.URL_LAW ( int value 0 ) or moses.util.Const.IMM_LAW
( i.e. immediate law, int value 1 ).controllerHost - represents the fully qualified host name of the controller.controllerPort - represents the port number the controller waits for agents to connect.
The default value for the controller port number is 9000.shortName - the name an agent wants to bear as a member of the community. Since agent
names are globally unique, the adoption of the agent can fail because of a poor name choice.
public Member(java.lang.String lawurl,
java.lang.String controllerHost,
int controllerPort,
java.lang.String shortName)
controllerHost - represents the fully qualified host name of the controller.controllerPort - represents the port number the controller waits for agents to connect.
The default value for the controller port number is 9000.shortName - the name an agent wants to bear as a member of the community. Since agent
names are globally unique, the adoption of the agent can fail because of a poor name choice.| Method Detail |
public void clearCertificateList()
addCertificate(moses.security.LGICert, byte[])
public void addCertificate(moses.security.LGICert cert,
byte[] sign)
cert - represent the certificate to submit to the controller during adoption. The certificate
(of LGICert type) can be either a proper or a self certificate. It can be created and handled by using
certCreation class.sign - represent the signature corresponding to a self certificate. If the argument is null,
then cert argument is intrepreted as a proper certificate.clearCertificateList(),
LGICert,
certCreation
public int adopt(java.lang.String passwd,
java.lang.String args)
moses.message.Message class. This message contains mainly the following information:
the desired name of the agent, the law this agent wants to operate under (either as immediate value or as URL),
the password used for reconnection, and the argument provided by the user ( the later two fields taken as
arguments to this method). If this object stores any certificate, they are also send along within this message.
As a result of this message, the controller starts the procedure of creating an LGI agent. The main steps involved are the downloading and the verification of the law, checking the name of the agent, and setting up the state associated with this agent (Control State CS, Distinguished Control State DCS, with all its components), and other data structures internal to the controller. The controller will also set up a mailbox where all the un-acknowledged messages will be stored. Subsequent to these steps, if the creation of the agent is succesfull, an adopted event will be triggered according to the law this agent operates under. In the same time, an acceptance message will be sent back to this Member object. If the controller is not able to create an LGI agent (for reasons discussed below), a rejected message is sent back.
If there were certificates previously stored in this object (using addCertificate method), these
certificates will be send as part of the first message to the controller. After their proper verification
these certificates will be presented as part of the adopted event. The failure to verify the validity of
a certificate will be treated quietly: the adoption will still be succesfull (thus a succesful message
will be sent to this object), but the adoption event will not include the failed certificate.
In extremis, if none of the certificates passes the verification stage, the adopted events
will be evaluated with an empty list of certificates.
Some other details of the adoption procedure are also discussed in the context of the adoption event in the law object.
passwd - represents the password to be used later for reconnection to this controller should this
connection will be torn down or the agent will temporarly disconnect. Once the password is established,
it can be changed in two ways: either using this obejct's changePassword method, or within the law,
by using the setPassword primitive operation. This second method is also discussed in the
documentation adjacent to the description of the law.args - represents an arbitrary string to be used during the evaluation of the adoption event.
In the case of an agent operating under a law written in Java, the string can be any arbitrary string.
In the case of a Prolog law, this string should follow the syntax of a properly formed Prolog term.
moses.util.Const class, the following are the return values and their
interpretation:
public int reconnect(java.lang.String passwd)
moses.message.Message class. This message contains mainly
the following information: the name of the agent, and the password necesary to authenticate this member.
In order for the controller to accept the reconnection, the password should match the password maintained by the controller on behalf of the agent, and the state of the controller agent should be DISCONNECTED. The other two possible states of an agent are either CONNECTED (for a controller agent maintaining an active TCPIP connection with its agent) either UNCONNECTABLE (for a controller agent that has a "null" password as result of setPassword primitive operation). If the above steps are successful, a reconnected event is triggered for this agent. Simultaneously, the controller returns a sucessful message that will be provided as a result value of this method. Otherwise, an error message will be returned. If this method returns sucessfully, and the controller has previously stored any messages on behalf of this agent during the disconnection time, all the unacknowledged messages will be sent to this member.
passwd - represents the password provided as means of authenticating the member
moses.util.Const class, the following are the return values and their
interpretation:
public boolean send_lg(java.lang.String message,
java.lang.String destination)
invalid: original message is sent back to the actor. Next, if the law allows
(based on the actual implementation of the sent event), the message is being forwarded to the destination.
message - represent the body of this message (i.e. the payload). Any non-nullvalue is allowed.destination - represent the destination of this message. Unless the law itself overwrites this argument,
this value should be a non-null moses address of the form "agent-name@controller.name".
send_lg( byte[] bmessage, String destination),
send_lg( Object omessage, String destination),
send_lg( byte[] bmessage, String destination),
send_lg( String message, String destination, String lname),
send_lg( Object omessage, String destination, String lname),
sendXML_lg(String message, String destination, String lname),
sendXML_lg(String message, String destination, String lname)
public boolean send_lg(byte[] bmessage,
java.lang.String destination)
send_lg( String message, String destination)
public boolean send_lg(java.lang.Object omessage,
java.lang.String destination)
send_lg( String message, String destination)
public boolean sendXML_lg(java.lang.String message,
java.lang.String destination)
send_lg( String message, String destination)public int sendCertificate(moses.security.LGICert cert)
cert - represents a properly initialized LGIcert object.
moses.util.Const class, the following are the return values and their
interpretation:
sendSelfCertificate(LGICert cert, byte [] mySign)
public int sendSelfCertificate(moses.security.LGICert cert,
byte[] mySign)
cert - represents a properly initialized LGIcert object.mySign - represent the signature of the certificate performed with the private key of the
submitting agent.
moses.util.Const class,
the following are the return values and their interpretation:
sendCertificate(LGICert cert)
public boolean send_lg(java.lang.String message,
java.lang.String destination,
java.lang.String lname)
message - represent the body of this message (i.e. the payload). Any non-nullvalue is allowed.destination - represent the destination of this message. Unless the law itself overwrites this argument,
this value should be a non-null moses address of the form "agent-name@controller.name".lname - represent the name of the law the destination operates under. The name of the destination law
should be defined in the portal of the law of the sending agent. A non-null value is required.send_lg( String message, String destination)
public boolean send_lg(byte[] bmessage,
java.lang.String destination,
java.lang.String lname)
send_lg( String message, String destination)
public boolean send_lg(java.lang.Object omessage,
java.lang.String destination,
java.lang.String lname)
send_lg( String message, String destination)
public boolean sendXML_lg(java.lang.String message,
java.lang.String destination,
java.lang.String lname)
send_lg( String message, String destination)public moses.member.Answer generic_receive_lg()
receive_lg()public java.lang.String receive_lg()
generic_receive_lg()public moses.member.Answer receiveXML_lg()
generic_receive_lg(),
receive_lg()
public int changePassword(java.lang.String newPass,
java.lang.String oldPass)
newPass - represent the new password for the reconnection to this agent.oldPass - represent the old password already in place.
public boolean test(java.lang.String firstArg,
java.lang.String secondArg)
public void close()
public void run()
run in interface java.lang.Runnable
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||