Package overit.geocall.basic.anonymizer
Class Anonymizer.EmailAnonymizer
java.lang.Object
overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer<String,Anonymizer.EmailAnonymizer>
overit.geocall.basic.anonymizer.Anonymizer.EmailAnonymizer
- Enclosing class:
Anonymizer
public class Anonymizer.EmailAnonymizer
extends Anonymizer.AbstractAnonymizer<String,Anonymizer.EmailAnonymizer>
Used to obfuscate a fields containing string values which respect the email format.
If the context doesn't contain the field assigned to this instance, all the method of this class will not change the context.
-
Field Summary
FieldsFields inherited from class overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer
_field -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a prefix to the current field's value.anonymizeDomain(String alphabet) Set a random string as domain part (the string following the @ character) of the value field assigned to this instance.anonymizeDomain(String alphabet, int size) Set a random string as domain part (the string following the @ character) of the value field assigned to this instance.anonymizeTLDomain(String... candidates) Set a random string as top level domain part (the string following the @ character) of the value field assigned to this instance.anonymizeUsername(String alphabet) Set a random string as username part (the string preceding the @ character) of the value field assigned to this instance.anonymizeUsername(String alphabet, int size) Set a random string as username part (the string preceding the @ character) of the value field assigned to this instance.protected Stringprotected String[]protected StringgetRandomString(String currentValue, String alphabet, Integer size) protected Stringprotected Stringprotected voidprotected voidsetTLDomain(String tld) protected voidsetUsername(String username) protected voidMethods inherited from class overit.geocall.basic.anonymizer.Anonymizer.AbstractAnonymizer
setValue
-
Field Details
-
_pattern
-
-
Constructor Details
-
EmailAnonymizer
-
-
Method Details
-
addPrefix
Add a prefix to the current field's value. Pay attention to call this method after the anonymize, otherwise the prefixed value will be overwritten. For example, we assume thatanonymizeUsername(RandomToken.LOWERCASE)set the value "abc@domain.com". If we call this method after the anonymize
into the context we will find the valueanonymizeUsername(RandomToken.LOWERCASE).addPrefix("UNKNOWN_")"UNKNOWN_abc@domain.com". If we call the same methods but in the reverse order
the context will be update with the valueaddPrefix("UNKNOWN_").anonymizeUsername(RandomToken.LOWERCASE)"abc@domain.com"; that's why the second method has overwritten the changes made by the first one.- Parameters:
prefix- string that will be appended before the current value- Returns:
- a reference of this object.
- Throws:
IllegalArgumentException- if the prefix contains characters not allowed by the email standard format.
-
anonymizeUsername
Set a random string as username part (the string preceding the @ character) of the value field assigned to this instance. The length of the generated string will be the same as the original username part.- Parameters:
alphabet- String containing the characters that will be used to generate the random username. Typically you can use these predefined set of alphabet:RandomToken.ALPHA_DIGIT: uppercase/lowercase letters and digitsRandomToken.ALPHA: uppercase/lowercase lettersRandomToken.LOWERCASE_DIGIT: lowercase letters and digitsRandomToken.UPPERCASE_DIGIT: uppercase letters and digitsRandomToken.LOWERCASE: lowercase lettersRandomToken.UPPERCASE: uppercase lettersRandomToken.HEX: hexadecimal letters and digitsRandomToken.DIGIT: only digits
- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if the alphabet is null or empty.IllegalArgumentException- if the alphabet contains characters not allowed by the email standard format.
-
anonymizeUsername
Set a random string as username part (the string preceding the @ character) of the value field assigned to this instance. The length of the generated string will be the same as the one specified by the size parameter.- Parameters:
alphabet- String containing the characters that will be used to generate the random username. Typically you can use these predefined set of alphabet:RandomToken.ALPHA_DIGIT: uppercase/lowercase letters and digitsRandomToken.ALPHA: uppercase/lowercase lettersRandomToken.LOWERCASE_DIGIT: lowercase letters and digitsRandomToken.UPPERCASE_DIGIT: uppercase letters and digitsRandomToken.LOWERCASE: lowercase lettersRandomToken.UPPERCASE: uppercase lettersRandomToken.HEX: hexadecimal letters and digitsRandomToken.DIGIT: only digits
size- positive number indicating length of the generated username.- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if the alphabet is null or empty, or if the size is negative.IllegalArgumentException- if the alphabet contains characters not allowed by the email standard format.
-
anonymizeDomain
Set a random string as domain part (the string following the @ character) of the value field assigned to this instance. The length of the generated string will be the same as the original domain part. Note that the domain part will not include the TOP LEVEL DOMAIN (the very last part of the email address, between the last dot character and the end of the email)- Parameters:
alphabet- String containing the characters that will be used to generate the random domain. Typically you can use these predefined set of alphabet:RandomToken.ALPHA_DIGIT: uppercase/lowercase letters and digitsRandomToken.ALPHA: uppercase/lowercase lettersRandomToken.LOWERCASE_DIGIT: lowercase letters and digitsRandomToken.UPPERCASE_DIGIT: uppercase letters and digitsRandomToken.LOWERCASE: lowercase lettersRandomToken.UPPERCASE: uppercase lettersRandomToken.HEX: hexadecimal letters and digitsRandomToken.DIGIT: only digits
- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if the alphabet is null or empty.IllegalArgumentException- if the alphabet contains characters not allowed by the email standard format.
-
anonymizeDomain
Set a random string as domain part (the string following the @ character) of the value field assigned to this instance. The length of the generated string will be the same as the one specified by the size parameter. Note that the domain part will not include the TOP LEVEL DOMAIN (the very last part of the email address, between the last dot character and the end of the email)- Parameters:
alphabet- String containing the characters that will be used to generate the random domain. Typically you can use these predefined set of alphabet:RandomToken.ALPHA_DIGIT: uppercase/lowercase letters and digitsRandomToken.ALPHA: uppercase/lowercase lettersRandomToken.LOWERCASE_DIGIT: lowercase letters and digitsRandomToken.UPPERCASE_DIGIT: uppercase letters and digitsRandomToken.LOWERCASE: lowercase lettersRandomToken.UPPERCASE: uppercase lettersRandomToken.HEX: hexadecimal letters and digitsRandomToken.DIGIT: only digits
size- positive number indicating length of the generated domain.- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if the alphabet is null or empty, or if the size is negative.IllegalArgumentException- if the alphabet contains characters not allowed by the email standard format.
-
anonymizeTLDomain
Set a random string as top level domain part (the string following the @ character) of the value field assigned to this instance. The length of the generated string will be the same as the original domain part. Note that the top level domain part is the very last part of the email address, between the last dot character and the end of the email and will not include the DOMAIN. For example, given these email addresses:- user@domain.com
- user@localhost
- user@domain.subdomain.org
- com
- localhost
- org
- Parameters:
candidates- list of the top level domains among which will be randomly chosen the one that will be replace the original.- Returns:
- a reference of this object.
- Throws:
overit.geocall.asserts.AssertsException- if the candidates is null.IllegalArgumentException- if the candidates contains characters not allowed by the email standard format.
-
getRandomString
-
getUsername
-
setUsername
-
getDomain
-
setDomain
-
getTLDomain
-
setTLDomain
-
getEmailParts
-
validate
- Overrides:
validatein classAnonymizer.AbstractAnonymizer<String,Anonymizer.EmailAnonymizer>
-