Class SealedSystemPropertiesStringProperty


  • public class SealedSystemPropertiesStringProperty
    extends java.lang.Object
    A security-sensitive String setting -- in practice a class name -- read from System properties as of the seal, from supplied configuration live, or from a default.

    The String member of the family that includes SealedSystemPropertiesBooleanProperty and SealedSystemPropertiesWhitelistManager, and it shares their reason for treating the two sources differently. System properties are an ambient channel any code in the process can write, unguarded since SecurityManager's removal, so they are read from SealedSystemProperties and later mutation is invisible. A PropertiesConfig is a parameter the application chose to pass, and implementations are read-only views of configuration the application manages, so it is honored per call. Either may be null.

    Precedence, and how it differs from the others

    A sealed System property wins; failing that, the supplied configuration; failing that, the default. That is a plain precedence rule, and it is not what the boolean and whitelist members do. Those resolve disagreement conservatively -- the safer of two answers stands, whichever source offered it -- because a boolean has a safe polarity and a whitelist has a narrower reading. A String has neither, so there is nothing to be conservative toward, and the question becomes simply whose word counts. The operator's does.

    Do not read this as a weaker guarantee. Nothing an attacker writes to System properties after the seal is visible here at all, which is the property that matters; what is given up is only the ability to resolve a genuine disagreement toward safety, which for an opaque String is not a meaningful notion.

    Whitespace

    The intended values are class names handed to Class.forName, and Properties.load preserves trailing whitespace, so someKey=com.example.Foo  in a properties file yields a name that cannot resolve -- failing as a ClassNotFoundException for a class that looks correct in the file. Each source is therefore passed through a SealedSystemPropertiesStringProperty.Whitespace policy, chosen at construction:

    Because trimming happens at each source rather than once at the end, a blank System property yields to a real configured value rather than masking it.

    The default is used as-is

    A default is a literal supplied by the calling code, not configuration, so it is returned unprocessed -- the whitespace policy does not apply to it. A default that is blank or carries surrounding whitespace is therefore almost certainly an authoring mistake, and is reported once, at the first lookup, whether or not the default is ever actually used: it is a defect in code rather than a condition of the deployment, and the person who can fix it should hear about it either way. An empty default under SealedSystemPropertiesStringProperty.Whitespace.TRIM_BLANKS_ARE_EMPTY is exempt, that policy having declared the empty String meaningful.

    High-security defaults

    Falling back to the default is reported too, once, and again if configuration appears and is later withdrawn -- a deployment running on the library's choice rather than its own should know it. But not every default is a concession. Some are the most restrictive setting available, and a setting whose default already refuses everything it ought to refuse is one almost nobody configures, so reporting the fallback would put a warning in front of nearly every user for being correctly configured. Constructing with highSecurityDefault true declares a default to be of that kind, and suppresses the notice.

    SealedSystemPropertiesBooleanProperty needs no such flag. A boolean has a safe polarity, so it can see for itself whether its default is the safe one and warn only when it is not. A String has no polarity, so only the caller knows.

    The flag suppresses that one notice and nothing else. A default carrying stray whitespace is still reported -- that is a mistake in code whatever the setting's security posture, and Class.forName will not care how the author characterized it -- and a sealed System property taking over is still noted.

    • Constructor Detail

      • SealedSystemPropertiesStringProperty

        public SealedSystemPropertiesStringProperty​(java.lang.String property,
                                                    java.lang.String defaultValue,
                                                    boolean highSecurityDefault,
                                                    SealedSystemPropertiesStringProperty.Whitespace whitespace)
      • SealedSystemPropertiesStringProperty

        public SealedSystemPropertiesStringProperty​(java.lang.String property,
                                                    java.lang.String defaultValue,
                                                    boolean highSecurityDefault)
      • SealedSystemPropertiesStringProperty

        public SealedSystemPropertiesStringProperty​(java.lang.String property)