Class Anonymizer

java.lang.Object
overit.geocall.basic.anonymizer.Anonymizer
All Implemented Interfaces:
Identified

public class Anonymizer extends Object implements Identified
Use this class to anonymize the informations contained into a map, in order to make impossible to link those information to a specific identity. Tipically the map that you will pass will contains the row obtained by an AUSER query. You must forcibly set the context before start to invoke the methods of this class otherwise nothing will happens. Here is an exmple of usages:

 Anonymizer a = Factory.make(Anonymizer.class, this);
 a.setContext(user);

 a.forText("AUSENAME").anonymize(RandomToken.LOWERCASE) // anonymize the name with a random value
 a.forText("AUSESURNAME").setValue("unknown"); // anonymize the surname with a fixed value
 a.forLong("AUTEETA").anonymize(25, 50) // anonymyze the age whit a value between 25 and 50
 a.forDate("AUSEBIRTHDATE").anonymize(fromRange, toRange); // anonymize the birth date between a given date range
 
Every methods save the changes directly inside the context map.
  • Field Details

  • Constructor Details

    • Anonymizer

      public Anonymizer()
  • Method Details

    • getIdentity

      public Identity getIdentity()
      Description copied from interface: Identified
      Returns the Identity associated to the component
      Specified by:
      getIdentity in interface Identified
      Returns:
      The Identity of the user currently logged in the application
    • setIdentity

      public void setIdentity(Identity identity)
      Description copied from interface: Identified
      Sets the Identity to the component
      Specified by:
      setIdentity in interface Identified
      Parameters:
      identity - The Identity that must be associated to the component
    • setContext

      public void setContext(HashGetter context)
      Set the context whose data that will be used during the anonymisation process.
      Parameters:
      context - instance of the HashGetter containing the entry that will be anonymized.
    • forText

      public Anonymizer.TextAnonymizer forText(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the string value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains a String value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forEmail

      public Anonymizer.EmailAnonymizer forEmail(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the string value of the field indicated as parameter. The field must contains a valid email, otherwise nothing will happens.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains a valid email value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forPhone

      public Anonymizer.PhoneAnonymizer forPhone(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the value of the field indicated as parameter. The field must contains a valid phone, otherwise nothing will happens.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains a valid phone value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forInteger

      public Anonymizer.IntegerAnonymizer forInteger(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the integer value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains an integer value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forLong

      public Anonymizer.LongAnonymizer forLong(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the long value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains an long value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forDouble

      public Anonymizer.DoubleAnonymizer forDouble(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the double value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains an double value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forDate

      public Anonymizer.DateAnonymizer forDate(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the date value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains an date value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forTime

      public Anonymizer.TimeAnonymizer forTime(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the time value of the field indicated as parameter.
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains a Date instance. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forCoordinate

      public Anonymizer.CoordinatesAnonymizer forCoordinate(String latitudeField, String longitudeField)
      Use this method to get the reference of the anonymizer that contains the methods you can use to obfuscate the geographical coordinates defined by the values contained into the two input parameters.
      Parameters:
      latitudeField - string containing the name of the field that will be anonymized. The value ot the field must contains a valid latitude value (a double number included between -90° and +90°) expressed in decimal degrees. Null value will throws an exception.
      longitudeField - string containing the name of the field that will be anonymized. The value ot the field must contains a valid longitude value (a double number included between -180° and +180°) expressed in decimal degrees. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.
    • forItalianFiscalCode

      public Anonymizer.ItalianFiscalCodeAnonymizer forItalianFiscalCode(String field)
      Use this method to get the reference of the anonymizer that contains the methods you can use to generate the user's fiscal code (in the italian format).
      Parameters:
      field - string containing the name of the field that will be anonymized. The value ot the field must contains an String value. Null value will throws an exception.
      Returns:
      the instance of the anonymizer that you can use to obfuscate the field's value.