Annotation Interface Sensitive


@Retention(RUNTIME) @Target(FIELD) public @interface Sensitive
This annotation is used to mark string attributes that contain sensitive information and should be masked when output to a log file, and encrypted when stored in a database.
Author:
Yan Ma
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The masking pattern that should be applied to the value of the annotated attribute.
    The type of sensitive attribute.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    char
    The character that should be used to mask the value of the annotated attribute.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Mask for a credit card number: dddd-XXXX-XXXX-dddd
    static final String
    Mask for a email address.
    static final String
    Mask for a password or alphanumeric pin with various lengths (min length = 4, max length = 100): mask all characters
    static final String
    Mask for a phone number: XXX-XXX-dddd leave the last four digits unmasked
    static final String
    MASK for a SSN: XXX-XX-dddd leave the last four digits unmasked
  • Field Details

    • MASK_PASSWORD

      static final String MASK_PASSWORD
      Mask for a password or alphanumeric pin with various lengths (min length = 4, max length = 100): mask all characters
      See Also:
    • MASK_EMAIL_ADDRESS

      static final String MASK_EMAIL_ADDRESS
      Mask for a email address. Masks every character before @
      See Also:
    • MASK_PHONE_NUMBER

      static final String MASK_PHONE_NUMBER
      Mask for a phone number: XXX-XXX-dddd leave the last four digits unmasked
      See Also:
    • MASK_CREDIT_CARD_NUMBER

      static final String MASK_CREDIT_CARD_NUMBER
      Mask for a credit card number: dddd-XXXX-XXXX-dddd
      See Also:
    • MASK_SSN

      static final String MASK_SSN
      MASK for a SSN: XXX-XX-dddd leave the last four digits unmasked
      See Also:
  • Element Details

    • type

      String type
      The type of sensitive attribute. This may be needed to determine how to encrypt/decrypt the sensitive information.
      Returns:
      The attribute type
    • mask

      String mask
      The masking pattern that should be applied to the value of the annotated attribute. The pattern is a regular expression that contains "(" and ")" surrounding the parts of the string that should be masked with "X"s.
      Returns:
      The masking pattern.
    • character

      char character
      The character that should be used to mask the value of the annotated attribute. The default character is 'X'.
      Returns:
      The masking character.
      Default:
      'X'