@@ -1408,8 +1408,7 @@ public static PortionBuilder portion() {
1408
1408
* A builder for obfuscators that obfuscate a specific portion of their input.
1409
1409
* An obfuscator created with {@link #keepAtStart(int) keepAtStart(x)} and {@link #keepAtEnd(int) keepAtEnd(y)} will, for input {@code s},
1410
1410
* obfuscate all characters in the range {@code x} (inclusive) to {@link CharSequence#length() s.length()}{@code - y} (exclusive).
1411
- * If this range is empty, such an obfuscator will not obfuscate anything, unless if {@link #withFixedTotalLength(int)} or
1412
- * {@link #withFixedLength(int)} is specified.
1411
+ * If this range is empty, such an obfuscator will not obfuscate anything, unless if {@link #withFixedTotalLength(int)} is specified.
1413
1412
*
1414
1413
* @author Rob Spoor
1415
1414
*/
@@ -1420,7 +1419,6 @@ public static final class PortionBuilder {
1420
1419
private int atLeastFromStart ;
1421
1420
private int atLeastFromEnd ;
1422
1421
private int fixedTotalLength ;
1423
- private int fixedObfuscatedLength ;
1424
1422
private char maskChar ;
1425
1423
1426
1424
private PortionBuilder () {
@@ -1507,23 +1505,6 @@ public PortionBuilder withFixedTotalLength(int fixedTotalLength) {
1507
1505
return this ;
1508
1506
}
1509
1507
1510
- /**
1511
- * Sets or removes the fixed number of {@link #withMaskChar(char) mask characters} to use for obfuscating.
1512
- * <p>
1513
- * This setting will be ignored if the {@link #withFixedTotalLength(int) fixed total length} is set.
1514
- *
1515
- * @param fixedObfuscatedLength The fixed number of mask characters, or a negative value to use the actual length of the input.
1516
- * The default is {@code -1}.
1517
- * @return This builder.
1518
- * @deprecated The total length of obfuscated contents can vary when using this setting, making it possible in certain cases to find the
1519
- * original value that was obfuscated. Use {@link #withFixedTotalLength(int)} instead.
1520
- */
1521
- @ Deprecated
1522
- public PortionBuilder withFixedLength (int fixedObfuscatedLength ) {
1523
- this .fixedObfuscatedLength = Math .max (-1 , fixedObfuscatedLength );
1524
- return this ;
1525
- }
1526
-
1527
1508
/**
1528
1509
* Sets the char that created obfuscators use for obfuscating.
1529
1510
*
@@ -1544,7 +1525,6 @@ public PortionBuilder withMaskChar(char maskChar) {
1544
1525
* <li>{@link #atLeastFromStart(int) atLeastFromStart(0)}</li>
1545
1526
* <li>{@link #atLeastFromEnd(int) atLeastFromEnd(0)}</li>
1546
1527
* <li>{@link #withFixedTotalLength(int) withFixedTotalLength(-1)}</li>
1547
- * <li>{@link #withFixedLength(int) withFixedLength(-1)}</li>
1548
1528
* <li>{@link #withMaskChar(char) withMaskChar('*')}</li>
1549
1529
* </ul>
1550
1530
*
@@ -1556,7 +1536,6 @@ public PortionBuilder withDefaults() {
1556
1536
atLeastFromStart (0 );
1557
1537
atLeastFromEnd (0 );
1558
1538
withFixedTotalLength (-1 );
1559
- withFixedLength (-1 );
1560
1539
withMaskChar (DEFAULT_MASK_CHAR );
1561
1540
return this ;
1562
1541
}
@@ -1593,7 +1572,6 @@ private static final class PortionObfuscator extends Obfuscator {
1593
1572
private final int atLeastFromStart ;
1594
1573
private final int atLeastFromEnd ;
1595
1574
private final int fixedTotalLength ;
1596
- private final int fixedObfuscatedLength ;
1597
1575
private final char maskChar ;
1598
1576
1599
1577
private PortionObfuscator (PortionBuilder builder ) {
@@ -1602,7 +1580,6 @@ private PortionObfuscator(PortionBuilder builder) {
1602
1580
this .atLeastFromStart = builder .atLeastFromStart ;
1603
1581
this .atLeastFromEnd = builder .atLeastFromEnd ;
1604
1582
this .fixedTotalLength = builder .fixedTotalLength ;
1605
- this .fixedObfuscatedLength = builder .fixedObfuscatedLength ;
1606
1583
this .maskChar = builder .maskChar ;
1607
1584
1608
1585
if (fixedTotalLength >= 0 && fixedTotalLength < keepAtStart + keepAtEnd ) {
@@ -1650,9 +1627,6 @@ public CharSequence obfuscateText(CharSequence s, int start, int end) {
1650
1627
1651
1628
if (fixedTotalLength >= 0 ) {
1652
1629
length = fixedTotalLength ;
1653
- } else if (fixedObfuscatedLength >= 0 ) {
1654
- // length - fromStart - fromEnd needs to be fixedObfuscatedLength, so length needs to be fixedObfuscatedLength + fromStart + fromEnd
1655
- length = fixedObfuscatedLength + fromStart + fromEnd ;
1656
1630
}
1657
1631
1658
1632
char [] array = new char [length ];
@@ -1680,9 +1654,6 @@ public void obfuscateText(CharSequence s, int start, int end, Appendable destina
1680
1654
1681
1655
if (fixedTotalLength >= 0 ) {
1682
1656
length = fixedTotalLength ;
1683
- } else if (fixedObfuscatedLength >= 0 ) {
1684
- // length - fromStart - fromEnd needs to be fixedObfuscatedLength, so length needs to be fixedObfuscatedLength + fromStart + fromEnd
1685
- length = fixedObfuscatedLength + fromStart + fromEnd ;
1686
1657
}
1687
1658
1688
1659
// first build the content as expected: 0 to fromStart non-obfuscated, then obfuscated, then end - fromEnd non-obfuscated
@@ -1723,14 +1694,13 @@ public boolean equals(Object o) {
1723
1694
PortionObfuscator other = (PortionObfuscator ) o ;
1724
1695
return keepAtStart == other .keepAtStart && keepAtEnd == other .keepAtEnd
1725
1696
&& atLeastFromStart == other .atLeastFromStart && atLeastFromEnd == other .atLeastFromEnd
1726
- && fixedObfuscatedLength == other .fixedObfuscatedLength
1727
1697
&& fixedTotalLength == other .fixedTotalLength
1728
1698
&& maskChar == other .maskChar ;
1729
1699
}
1730
1700
1731
1701
@ Override
1732
1702
public int hashCode () {
1733
- return keepAtStart ^ keepAtEnd ^ atLeastFromStart ^ atLeastFromEnd ^ fixedObfuscatedLength ^ fixedTotalLength ^ maskChar ;
1703
+ return keepAtStart ^ keepAtEnd ^ atLeastFromStart ^ atLeastFromEnd ^ fixedTotalLength ^ maskChar ;
1734
1704
}
1735
1705
1736
1706
@ Override
@@ -1751,9 +1721,6 @@ public String toString() {
1751
1721
if (atLeastFromEnd > 0 ) {
1752
1722
sb .append ("atLeastFromEnd=" ).append (atLeastFromEnd ).append (',' );
1753
1723
}
1754
- if (fixedObfuscatedLength >= 0 ) {
1755
- sb .append ("fixedLength=" ).append (fixedObfuscatedLength ).append (',' );
1756
- }
1757
1724
if (fixedTotalLength >= 0 ) {
1758
1725
sb .append ("fixedTotalLength=" ).append (fixedTotalLength ).append (',' );
1759
1726
}
0 commit comments