File sharing is one of the most popular applications in peer-to-peer networks where there is no control over what the peer can download or upload. This explains why file sharing got a high percentage of the overall internet traffic. Although file sharing is a legal technology, many users use it to share copyrighted materials and that's why many applications have been sued and shut down.
In this thesis we will build a secure and legal file sharing system using Java bindings of JXTA protocols. The application security is derived from using digital certificates signed by a server peer who acts like a certificate authority (CA), all communications are encrypted using these digital certificates. The legal side is derived from the fact that each peer has a tokens account that will be updated and signed by the server peer only. The downloading peer has to pay some tokens for downloading a file to the uploading peer who then contacts the server peer to credit its commission from that payment. The server peer is the only one who can cash those payments to make the system forgery protected. The interaction between peers and the server peer could be on monthly basis so peers can download and upload files easliy and without the presence of the server. At the end we analyzed the security aspects and show how the implementation deals with most known peer-to-peer threats.