This blog is subject the DISCLAIMER below.

Wednesday, July 21, 2010

FCIH Initiative launch

Finally we are glad to announce the launch of
FCIH Initiative Program
On Next Sunday 25/7/2010 at FCI-Helwan
Join our great event; Join a group of carefully selected sessions highly needed in your practical life.
Event Schedule:
Day 1 [Sunday: 25-7-2010]: Let's get started
10:00
10:30
Orientation
10:30
12:30
Object Oriented Blocks
12:30
01:00
Break
01:00
02:30
Good Code
02:30
03:00
Break
03:00
04:00
English for Business
Day 2 [Monday: 26-7-2010]: Develop your path
10:00
11:30
Web Development A – Z
11:30
12:00
Break
12:00
02:00
Software Quality Engineering
02:00
02:30
Break
02:30
04:00
CV Writing and interviewing skills
Day 3 [Wednesday: 28-7-2010]: IT, World of Endless Choices
10:00
11:00
GIS: Geographic information system
11:00
12:00
CMS: Content Management System
12:00
12:30
Break
02:00
02:30
BI: Business Intelligence
02:30
03:30
RIA: Rich Internet Application
Day 4 [Thursday: 29-7-2010]: Into the business world
10:00
01:00
Agile Software Development
01:00
01:30
Break
01:30
3:00
Understanding Business Analysis
03:00
04:30
Global / Local IT Market
04:30
05:00
Closing
Don't miss the chance…..and don't forget our date "25/7/2010" at FCI-Helwan.
Waiting you there :)
Yours,
FCIH Initiative Team

.. more.

Adding arabic letters jeem, peh, and veh to keyboard layout in Linux

The letters

چ
پ
ڤ
Do not come on the standard layout of arabic keyboard on linux. It is easy to add them.
You will need to edit /usr/share/X11/xkb/symbols/ara and log-out and login again.
The need to edit only the lines corresponding to they keys you'll attach those letters to. I chose the key corresponding to
ج
ب
ف
(naturally).
The 3 modified lines are:
key { [ Arabic_feh, 0x100fef9 , Arabic_veh ] };
key { [ Arabic_jeem, less , Arabic_tcheh ] };
key { [ Arabic_beh, bracketleft, Arabic_peh ] };
Notice that the new characters are in the third position. The first position is the letter typed when you press the key. The second position is the letter if you were pressing shift, and the third one is the letter if you were pressing the 3rd level selector key. To know which key you have (or to change it to a more convenient one) to go System>Preferences>Keyboard, Mappings tab, click on "Options" then click "Key to choose 3rd leve" then choose whichever key you prefer.
Enjoy your new characters :)

.. more.

Thursday, July 15, 2010

FCIH Initiative.. Postponement announcement

Hello all,

Because of some out-of-hand circumstances, we are sorry to announce that the big event is going to be postponed for few days. We are going to update you with the new dates along with the complete schedule within few days isA.

Sorry for any inconvenience,
FCIH Initiative team.

.. more.

Saturday, July 10, 2010

Creating a simple Open Search Provider/Plug-in

Yesterday, I needed to check/search my delicious bookmarks more than once. I then realized that delicious have its a search plug-in as a part of a tool bar (along with other bookmarking tools, few search tools, though), which -I guess- loads all your bookmarks to browser & make them available for search.

As I’m not so much into too much plug-ins, specially if they load lots of data (in contradiction to Pointy-haired Boss) , not to mention that I won’t need bookmarks when I’m offline, anyway, I decided I should create my search provider.

Creating the provider:

Here’s an example:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
   <ShortName>My Delicious</ShortName>
   <Description>Search Shady’s Delicious Bookmarks</Description>
   <Tags>Delicious Bookmarks Search Favorites</Tags>
   <Image width="16" height="16" type="image/x-icon">http://delicious.com/favicon.ico</Image>
   <Url type="text/html"
        template="http://delicious.com/search?p={searchTerms}&amp;context=userposts|m.shady|&amp;lc=1"/>
</OpenSearchDescription>

Away from the fact that I badly need a WYSIWYG code hi-lighter, let’s check that XML. First the ShortName which appears in your search box, something like this:

Click to Enlarge Description and Tags are obvious, & I think optional too.

Image is the small icon that appear beside when you select your provider (check the pic above again). You can either supply it as a URL to an image file (usually .ico or .png) or you can replace it with the base 64 string of the image (though I wasted quite sometime to make that work), like:

<Image width="16" height="16">data:image/x-icon;base64,AAA…AAA==</Image>

Finally, URL note that I’m using {SearchTerms} to pass the string typed in the search box. You can send other parameters to your search page. You might want add another URL for suggestions, here I’m only providing the search URL.

Using the provider:

To add the provider to your browser (as far as I’m concerned it works fine for Firefox & IE) you have one of two options:

Adding it as a suggested search provider: This can be done by adding a single line in your page <Head> tag, note that the attribute title in the below tag refers to the name appearing in the list as [Add “title”], check the image below the tag.

<link rel="search"
           type="application/opensearchdescription+xml"
           href="http://localhost/SearchProviders/delicious.xml"
           title="Delicious" />

Click to Enlarge

Using JavaScript to add the provider: The other available option is to add the provider using scripting, here’s an eg of how you can do that:

<a href="#" onclick="window.external.AddSearchProvider('http://localhost/SearchProviders/delicious.xml')">Add delicious Search to your browser</a>

Clicking a link like the one above will pop up a windows asking if you want to add the search provider.

References: http://www.opensearch.org

.. more.

Friday, July 09, 2010

Changing regional settings for System accounts (including ASPNET) in Windows 7

One of the small issues I faced while switching my development machine to windows 7 was a bug/exception in an application I was working on in parsing date format.

After switching my regional settings to the “expected” format, I still got the same exception. After playing a little with the regional settings, I realized that I was switching only my account date format, not the whole machine's date format. To push those settings to other system accounts (like ASPNET, etc), I did the following steps:

After setting your your account regional settings, switch to “Administrative” tab:

Click to Enlarge

From “Welcome screen and new user accounts”, click “Copy setting”:

Click to EnlargeMake sure “Welcome screen and system accounts”  check box is checked, press ok, and Voila!

.. more.

Monday, July 05, 2010

FCIH Initiative -- Students to Business

FCIH Initiative …..
Don't wait the chance, Create It

Thinking about your future? Worried about your career?

Thinking that you are far away from real market life and limited by your academic life?

Want to be professional but don't know where to start?

Interested to know how people work and deliver projects?

Need to gain experience in market? Need to know about Egyptian IT market?

FCIH Initiative is now here for you

Our goal is you, preparing for you, planning for you

Build your own market and Make companies sigh for you

This summer, we'll be together to make your dreams come true

To bridge your academic study to your career

Plan for your career right now

Meet your older colleagues and learn from them

Join us and enjoy:

Trainings – Research – Business Experience – Technical Knowledge – English Club - and more….

FCIH initiative program will start on 17-7, so don't miss the chance.

We're planning to provide:

· Technical sessions

· Training program in 3 tracks (java, .net, and PHP)

· Sessions talking about market, and adding to your personal skills.

· Program for those who are interested in research.

· Soft skills program.

· English club.

Now, don't worry about the future...Together we'll build a better tomorrow

Contacts:

Mail: FCIH.Initiative@fcih.net

Website: http://www.helwan.edu.eg:90/fcih/details.asp?id=161

FaceBook Event: http://www.facebook.com/#!/event.php?eid=128813070490801&ref=mf



.. more.

Saturday, July 03, 2010

Customizing your eclipse download

In this site (http://ondemand.yoxos.com/geteclipse/start) you choose which plugins you want to download you eclipse version with; as opposed to downloading a predefined standard template and customizing it later after you install it. Enjoy :)

.. more.

Thursday, July 01, 2010

Downloading metacafe videos

The following script will download metacafe videos for you:


metacafe-dl.sh:
url=`wget @1 -o /dev/null -O - | grep 'mediaURL' | sed 's/%22/\n/g' | grep -A 6 mediaURL | sed 's/%3A/:/g' | sed 's|%2F|/|g' | sed 's/%5C//g' | sed 's/%25/%/\
g' | tr '\n' '#' | awk '-F#' '{print @3 "?__gda__=" @7}'`

wget --referer=http://s.mcstatic.com/Flash/vp/mc/Portal_3.2.1.1.swf @url -O `echo @url | sed 's%/%_%g'`.mp4

Just call the file like this
./metacafe-dl http://url-of-the-meta-cafe-video

(due to technical error replace @ with a dollar sign instead).
And you will have your file there. Have a nice time ;)

.. more.

Saturday, June 19, 2010

VS 2008 to TFS 2010 (on windows 7, or may be x64 in general)

Probably you already know that Visual studio (Team explorer) 2008 can connect to TFS 2010 if you installed the right Service Pack (there’s one for VS 2005 too) and types the right server name.

 

Yet, a week (or so) ago I switched to windows 7 (64 bit) which lead to a couple of issues with my development environment (feel free to ask me or share your experience with me on that topic, I’m still struggling at that point). One of these issues was that the Visual Studio 2008 SP 1 Forward Compatibility Update for TFS 2010 wouldn’t work for me.

 

After a long search, & several installs, uninstalls, reinstalls, etc.. I came to the following solution that worked for me & (later) for a couple of my team mates at work. Here’s what you might want to do to fix that:

Try to use the same order above, and make sure you reinstall the above stuff even if you already have them.

.. more.

Tuesday, May 25, 2010

How to consume REST based-services?

Q. How to consume REST based-services?
Assume we have REST based-service contains method Add which takes two operands op1 and op2 and return the summation.

A. Create any project type (Console, Windows or even Web-based application)
Add using System.Net; using System.IO;
Write some code to consum the service
string parameters;
string response;
// Create the request obj
WebRequest request = WebRequest.Create("serviceURL/Add");
// Set values for the request back
request.Method = "POST"; //REST based-services using Post method
request.ContentType = "application/json"; //tells request the content typs is JSON
parameters = "{\"op1\":2,\"op2\":\"1\"}";
request.ContentLength = parameters.Length;
// Write the request
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
requestWriter.Write(parameters);
requestWriter.Close();
// Do the request to get the response
StreamReader responseReader = new StreamReader(request.GetResponse().GetResponseStream());
response = responseReader.ReadToEnd();
responseReader.Close();
//response value should be 3 if you implement Add method correctly :))

.. more.

Tuesday, May 18, 2010

Python Script to download TED Talks translations :))

Well, i admit it, i am a TED lover. I love the passion, and the "new" factor TED brings to me :)

I was watching this presentation for Simon Sink and someone I know downloaded the video but wasn't able to view the translation locally, so I thought I might be able to download the translations for him and convert them to SRT format to be able to display them on any Video Player. and Here is how I did it :)

If you visited the site before, you will find it has a flash control where you can view the video and choose the translation if needed.

First, To be able to investigate how the flash control gets the translation, you have to open a network sniffer which will enable you to view all the packets going to and from your network card. A good packet sniffer is Wireshark, and if you don't know it check those links to know more about how to use it :)
Packet Sniffing using Wireshark Tutorial (Video)
Fifteen Minute Wireshark Tutorial - Wheeler Software


Second,
you need to add a filter for "HTTP" requests only, and navigate through any video (like the one above) to view how the flash control communicates with the server :)

When you choose a translation, you will find a request to a URL like this: www.ted.com/talks/subtitles/id/848/lang/eng , where 848 is the Talk ID and eng is the language choosed "English".

So there two questions now, given a URL to the TED Talk

What format are translation subtitles returned?
How do i get the Talk ID?


To answer the first question, just click the link above, and you will find the translation is returned in JSON (Javascript Object Notation) format. So this is good news. We just need to find a good library to handle JSON, and be able to convert it to SRT format to be able to use it on almost any Video Player like VLCMedia Player.

And the answer to the second question is to do a simple "View Source" and search for this number, you will find it in several places through the page's source code, so simple parsing the page HTML should do the job.
Here is the full Script to do the job given the URL on ted.com and the language code which is eng for english and ara for arabic. Will try to provide the rest of the language codes later.

This is a simple command to test the script:

python TEDSubtitles.py "http://www.ted.com/talks/simon_sinek_how_great_leaders_inspire_action.html" "eng"

And here is the full source code, will try to upload it somewhere soon.

Hope it's worth spreading :))

Updates:
You can get the script here .
You need at least Python 2.6 for the json module to be available.

Update on 22/09/2010:
I was informed in the comments by Mohammad that he created a program http://sourceforge.net/projects/tedgrabber/ to download TED Talks and subtitles. He also created another one http://sourceforge.net/projects/timecovergrabbe/ , which allows you to grab Time Magazine covers.This is another example that illustrates the concept and ofcourse it can be applied everywhere. Good luck to Mohammed.
Although it's hosted on sourceforge, the source code is not available. It would be better if it was shared.

Update on 24/04/2011:
A Google Appengine application was created for the same functionality on http://tedsubtitles.appspot.com

You can view the source below, but for better colorized viewing check this link here
import os
import sys
import json
import urllib2

# Format Time from TED Subtitles format to SRT time Format
def formatTime ( time ) :
milliseconds = 0
seconds = ((time / 1000) % 60)
minutes = ((time / 1000) / 60)
hours = (((time / 1000) / 60) / 60)
formatedTime = str ( hours ) + ':' + str (minutes) + ':' + str ( seconds ) + ',' + str ( milliseconds )
return formatedTime

# Convert TED Subtitles to SRT Subtitles
def convertTEDSubtitlesToSRTSubtitles ( jsonString , introDuration ) :
jsonObject = json.loads( jsonString )

srtContent = ''
captionIndex = 1

for caption in jsonObject['captions'] :
startTime = str ( formatTime ( introDuration + caption['startTime'] ) )
endTime = str ( formatTime ( introDuration + caption['startTime'] + caption['duration'] ) )

srtContent += ( str ( captionIndex ) + os.linesep )
srtContent += ( startTime + ' --> ' + endTime + os.linesep )
srtContent += ( caption['content'] + os.linesep )
srtContent += os.linesep

captionIndex = captionIndex + 1
return srtContent

def getTEDSubtitlesByTalkID ( talkId , language ) :
tedSubtitleUrl = 'http://www.ted.com/talks/subtitles/id/' + str(talkId) + '/lang/' + language
req = urllib2.Request(tedSubtitleUrl)
response = urllib2.urlopen(req)
result = response.read()
return ( result )

tedTalkUrl = sys.argv[1]
language = sys.argv[2]

req = urllib2.Request(tedTalkUrl)
response = urllib2.urlopen(req)
result = response.read()

## Get Talk ID value
splits = result.split ( ';ti=' )
talkId = splits[1].split ( '&' )[0]
print talkId

## Get Talk Intro Duration value
splits = result.split ( ';introDuration=' )
talkIntroDuration = splits[1].split ( '&' )[0]
talkIntroDuration = int ( talkIntroDuration )
print talkIntroDuration

jsonString = getTEDSubtitlesByTalkID ( talkId , language )

srtContent = convertTEDSubtitlesToSRTSubtitles ( jsonString , talkIntroDuration )

# Generate SRT file name
splits = tedTalkUrl.split ( '/' )
srtFilename = splits[len ( splits )-1].split ('.')[0]

srtFile = open ( './' + srtFilename + '.srt' , 'w' )
srtFile.write ( srtContent.encode ( "utf-8" ) )
srtFile.close ()


.. more.

Friday, April 23, 2010

ArabEyes Arabic Technical Dictionary

The ArabEyes project is managing a wiki-based technical dictionary for Arabizing English technical terms.

Not all the terms are translated, and some are still under discussion by the wiki members. Some terms have many proposals and is under a voting process.
The dictionary is used as a reference for translating open source software, like Ubuntu and OpenOffice.
If you want to leave your signature or recommend a better translation for some terms, you are more than welcome to participate on the URL :

.. more.

Sunday, April 11, 2010

GridView with Highlighting and dragging rows

Two days ago, I needed a grid like GridView to be project’s inbox but must have some UI effects like highlighting rows and sorting rows according to column’s name or by drag and drop rows by mouse pointer.
Of course the first thing came in my mind is using JQuery with the gridview as it runs by a little lines of code and give the client a big influence and satisfaction.

I am already started with trying some plug-ins for Drag and Drop but I found a big issue with GridView itself as it’s render the header and footer as ordinary row (TR Tag) NOT (thead tag) and (tfoot tag) so any plug-in can’t differentiate between any row and the header (the section of columns name) or footer (the section of paging ).

So I google for solution and get a part of it by Suprotim Agarwal then I modified it to fit my needs and some changes in the Table Drag and Drop JQuery . So take care to use the attached (modified) Dragging plug-in as I modified it and use the start up script.

The Grid before fix (as you can see, you can drag any row even the header or footer):

After fixing:
Download the complete Example.

.. more.

Tuesday, March 23, 2010

How to configure SQL Server for ASP.NET SQL Server Session State <sessionState mode="SQLServer" ../>

On your prompt (doesn’t matter if you’re on the SQL server machine or not), run the below command:

”system root”\Microsoft.NET\Framework\”version number”>aspnet_regsql.exe –S “server” -U sa -P “Password” -ssadd -sstype p
for eg:
C:\Windows\Microsoft.NET\Framework\v2.0.50727>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
OR
C:\WINNT\Microsoft.NET\Framework\v4.0.21006>aspnet_regsql.exe -S MySQLServerInstanceName -U sa -P password -ssadd -sstype p
Now you have ASPState database on your servers with the tables, stored procedures, jobs needed to handle SQL server mode session state.

.. more.

Thursday, February 25, 2010

Shared secrets

This post continues the other approach to secure multi-party computation, which is called "Secret-sharing".

The problem
Consider the problem that, there is a nuclear missile, and there is its launch code. Only the president has that code. But what if the president is unavailable ? We can't trust any of the executives alone. We would require for example that 3 of them can launch the missile, but not any single one of them alone. This is what secret-sharing is about. It's goal is quite different than homomorphic encryption, but it used also for secure multi-party computation.





Which is more secure?
Homomorphic encryption relies on the assumption that it would take long time to crack it. Typically for example, the problem of factoring a very big number. Secret-sharing, on the other hand, is secure in information-theory sense. That means that even if given the entire eternity, you can not break it, simply because there is no information leakage (unlike the other approach where is information leakage with small probability).

Shamir's Secret Sharing
The first to publish about a practical secret sharing scheme was Shamir, in 1979 [1]. It's target is to create $n$ shares of the secret, such that any $k$ shares are sufficient to reconstruct the secret. Each person would be given some shares. The president is allowed to launch the missile alone, so he will have $k$ shares. The executes must be 3, so each one will take $k/3$ shares. The total number of shares is unbounded. Such a scheme is called $(k,n)$ secret-sharing.

What if some shares was stolen ?
If the number of shares stolen were less than $k$, then the other shares can be renewed by adding a random shared secret whose value is zero [2]. The old stolen shares are useless now since their compatible shares were replaced by new ones.

How does it work ?
Shamir's scheme depends on Lagrange Interpolation of polynomials. Using Lagrange interpolation, you can recover a polynomial $f(x)$ of degree $t$, given $t$ pairs $(x_i,y_i)$ such that $y_i=f(x_i)$.

Encoding a secret
To encode a secret value $v$ in a $(k,n)$ secret-sharing scheme, do the following:
- Generate a random polynomial of degree $k$ whose free coefficient is $v$ (that means $f(0)=v$).
- Evaluate the polynomial at $n$ different points $x_1,x_2,..,x_n$
- Each share consists of a pair $(x_i,f(x_i))$

Reconstructing a secret
to reconstruct the secret, collect $k$ shares, and follow the Lagrange interpolation and substitute $x$ by zero. That is we reconstruct the polynomial and evaluate it at zero. The result is $f(0)$, which is $v$. If you have less than $k$ points, the constructed polynomial is wrong and you can not retrieve the secret.

[1] A. Shamir, "How to share a secret," Communications of the ACM, vol. 22, 1979, p. 612–613.
[2] Herzberg, A., Jarecki, S., Krawczyk, H., and Yung, M. 1995. Proactive Secret Sharing Or: How to Cope With Perpetual Leakage. In Proceedings of the 15th Annual international Cryptology Conference on Advances in Cryptology (August 27 - 31, 1995). D. Coppersmith, Ed. Lecture Notes In Computer Science, vol. 963. Springer-Verlag, London, 339-352.

Originally posted to http://fci-h.blogspot.com/. This is just an automatically forwarded copy. (To read the Latex-typeset mathematics correctly, please visit the original post).

.. more.

Replication Error "SQL Server is unable to connect to server.."

If you're working in SQL Server Replication, you may get this message
SQL Server is unable to connect to server 'Your server name'.

SQL Server replication requires the actual server name to make a connection to the server. Connections through a server alias, IP address, or any other alternate name are not supported. Specify the actual server name, 'Another server name'. (Replication.Utilities)



It always appears as you change the instance name manually or network administrators change the computer name.

Actually your server name still as it's and not changed with above changes so to avoid getting this message you should write these couple of T-SQL scripts every time you do one or all changes on the instance name

SELECT @@SERVERNAME -- you'll get a strange name, you may didn't see it before...
GO
sp_dropserver 'Old server name' -- you got it from pervious select.
GO
sp_addserver 'SQL server instance name','local' -- the name of current instance.
GO
Then, restart the service, and go on you replication work...

.. more.

Sunday, February 14, 2010

Ultimus: JFG can't return with workaround

With Ultimus you have a flexibility to "submit" or "return" any step using Ultimus APIs (EIK) whatever the recipient of that step expect the "Job Function Group" (JFG) and "Group" as it fails in the "return" because the JFG contains more than one user and this is my problem.

I need to return from a step with recipient type JFG have more than one user using EIK.
Note: submitting the step with condition to return back to the previous step is not a solution as I need to keep the status of the returned step as returned.

After asking Ultimus support about this issue they answered me that as per Ultimus BPM Studio Documentation, Page 175:
Any step with multiple recipients from a group or dynamic group cannot
return the task and this is a design behavior.

So I came up with workaround to solve this behavior that allow you to return a step one level back and keep the status of the returned step as returned even the recipient type was JFG.

Assume this case study:
you have two steps one for "officer" who collect some data and then pass this step to "manager" who review the officer's data then submit his task, both steps(Officer & Manager)have "Job Function Group" as a "Recipient Type".

If your business needs is to return the task from manager to officer again if the manager have some comments and needs changes in the officer's data so the problem will come here as the task can't be returned because it's JFG.

To solve this problem you can follow me pattern with fake or dummy step as in the following picture.

1-When the Officer submit the step then he will activate two step Not only the manager step but also the fake(Dummy) step.
2-the straight forward scenario is that the manager will submit the task and raise a flag so the Complete Event of the step will fire as the following:

  • The flag will foreword the manager to the junction step to go throw the normal path.
  • The flag will abort the fake step.

3-if the decision of manager was return to officer then:

  • The manager will submit the step with no valid condition so the submition will do nothing than make the step as not active.
  • Using EIK you can get the fake step by Ultimus Filter and call the Return function so it will return it in the officer step with returned status and that is what we already need to do.

.. more.

Saturday, February 13, 2010

Homomorphic Encryption

We will talk in this post about a very useful cryptographic tool. But lets talk first about the motivation or the problem it solves first.

As the first example, we will introduce the private voting problem:
We want to make an online voting application, no one can know what anyone else has voted (not ever the server itself), but at the end, we will know how many votes each candidate has received. The problem is even harder if there is no "central" trusted server and it is a distributed system which all nodes interact with all others and no one can trust anyone else.

Now, lets introduce homomorphic encryption. Homomorphic encryption, is an encryption system which allows you to do calculations on the encrypted data, without knowing the original text. At the end you will get the encryption of the result, not the result itself.

Caution: the notation used is simplified and there are some details that are not mentioned in order to simplify the presentation.

To make it more elaborate, assume $a, b$ are plain texts, and $E(a), E(b)$, are their encryption. If the encryption system you are using allows for addition, you can then call $Add(E(a),E(b))$ and you will get $E(a+b)$.

Ok, so how can this help us in our voting problem ? We will describe the protocol to show how. There is a node which will start the voting, it is the only node that can decrypt values. He will send his vote $v_1$, either 0 or 1, encrypted to the the next node. The next node will take the encrypted vote and adds his encrypted vote, either 0 or 1, and forwards it to the next one, and so forth, in a ring-like fashion, until it reaches the first node again. The first node will then decrypt and will find the sum of the votes for the first candidate. This is repeated for each candidate.

Homomorphic encryption has a lot more applications, and is more sophisticated that the simplified version mentioned here. For example, it usually has "semantic" security, which means that it is a probabilistic encryption, which means that every time you encrypt the same value, you will get a different cipher text. That is, if two people sent you $E(1)$, you will not be able to know it is the same value just by looking at the cipher text alone. Also, there are encryption schemes that only allows for addition, and others that only allow for multiplication. There is one that allows for addition and only one multiplication. Those who supports unlimited number of addition and multiplication are called "algebraic homomorphic encryption", or "fully homomorphic". So far, fully homomorphic schemes incur very big overhead for practical purposes.

Note that homomorphic properties are usually intended in a cipher. If a cipher had these properties and it was not intended, it is called "malleable" encryption and it is considered a flaw instead. Remarkable homomorphic cryptosystem are RSA, ElGamal, and Paillier.

Note also that these schemes are also asymmetric. So anyone with public key can encrypt a value, but can not decrypt it except with a public key.

References:
- Pascal Paillier: Public-Key Cryptosystems Based on Composite Degree Residuosity Classes. EUROCRYPT 1999:223-238

- http://en.wikipedia.org/wiki/Homomorphic_encryption


Author: Mohammad Alaggan

.. more.

Wednesday, February 03, 2010

Automated build for ATG, Ant or Maven ??

If you are not working with ATG, then, this article will be a waste of time, this article is for those guys working - or in other words suffering - with ATG. The case is you want to automate the build of ATG projects which are not following most of the JEE standards, they are using their own methodology which is not bad, but somehow weird. This article is to discuss whether it is better to use Ant or Maven for the build process of ATG projects.
------------
You can read about Ant here and Maven here.
------------

Well, maven is great tool indeed and i pesonally like it, unlike Ant, maven has knowledge about the whole project and handles alot of work in a declarative way, you just tell maven to compile the project and it compiles it without any configuration, this is due to its knowledge about the project, on the other side, Ant only knows about the build process, you define targets using XML script and define their sequence of execution, each target in an Ant build script does not know about other targets, it executes what you tell it to execute and nothing more, for example; to compile a project using Ant you need to define a compile target and tell it the classpath to use and where to place the .class files. Orginially, Ant did not support any dependency management technique, however, now Ant have a powerfull extension named Ivy which eanbles Ant to resolve project dependcies using maven's way, however, this does not change the main Ant concept of separate targets who do not know anyhing about each other, ivy enables you to tell it what artifacts (jars) you want and is gets it from a repository and places it in a directory.

It is very clear that maven is more advanced, more smart than Ant, but, for ATG projects the story is somehow different, the minimum build process for JEE application is as follows:

1- Checkout code.
2- Compile.
3- Test.
4- Package and deploy.

Maven and Ant works the same for ATG projects for the first step. Starting from the second step we see that to work with maven you need to add your project's artifacts to a repository and configure maven to look up that repository. To package an ATG project - (step 4) - you need ATG to be installed on the build machine to assemble (package) the project, this indicates that the needed artifacts are surely on the same machine you are working on, so the need of a repository is vanished. Why defining a repository while i know that the needed jars are on the build machine for sure. Here, Ant is more flexible and logic to use, you will just define the place of the jars and that's it, you can do this with maven, but you will end up loosing the power of it.

That packaging step makes maven loose its leverage over the prject even more, as in ATG projects the packaging will be done by making maven execute a shell command to run the assembler which is not what maven understands. The generated EAR will be totally outside the scope of maven and to deploy it you will execute another shell command to copy it to the desired location and loosing again the deploy feature of maven. Here also, the build process shows to be more likely an Ant style build.

Testing ATG modules is the most painful, all ATG developers knows the amount of hassle to unit test ATG modules, it is not as direct as spring. In  this step neither Ant or Maven have power points over each other it is bad all along the way and to get it done you need a lot of workarounds related to ATG.

Although you can do it with Maven, Ant is a better fit here as it is designed to handle builds that need flexibility and do not follow the normal and well known build steps.

.. more.

Wednesday, January 20, 2010

Discrete Event Simulators : Simulating Networks

----
Update:
I've been told that this article doesn't present *why* we need discrete event simulators, or what is the problem solved by them.
The problem is, for one example, consider you are developing a peer to peer program, like bittorrent, and you want to try it to see how good it works when 1000 users run it. You can get 1000 of your friends and they'd start the program and there you go (Or use PlanetLab). However if there were a bug, you'd be completely lost how to debug it. Discrete event simulators, "simulate" that there is 1000 users (or more, if you want) on your machine. More than that, they are all in the same "process/thread". So it boils down to a single-threaded application that is so much easier to debug.
Another example is to test a network protocol for example (see NS-2 simulator). You want to modify the "IP" protocol and want to simulate a network of hosts and routers and switches instead of implementing it on the hardware level and testing it in real life. That's what discrete event simulators are useful for.
----

If you are familiar with windows event loop of event-driven applications (GUI, sockets), you know that pretty much applications can be defined in terms of events. We consider here network applications which are mostly defined by a "receive-message" event.

You write your network application and depend on a receive event as a black box to receive messages (ref: Apache Mina). Imagine now we have the same application but we just replaced that black box, instead of the OS socket APIs, we replaced it with a discrete event simulator of the same exact interface.

That interface is just the function send(msg) and a callback function that you provide called receive(msg).

Instead of having the sender and receiver on different machines, they both will be on the same machine and in the same application (it's a "simulation", you want to test them as "if" they were on a real network).

The first application calls send() unsuspectingly, and then the discrete event simulator instead of calling OS APIs to send it on the network card, he just creates a corresponding reception event in the second (receiving) application. And then the second application gets a callback that he has got a message from the first application.

This view is simplified a little bit. We want to model network delay and bandwidth constraints, especially if we are going to simulate3000 peers of bit-torrent for example. There is ns-2, which simulates these metrics using a complete IP stack implementation (IP/TCP). It splits messages into packets, and simulates routers and so . NS-2 is used to test real protocols like WiFi and routing algorithms. However its over head is unacceptable if we want to consider a peer to peer network of 1000 peers (running on the same machine).

Some approaches like peersim, models delay as a random function and not bandwidth. However there are other approaches like MyP2PWorld[1] that models bandwidth but obtains efficiency from approximating the bandwidth constraints on the "message" level not the packet level.

Most discrete event simulators are not designed to test a deployable system and requires implementation using it's own interfaces and tools and then you transform that into a real application. MyP2PWorld[1] was designed to adapt the Apache Mina interface (used in real application). So you can write you own deployable peer to peer application using Apache Mina (event-driven networking), and with a flip of a boolean variable, you test it on a discrete event simulator. So your code you use in simulation is the same code used in deployment.

References:
[1] Roberto Roverso, Mohammed Al-Aggan, Amgad Naiem, Andreas Dahlstrom, Sameh El-Ansary, Mohammed El-Beltagy, Seif Haridi: MyP2PWorld: Highly Reproducible Application-Level Emulation of P2P Systems. SASO Workshops 2008:272-277

.. more.