All Downloads are FREE. Search and download functionalities are using the official Maven repository.

liquibase.database.jvm.ConnectionPatterns Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.database.jvm;

import java.util.AbstractMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;

/**
 * A base class that holds connection string patterns with connection credentials that should be hidden in logs.
 * Derived classes add their own connection string patterns.
 */
public abstract class ConnectionPatterns {

    public static class PatternPair {
        private PatternPair() { }

        // Return a map entry (key-value pair) from the specified values
        public static  Map.Entry of(T first, U second) {
            return new AbstractMap.SimpleEntry<>(first, second);
        }
    }
    private final Set> patternJdbcBlank = new HashSet<>();
    private final Set> patternJdbcBlankToObfuscate = new HashSet<>();
    private final Set> patternJdbcObfuscate = new HashSet<>();

    public Set> getJdbcBlankPatterns() {
        return patternJdbcBlank;
    }

    public Set> getJdbcBlankToObfuscatePatterns() {
        return patternJdbcBlankToObfuscate;
    }

    public Set> getJdbcObfuscatePatterns() {
        return patternJdbcObfuscate;
    }

    /**
     * Holds credential patterns that should be replaced by empty string.
     * 

* jdbc:mysql://localhost:3306/lbcat?user=username&password=password *

*

* jdbc:mariadb://username:password@localhost:3306/lbcat *

*/ @SuppressWarnings("secrets:S6703") public void addJdbcBlankPatterns(Map.Entry jdbcBlankPatterns) { patternJdbcBlank.add(jdbcBlankPatterns); } /** * Holds credential patterns that are located before the domain or subdomain part. * They should be replaced by asterisks. *

* jdbc:mariadb://username:password@localhost:3306/lbcat *

*/ public void addJdbcBlankToObfuscatePatterns(Map.Entry patternJdbcBlankToObfuscate) { this.patternJdbcBlankToObfuscate.add(patternJdbcBlankToObfuscate); } /** * Holds credential patterns that are located in the URL parameters. * They should be replaced by asterisks. *

* jdbc:postgresql://localhost:6432/lbcat?user=username&password=password *

*/ @SuppressWarnings("secrets:S6703") public void addJdbcObfuscatePatterns(Map.Entry jdbcObfuscatePatterns) { patternJdbcObfuscate.add(jdbcObfuscatePatterns); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy