Class ScrambleAttributeTransformation

    • Constructor Summary

      Constructors 
      Constructor Description
      ScrambleAttributeTransformation​(Schema schema, java.lang.Long randomSeed, boolean scrambleEntryDNs, java.util.Collection<java.lang.String> attributes, java.util.Collection<java.lang.String> jsonFields)
      Creates a new scramble attribute transformation that will scramble the values of a specified set of attributes.
      ScrambleAttributeTransformation​(Schema schema, java.lang.Long randomSeed, java.lang.String... attributes)
      Creates a new scramble attribute transformation that will scramble the values of a specified set of attributes.
      ScrambleAttributeTransformation​(java.lang.String... attributes)
      Creates a new scramble attribute transformation that will scramble the values of the specified attributes.
      ScrambleAttributeTransformation​(java.util.Collection<java.lang.String> attributes)
      Creates a new scramble attribute transformation that will scramble the values of the specified attributes.
    • Constructor Detail

      • ScrambleAttributeTransformation

        public ScrambleAttributeTransformation​(java.lang.String... attributes)
        Creates a new scramble attribute transformation that will scramble the values of the specified attributes. A default standard schema will be used, entry DNs will not be scrambled, and if any of the target attributes have values that are JSON objects, the values of all of those objects' fields will be scrambled.
        Parameters:
        attributes - The names or OIDs of the attributes to scramble.
      • ScrambleAttributeTransformation

        public ScrambleAttributeTransformation​(java.util.Collection<java.lang.String> attributes)
        Creates a new scramble attribute transformation that will scramble the values of the specified attributes. A default standard schema will be used, entry DNs will not be scrambled, and if any of the target attributes have values that are JSON objects, the values of all of those objects' fields will be scrambled.
        Parameters:
        attributes - The names or OIDs of the attributes to scramble.
      • ScrambleAttributeTransformation

        public ScrambleAttributeTransformation​(Schema schema,
                                               java.lang.Long randomSeed,
                                               java.lang.String... attributes)
        Creates a new scramble attribute transformation that will scramble the values of a specified set of attributes. Entry DNs will not be scrambled, and if any of the target attributes have values that are JSON objects, the values of all of those objects' fields will be scrambled.
        Parameters:
        schema - The schema to use when processing. This may be null if a default standard schema should be used. The schema will be used to identify alternate names that may be used to reference the attributes, and to determine the expected syntax for more accurate scrambling.
        randomSeed - The seed to use for the random number generator when scrambling each value. It may be null if the random seed should be automatically selected.
        attributes - The names or OIDs of the attributes to scramble.
      • ScrambleAttributeTransformation

        public ScrambleAttributeTransformation​(Schema schema,
                                               java.lang.Long randomSeed,
                                               boolean scrambleEntryDNs,
                                               java.util.Collection<java.lang.String> attributes,
                                               java.util.Collection<java.lang.String> jsonFields)
        Creates a new scramble attribute transformation that will scramble the values of a specified set of attributes.
        Parameters:
        schema - The schema to use when processing. This may be null if a default standard schema should be used. The schema will be used to identify alternate names that may be used to reference the attributes, and to determine the expected syntax for more accurate scrambling.
        randomSeed - The seed to use for the random number generator when scrambling each value. It may be null if the random seed should be automatically selected.
        scrambleEntryDNs - Indicates whether to scramble any appropriate attributes contained in entry DNs and the values of attributes with a DN syntax.
        attributes - The names or OIDs of the attributes to scramble.
        jsonFields - The names of the JSON fields whose values should be scrambled. If any field names are specified, then any JSON objects to be scrambled will only have those fields scrambled (with field names treated in a case-insensitive manner) and all other fields will be preserved without scrambling. If this is null or empty, then scrambling will be applied for all values in all fields.
    • Method Detail

      • transformEntry

        public Entry transformEntry​(Entry e)
        Applies an appropriate transformation to the provided entry.
        Specified by:
        transformEntry in interface EntryTransformation
        Parameters:
        e - The entry to transform.
        Returns:
        A copy of the entry with any appropriate transformation applied, the original entry if no transformations were necessary, or null if the entry should be suppressed.
      • scrambleDN

        public java.lang.String scrambleDN​(java.lang.String dn)
        Creates a scrambled copy of the provided DN. If the DN contains any components with attributes to be scrambled, then the values of those attributes will be scrambled appropriately. If the DN does not contain any components with attributes to be scrambled, then no changes will be made.
        Parameters:
        dn - The DN to be scrambled.
        Returns:
        A scrambled copy of the provided DN, or the original DN if no scrambling is required or the provided string cannot be parsed as a valid DN.
      • scrambleDN

        public DN scrambleDN​(DN dn)
        Creates a scrambled copy of the provided DN. If the DN contains any components with attributes to be scrambled, then the values of those attributes will be scrambled appropriately. If the DN does not contain any components with attributes to be scrambled, then no changes will be made.
        Parameters:
        dn - The DN to be scrambled.
        Returns:
        A scrambled copy of the provided DN, or the original DN if no scrambling is required.
      • scrambleRDN

        public RDN scrambleRDN​(RDN rdn)
        Creates a scrambled copy of the provided RDN. If the RDN contains any attributes to be scrambled, then the values of those attributes will be scrambled appropriately. If the RDN does not contain any attributes to be scrambled, then no changes will be made.
        Parameters:
        rdn - The RDN to be scrambled. It must not be null.
        Returns:
        A scrambled copy of the provided RDN, or the original RDN if no scrambling is required.
      • scrambleAttribute

        public Attribute scrambleAttribute​(Attribute a)
        Creates a copy of the provided attribute with its values scrambled if appropriate.
        Parameters:
        a - The attribute to scramble.
        Returns:
        A copy of the provided attribute with its values scrambled, or the original attribute if no scrambling should be performed.
      • scrambleGeneralizedTime

        public java.lang.String scrambleGeneralizedTime​(java.lang.String s)
        Scrambles the provided generalized time value. If the provided value can be parsed as a valid generalized time, then the resulting value will be a generalized time in the same format but with the timestamp randomized. The randomly-selected time will adhere to the following constraints:
        • The range for the timestamp will be twice the size of the current time and the original timestamp. If the original timestamp is within one day of the current time, then the original range will be expanded by an additional one day.
        • If the original timestamp is in the future, then the scrambled timestamp will also be in the future. Otherwise, it will be in the past.
        Parameters:
        s - The value to scramble.
        Returns:
        The scrambled value.
      • scrambleNumericValue

        public java.lang.String scrambleNumericValue​(java.lang.String s)
        Scrambles the provided value, which is expected to be largely numeric. Only digits will be scrambled, with all other characters left intact. The first digit will be required to be nonzero unless it is also the last character of the string.
        Parameters:
        s - The value to scramble.
        Returns:
        The scrambled value.
      • scrambleBinaryValue

        public byte[] scrambleBinaryValue​(byte[] value)
        Scrambles the provided value, which may contain non-ASCII characters. The scrambling will be performed as follows:
        • Each lowercase ASCII letter will be replaced with a randomly-selected lowercase ASCII letter.
        • Each uppercase ASCII letter will be replaced with a randomly-selected uppercase ASCII letter.
        • Each ASCII digit will be replaced with a randomly-selected ASCII digit.
        • Each ASCII symbol (all printable ASCII characters not included in one of the above categories) will be replaced with a randomly-selected ASCII symbol.
        • Each ASCII control character will be replaced with a randomly-selected printable ASCII character.
        • Each non-ASCII byte will be replaced with a randomly-selected non-ASCII byte.
        Parameters:
        value - The value to scramble.
        Returns:
        The scrambled value.
      • scrambleEncodedPassword

        public java.lang.String scrambleEncodedPassword​(java.lang.String s)
        Scrambles the provided encoded password value. It is expected that it will either start with a storage scheme name in curly braces (e.g.., "{SSHA256}XrgyNdl3fid7KYdhd/Ju47KJQ5PYZqlUlyzxQ28f/QXUnNd9fupj9g==") or that it will use the authentication password syntax as described in RFC 3112 in which the scheme name is separated from the rest of the password by a dollar sign (e.g., "SHA256$QGbHtDCi1i4=$8/X7XRGaFCovC5mn7ATPDYlkVoocDD06Zy3lbD4AoO4="). In either case, the scheme name will be left unchanged but the remainder of the value will be scrambled.
        Parameters:
        s - The encoded password to scramble.
        Returns:
        The scrambled value.
      • scrambleJSONObject

        public java.lang.String scrambleJSONObject​(java.lang.String s)
        Scrambles the provided JSON object value. If the provided value can be parsed as a valid JSON object, then the resulting value will be a JSON object with all field names preserved and some or all of the field values scrambled. If this AttributeScrambler was created with a set of JSON fields, then only the values of those fields will be scrambled; otherwise, all field values will be scrambled.
        Parameters:
        s - The time value to scramble.
        Returns:
        The scrambled value.
      • scrambleString

        public java.lang.String scrambleString​(java.lang.String s)
        Scrambles the provided string. The scrambling will be performed as follows:
        • Each lowercase ASCII letter will be replaced with a randomly-selected lowercase ASCII letter.
        • Each uppercase ASCII letter will be replaced with a randomly-selected uppercase ASCII letter.
        • Each ASCII digit will be replaced with a randomly-selected ASCII digit.
        • All other characters will remain unchanged.
        Parameters:
        s - The value to scramble.
        Returns:
        The scrambled value.
      • translate

        public Entry translate​(Entry original,
                               long firstLineNumber)
        Applies some special transformation or filtering to the original Entry.
        Specified by:
        translate in interface LDIFReaderEntryTranslator
        Parameters:
        original - The original Entry that was read and parsed from the input file.
        firstLineNumber - The first line number of the LDIF record corresponding to the read Entry. This is most useful when throwing an LDIFException.
        Returns:
        The Entry that should be returned in the call to LDIFReader.readEntry(). This can be the original parameter Entry, a newly constructed Entry, or null to signal that the provided Entry should be skipped.
      • translate

        public LDIFChangeRecord translate​(LDIFChangeRecord original,
                                          long firstLineNumber)
        Applies some special transformation or filtering to the original change record.
        Specified by:
        translate in interface LDIFReaderChangeRecordTranslator
        Parameters:
        original - The original change record that was read and parsed from the input file.
        firstLineNumber - The first line number of the LDIF change record. This is most useful when throwing an LDIFException.
        Returns:
        The LDIF change record that should be returned in the call to LDIFReader.readChangeRecord(). This can be the original parameter change record, a newly constructed change record, or null to signal that the provided change record should be skipped.
      • translateEntryToWrite

        public Entry translateEntryToWrite​(Entry original)
        Applies some special transformation or filtering to the original Entry.
        Specified by:
        translateEntryToWrite in interface LDIFWriterEntryTranslator
        Parameters:
        original - The original Entry that was to be written.
        Returns:
        The Entry that should be written. This can be the original parameter Entry, a newly-constructed Entry, or null to signal that this Entry should not be written. Note, however, that if the original entry provided as a parameter is altered, then the change will be visible to anything that references that entry. If you are not sure about whether changes to the original entry are acceptable, it is recommended that you use the duplicate() method to create a copy of the original and make the necessary changes to that duplicate.
      • translateChangeRecordToWrite

        public LDIFChangeRecord translateChangeRecordToWrite​(LDIFChangeRecord original)
        Applies some special transformation or filtering to the original change record.
        Specified by:
        translateChangeRecordToWrite in interface LDIFWriterChangeRecordTranslator
        Parameters:
        original - The original change record that was to be written.
        Returns:
        The change record that should be written. This can be the original parameter change record, a newly-constructed change record, or null to signal that the change record should not be written. Note, however, that if the original record provided as a parameter is altered, then the change will be visible to anything that references that change record. If you are not sure about whether changes to the original change record are acceptable, it is recommended that you use the duplicate() method to create a copy of the original and make the necessary changes to that duplicate.