Here is an example on how to get the list of users already created:
AfDalAfKernelAfUser * a_user; gint i; // initilize Af-Arch framework afdal_init (); // log in inside the Af-Arch. Af-kernel central server // is located at: host barbol:55000 AfDalNulData * login_response = afdal_sync_session_login ("aspl", "test", "barbol", "55000"); if (AFDAL_IS_ERROR (login_response)) { g_print ("Login failed, error was: %s\n", AFDAL_RESPONSE (login_response)); afdal_nul_free (login_response); return; } afdal_nul_free (login_response); // get Af-Arch users list AfDalList * users = afdal_af_kernel_af_user_list_sync (0, 0); if (AFDAL_IS_ERROR (users)) { g_print ("Unable to get actual user list, error was: %s\n", AFDAL_RESPONSE (users)); return; } // iterate over all users created for (i = 0; i < afdal_list_length (users); afdal_list_next (users)) { // Get a reference to a well-defined Gobject structure a_user = afdal_list_data (users); g_print ("#%d: login=%s description=%s\n", a_user->id, a_user->nick, a_user->description); } // free user list afdal_list_destroy (users);
This is particular useful while programming client applications using a Graphical User interface. Application can keep on updating its interface, implement a status bar or making several petitions at the same time.
User space code is notified through a callback which is provided at request time. Here is an example about requesting Af-Arch users using Asynchronous method invocation:
// my callback which will be invoked when request answer is received gboolean my_callback (AfDalList * users, gpointer user_data) { // check request status if (AFDAL_IS_ERROR (users)) { g_print ("Unable to get actual user list, error was: %s\n", AFDAL_RESPONSE (users)); return; } // iterate over all users created for (i = 0; i < afdal_list_length (users); afdal_list_next (users)) { // Get a reference to a well-defined Gobject structure a_user = afdal_list_data (users); g_print ("#%d: login=%s description=%s\n", a_user->id, a_user->nick, a_user->description); } // free user list afdal_list_destroy (users); return TRUE; } // request code void my_request () { // we have already logged in // request user list if (afdal_af_kernel_af_user_list (0, 0, my_callback, NULL)) { g_print ("Unable to perform request.\n"); return; } // request doesn't blocks caller, applications keeps on // running return; }
User space code is written with no knowledge about where are services and servers executing, making user code maintainable and easy to be produced.
Af-Arch provides a runtime host location service and a runtime remote service binding through the central server Af-Kernel which is transparent, and need no user especial code to be activated or used. Af-Arch care about this.
There are only two data which have to be know by Af-Arch clients: host and TCP port where is running Af-Kernel central server.
Af-Arch developer will no need to implement more users and group stuff for each project. Af-Arch users and groups are integrated into the security and service execution, allowing to program services at server side without paying attention to which users and groups will be able to execute them.
Af-Arch users and groups service permissions are handled by Af-Key tickets. This elements allows to have a decoupled security model making Af-Kernel central server to generate Af-Key tickets which are used by the rest of Af-Arch nodes to validate users requests.
This decoupled model works pretty much like Kerberos security access. Af-Kernel and the rest of Af-Arch server nodes do not need to communicate each others for every service executed by users. Af-Arch server nodes uses generated Af-Key tickets.
Af-Arch groups enable to configure execution level profiles for a set of users making it easy to manage users execution profiles because users inherits groups permissions.
Each service exported is actually a permissions. This gives higher level to control which services can be executed by users and groups.
Both client and server code developed do not need to pay attention to service execution permission. Using a tool such as aspl-clm, administrators can configure permission for each users and groups.
Af-Arch permissions set to groups are inherited by users inside them, allowing to create a set of groups to implement users security profiles.
Af-Arch permission can be associated each others making posible to implement permissions cascading association when a permission is set.
Session are controled from server nodes, allowing to configure if they are activated, or to set how long a session is.
Currently there are fully support to C and C# to develop client application.
Server side components only runs on GNU/Linux server side.
server interface af-contact {
// type definition using implicit id as index
type addresses is data (string address, string city,
string postal_code) index (id);
// module definition with three services
module address () {
// list all address created
public get_list (int initial, int max_row_number) return addresses;
// create a new address
public create (string address, string city, string postal_code) return simple;
// remove the given address
public remove (int id) return nul;
}
// also generate synchronous interface
sync interface address;
}
But, af-gen also allows you to integrate your code inside the idl defintion, making more easy to keep synchronized user code generated with IDL definition:
server interface af-contact {
// type definition using implicit id as index
type addresses is data (string address, string city,
string postal_code) index (id);
// module definition with three services
module address () {
// list all address created
public get_list (int initial, int max_row_number) return addresses {
CoyoteDataSet * result;
// make database request
result = afgs_command_execute_single_query ("SELECT * FROM address");
// check result
if (!result) {
AFGS_ERROR ("Error while getting addresses", COYOTE_CODE_ERROR);
return FALSE;
}
AFGS_OK ("Addreses available", COYOTE_CODE_OK, result);
return TRUE;
}
// create a new address
public create (string address, string city, string postal_code) return nul {
gboolean result;
#define QUERY "INSERT INTO address (address, city, postal_code) VALUES ('%s', '%s', '%s')"
result = afgs_command_execute_non_query (QUERY, address, city, postal_code);
// check result
if (!result) {
AFGS_ERROR ("Error while creating the address", COYOTE_CODE_ERROR);
return FALSE;
}
AFGS_OK ("Address created", COYOTE_CODE_OK, NULL);
return TRUE;
}
// remove the given address
public remove (int id) return nul {
gboolean result;
#define QUERY "DELETE FROM address WHERE id = '%s'"
result = afgs_command_execute_non_query (QUERY, id);
// check result
if (!result) {
AFGS_ERROR ("Error while creating the address", COYOTE_CODE_ERROR);
return FALSE;
}
AFGS_OK ("Address deleted", COYOTE_CODE_OK, NULL);
return TRUE;
}
}
// also generate synchronous interface
sync interface address;
}
But af-gen goes furthermore ahead with its capabilities to create implicit definitions due to module definitions and relations set between them.
server interface af-contact {
// relation definition
relation located;
// module definition for addresses
module address (string address,
string city,
string postal_code) implicit definition {
address located identity with 0..n;
}
// enum definition
enum IdentityType {organization, friend, people};
// module definition for identities
module identity (string name,
string description,
enum IdentityType identity_type) implicit definition {
identity located address with 0..n;
}
// also generate synchronous interface
sync interface address, identity;
}
./autogen.sh
make
make install
We encourage you to follow the development model you wish. There is no going to be any distintion on helping projects developing Open Source application or Commercial ones. Both are wellcome.
Of course, we will appreciate earing you mentioning Af-Arch framework from your project.