API - prasadtalasila/BITS-Darshini GitHub Wiki
#About This page lays out the API developed to achieve RESTful communication between front-end (client in browser) and back-end (java classes in server). Spring controllers are developed in the backend to interact with the models which interact with other java classes and database. These controllers respond to specific ajax request from the client side with specific URLs. All such APIs are listed below -
Home - "/"
This is the first view for the application. The specific controller sensitive to this URL returns the index.html file. This view prompts the user to log in to the application.
Login - "/signup"
RequestBody - JSON object {email : String ; password : String}
ResponseBody - JSON object {status : String}
Email and passwords entered by user are wrapped in an JSON object and sent as request-body. Corresponding credentials (or to be more specific, their hashes) are created in the server. If the credentials are unique and email is not already taken, then status is set success otherwise failure.
Login - "/signin"
RequestBody - JSON object {email : String ; password : String}
ResponseBody - JSON object {status : String ; loginHash : String}
Email and passwords entered by user are wrapped in an JSON object and sent as request-body. Corresponding credentials (or to be more specific, their hashes) are checked against database in the server. If the credentials are valid then status is set success otherwise failure. If the status is set as success then server also sends back a loginHash which is a SHA-256 hash whose significance is known only to server. This hash is stored in Cookies for that browser-window and serves as the status of logged in. When this hash is cleared from Cookies, user is considered logged out of the application.
Protocol Graph Validation - "/session/validate"
RequestBody - JSON object {experimentId : int ; graph : JSON object}
ResponseBody - JSON object {experimentId : int ; session : Session ; validationStatus : boolean ; validationRemark : String}
This AJAX request is to validate the protocol graph made by user by drag-dropping and connecting various protocol objects. This graph, if valid will be used in configuring Analyzer cell linkages. The structure of this JSON object will be as follows -
{fromProtocol : toProtocol ; fromProtocol : toProtocol ; ..}
where each key/value is the string identifying protcol object being drag-dropped in the UI. Each key value pair represents one edge in the graph.
This graph object is parsed in the server. If there is any misconfigured edge/node then validationStatus is set as false and corresponding error message is set in validationRemark in the ResponseBody. In this case, session object will be null.
If the graph is validated, then a session will be created with corresponding cells configured and linked with each other. This session object will be set in ResponseBody along with corresponding validationStatus and validationRemark.
Pcap File Analysis - "/session/analyze"
RequestBody - JSON object (Same as that of ResponseBody for /validate API)
ResponseBody - JSON object {packetCount : long ; analysisStatus : boolean}
The purpose of of using the same JSON object in the RequestBody as that of return by /validate API is to obtain the Session object constructed after validation. This object contains all the pipeline configuration. Session object will kickstart the pcap file reading and subsequent analysis process by starting new threads and synchronizing them etc. As soon as pcap file reading is finished, total number of packets read count will be returned. In almost every case, reading finishes faster than analysis and hence analysisStatus is set as false.