The backend of Amnesia is implemented in Java using the Spring framework. Its components offer a ReST API that handles anonymization requests issued by the web interface. It uses a temporary local storage for the anonymization purposes and final results are returned by the ReST interface. There are three ways to communicate with Amnesia’s backend procedures:
Visit Amnesia’s online version (https://amnesia.openaire.eu/amnesia/) provided only for test purposes for small datasets and hierarchies. To anonymize your private data, we recommend you use the following two options.
Run Amnesia’s application and execute the web request on localhost (port 8181) or in case you want to prevent GUI execution just run via terminal in Amnesia's folder, java -Xms1024m -Xmx4096m -Dorg.eclipse.jetty.server.Request.maxFormKeys=1000000 -Dorg.eclipse.jetty.server.Request.maxFormContentSize=1000000 -jar amnesiaBackEnd-1.0-SNAPSHOT.jar --server.port=8181
Clone Amnesia’s repository from Github.
To successfully build the Amnesia engine follow these steps:
All the examples below are harmonized with the last two methods on localhost using datasets and hierarchies provided in https://amnesia.openaire.eu/Datasets.zip
getSession [POST]
Web services require a field called “Session” as an argument. “Session” is the HTTP session(Cookie) of the user, which is called JSESSIONID. This call returns the JSESSIONID of the user, in order to use it.
Example via Terminal:
# /getSession [POST]
$ curl -X POST http://localhost:8181/getSession
> {"Status":"Success","Session_Id":"D6DF59C4A03432B79BC61961F1671EDB"}
loadData [POST]
Examples via Terminal:
# /loadData [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/loadData
--form file=@"/path/to/Datasets/Scenarios/Simple Table-Disk based simple table/data1/newData.txt"
--form del=,
--form datasetType=tabular --form columnsType="{\"zipcode\":\"int\",\"age\":\"int\",\"gender\":\"string\",\"salary\":\"int\"}"
{"Status":"Success","Message":"Dataset loaded successfully!"}
Sets of Values (set)
Amnesia handles “Procedure Codes”, which is a set column, as a string column.
# /loadData [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/loadData
--form file=@"/path/to/Datasets/Scenarios/Sets of Values/data1/setNumbers.csv"
--form del="|"
--form datasetType=set
--form columnsType="{\"Procedure Codes\": \"set\"}"
> {"Status":"Success","Message":"Dataset loaded successfully!"}
Table with a set-valued attribute (RelSet)
Amnesia handles “Procedure Codes”, which is a set column, as a string column
# /loadData [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/loadData
--form file=@"/path/to/Datasets/Scenarios/Table with a set-valued attribute/data1/mixedDataSet.csv"
--form del=,
--form delSet="|"
--form datasetType=RelSet
--form columnsType="{\"Procedure Codes\": \"set\", \"salary\":\"int\", \"age\":\"int\", \"date\":\"date\"}"
> {"Status":"Success","Message":"Dataset loaded successfully!"}
# /loadData [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8084/amnesia/loadData
--form file=@"/path/to/Datasets/Scenarios/Simple Table-Disk based simple table/data1/newData.txt"
--form del=,
--form datasetType=Disk
--form columnsType="{\"zipcode\":\"int\",\"age\":\"int\",\"gender\":\"string\",\"salary\":\"int\"}"
{"Status":"Success","Message":"Dataset loaded successfully!"}
generateHierarchy [POST]
Hierarchy autogeneration requires loading the dataset initially to find the appropriate values in a specific column to generate a new hierarchy. In the examples below, we consider that the mixedDataSet.csv dataset (Table with a set-valued attribute) has been loaded.
hierType is range and varType is {int or double}
The parameters above declare the domain range e.g. 1-100
Example via Terminal:
# /generateHierarchy [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/generateHierarchy
--form hierType=range
--form varType=int
--form attribute=age
--form hierName=age_hier
--form startLimit=1
--form endLimit=100
--form fanout=3
--form step=5
--out ./range_hier_age.txt
The hierarchy is stored in the “range_hier_age.txt” text file
hierType is range and varType is date
startYear: int
endYear: int The parameters above declare the domain range in term of years e.g. 1945-2016
years: Range step in term of years e.g. 5 years
months: Range step in term of months e.g. 2 months
days: Range step in term of days e.g. 7 days
fanout: Number of children of each node (int)
Example via Terminal:
# /generateHierarchy [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/generateHierarchy
--form hierType=range
--form varType=date
--form attribute=date
--form hierName=date_hier
--form startYear=1940
--form endYear=2016
--form years=5
--form months=6
--form days=7
--form fanout=3
--out ./range_hier_date.txt
The hierarchy is stored in the “range_hier_date.txt” text file.
Example via Terminal:
# /generateHierarchy [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/generateHierarchy
--form hierType=distinct
--form varType=string
--form attribute="Procedure Codes"
--form hierName=codes_hier
--form sorting=alphabetical
--form fanout=3
--out ./hier_p_codes.txt
The hierarchy is stored in the “hier_p_codes.txt” text file.
Example via Terminal:
# /generateHierarchy [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/generateHierarchy
--form hierType=mask
--form varType=string
--form attribute="Procedure Codes"
--form hierName=codes_hier
--form length=3
--out ./mask_hier_p_codes.txt
The hierarchy is stored in the “mask_hier_p_codes.txt” text file.
Example via Terminal:
# /generateHierarchy [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/generateHierarchy
--form hierType=distinct
--form varType=int
--form attribute=salary
--form hierName=salary_hier
--form sorting=numeric
--form fanout=3
--out ./distinct_hier_salary.txt
The hierarchy was saved in the “distinct_hier_salary.txt” text file.
loadHierarchies [POST]
Example via Terminal:
# /loadHierarchies [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/loadHierarchies
--form hierarchies=@"path/to/Datasets/Scenarios/Simple Table-Disk based simple table/data1/distinct_hier_salary.txt"
--form hierarchies=@"path/to/Datasets/Scenarios/Simple Table-Disk based simple table/data1/distinct_hier_age.txt"
> {"Status":"Success","Message":"Hierarchies have been successfully loaded!"}
anonymization [POST]
Returns a json string of possible solutions if the executed algorithm is Flash (simple table dataset) e.g. {sol1:{[1,1], unsafe},sol2:{[1,2], safe}} or the anonymized dataset.
Example via Terminal for simple table dataset:
# /anonymization [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/anonymization
--form bind="{\"age\":\"age\",\"salary\":\"salary\"}"
--form k=3
> {"Solutions":{
> "sol5":{"result":"safe","levels":"[0, 2]"},
> "sol4":{"result":"unsafe","levels":"[1, 1]"},
> "sol7":{"result":"safe","levels":"[1, 2]"},
> "sol6":{"result":"safe","levels":"[2, 1]"},
> "sol1":{"result":"unsafe","levels":"[1, 0]"},
> "sol0":{"result":"unsafe","levels":"[0, 0]"},
> "sol3":{"result":"safe","levels":"[2, 0]"},
> "sol2":{"result":"unsafe","levels":"[0, 1]"},
> "sol8":{"result":"safe","levels":"[2, 2]"}
> }}
Example via Terminal for table with with a set-valued attribute:
# /anonymization [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/anonymization
--form bind="{\"age\":\"age\",\"salary\":\"salary\", \"Procedure Codes\": \"myNumHier\" }"
--form k=3
--form m=2
--out ./anonymized_mixedData.csv
The anonymized data are stored in “anonymized_mixedData.csv” file
getAnonRules [POST]
The current endpoint is not supported for disk-based data (Disk based simple table) because the algorithm is executed using clustering and similarities that do not generate anonymization rules.
Examples via Terminal for simple table data:
# /getAnonRules [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getAnonRules
--form sol="[1,2]"
--form suppressed=true
> {"Status":"Fail","Message":"The solution [1,2] satisfies 3-anonymity so it can not be suppressed!"}
# /getAnonRules [POST]
curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getAnonRules
--form sol="[1,2]"
--form suppressed=false
--out ./anonRules.txt
The anonymized rules are stored in the “anonRules.txt” file.
Example via Terminal for table with with a set-valued attribute:
# /getAnonRules [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getAnonRules
--out ./anonRules_mixed.txt
The anonymized rules are stored in the “anonRules_mixed.txt” file.
loadAnonRules [POST]
We suppose that a simple table dataset has already been imported to Amnesia, and we have exported the anonymization rules in the “anonRules.txt” as in the previous example.
# /loadAnonRules [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/loadAnonRules
--form rules="path/to/anonRules.txt"
--out ./apply_rules.txt
The dataset which was produced from the anonymization rules is stored in the “apply_rules.txt” file.
clearSession [POST]
Example via Terminal:
# /clearSession [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/clearSession
> {"Status":"Success","Message":"Session is cleared!"}
getSolution [POST]
Example via Terminal:
# /getSolution [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getSolution
--form sol="[1,2]"
--out ./anonymized_simple_table_data.txt
The anonymized dataset is stored in the “anonymized_simple_table_data.txt” text file.
getSuppressPercentage [POST]
Examples via Terminal:
# /getSuppressPercentage [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getSuppressPercentage
--form sol="[1,2]"
> {"Status":"Success","percentageSuppress":0.0,"Message":"The solution: [1,2] satisfies k=3 anonymity","k":3}
For unsafe solution e.g. [1,1]
# /getSuppressPercentage [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getSuppressPercentage
--form sol="[1,1]"
> {"Status":"Success","percentageSuppress":0.3,"Message":"To produce a k=3 anonymity solution, it must be suppressed by 0.3%","k":3}
getSuppressedSolution [POST]
Examples via Terminal:
# /getSuppressedSolution [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getSuppressedSolution --form sol="[1,2]"
> {"Status":"Fail","Message":"The solution [1,2] satisfies 3-anonymity so > it can not be suppressed!"}
For unsafe solution e.g. [1,1]
# /getSuppressedSolution [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getSuppressedSolution
--form sol="[1,1]"
--out ./anonymized_suppressed_dataset.txt
The suppressed anonymized dataset is stored in the “anonymized_suppressed_dataset.txt” text file.
getStatistics [POST]
Examples via Terminal:
# /getStatistics [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getStatistics
--form sol="[1,2]"
--form quasi_ids=age
{"Status":"Success", "AnonymizedStats":[ {"numberOfValues":"142","value":"[102]"}, {"numberOfValues":"134","value":"[101]"}, {"numberOfValues":"131","value":"[105]"}, {"numberOfValues":"122","value":"[103]"}, {"numberOfValues":"119","value":"[107]"}, {"numberOfValues":"110","value":"[108]"}, {"numberOfValues":"104","value":"[106]"}, {"numberOfValues":"103","value":"[104]"}, {"numberOfValues":"34","value":"[109]"}, {"numberOfValues":"0","value":"problematic records"}, {"numberOfValues":"0","value":"Records with support less than 3%"}], "TotalRecords":999, "k":3}
# /getStatistics [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getStatistics --form sol="[1,2]" --form quasi_ids=salary
{"Status":"Success", "AnonymizedStats":[ {"numberOfValues":"999","value":"[10011]"}, {"numberOfValues":"0","value":"problematic records"}, {"numberOfValues":"0","value":"Records with support less than 100%"}], "TotalRecords":999, "k":3}
# /getStatistics [POST]
$ curl -X POST -H "Cookie: JSESSIONID=D6DF59C4A03432B79BC61961F1671EDB" http://localhost:8181/getStatistics
--form sol="[1,2]"
--form quasi_ids=age
--form quasi_ids=salary
{"Status":"Success", "AnonymizedStats":[ {"numberOfValues":"142","value":"[102, 10011]"}, {"numberOfValues":"134","value":"[101, 10011]"}, {"numberOfValues":"131","value":"[105, 10011]"}, {"numberOfValues":"122","value":"[103, 10011]"}, {"numberOfValues":"119","value":"[107, 10011]"}, {"numberOfValues":"110","value":"[108, 10011]"}, {"numberOfValues":"104","value":"[106, 10011]"}, {"numberOfValues":"103","value":"[104, 10011]"}, {"numberOfValues":"34","value":"[109, 10011]"}, {"numberOfValues":"0","value":"problematic records"}, {"numberOfValues":"0","value":"Records with support less than 3%"}], "TotalRecords":999, "k":3}
version 1.3.3 (release date: 25/09/2023)
version 1.3.2
version 1.3.1
version 1.3.0
version 1.2.9
Privacy guarantees with demographic statistics.
Support for anonymization of DICOM files.
version 1.2.8
Better interface for pseudo-anonymization.
Support for user-defined masking rules.
Added error messages on loading dataset
Removed openjfx java library.
Bug fixed on loading Dataverse data.
version 1.2.7.2
version 1.2.7.1
version 1.2.7
Integration with the dataverse project.
Bug fixed in zenodo inegration.
version 1.2.6
ReST API upgrade.
Bug fixed in string hierarchy.
Bugs fixed in anonymization rules
version 1.2.5
Cleaning non-printable characters
Keep 128 characters from the titles of columns
Cleaning titles of columns from undesired characters
version 1.2.4
Bug fixed in masking based autogeneration hierarchy
Resolved front-end issues
Bug fixed in suppression
Bug fixed in statistics
version 1.2.3
New feature, autogeneration masking based hierarchy for strings
Fixed bug in date formatting
Fixed bug in dataset loading
version: 1.2.2
Increased upload file size
Bugs fixed in hierarchy section
Bug fixed in date values localization
version: 1.2.1
Optimized clustering disk based algorithm.
Better handling for "(null)" hierarchy node for unspecified values e.g. empty cells.
Bug fixed in km-anonymity algorithm.
Bug fixed in online version.
Bug fixed for non-english character set.
Bug fixed for parsing dates with specific localization.
version: 1.2.0
Checked values existence in hierarchy tree.
Fixed bug on Safari browser.
Fixed bugs on hierarchy's operations (add, edit, delete).
Fixed bug on suppression functionality.
Better handling of the empty cells for range type of hierarchy.
Fixed bug for windows OS related on java version.
New clustering disk based algorithm.
Set limits on dataset's records and on hierarchy's nodes for on-line version.
Faster loading of date values in dataset.
Fixed bug for decimal values with comma.
Changed loading data-types.
Fixed bug on rage date type with the same bounds.
version: 1.1.1
Increased the Java heap size.
Fixed a bug causing crushed in the windows' version of Amnesia.
The on-line version of Amnesia is restricted to 3 minutes of processing time per anonymization task.
Fixed bug with character encoding on several Linux distributions.
version: 1.1.0
New algorithm for Object-relational dataset (combination between relational dataset and set-valued dataset).
Update error handling.
Bugs fixed in hierarchy editing.
Hierarchy removing.
Bugs fixed when the results are appeared.
version: 1.0.7
Updated interface.
Several bugs fixed.
version: 1.0.6
Template implementation via terminal.
Template implementation via rest service.
version: 1.0.5
Date hierarchy editing.
Updated interface.
Several bugs fixed.
version: 1.0.4
Wizard for numeric ranges has been updated.
Upgraded scalability capabilities (Bigger files, can now be uploaded).
version: 1.0.3
Bugs fixed in suppressing and km-anonymity algorithm.
Changes in text descriptions.
version: 1.0.2
version: 1.0.1
Better interface in pie graph.
Changes in suppressing.
Hierarchy editing.
Bugs fixed.
version: 1.0.0