Class SecretMasking
java.lang.Object
dev.langchain4j.internal.SecretMasking
Hides credentials in what LangChain4j writes to logs and exception messages.
When in doubt, it masks: a value that was masked without need costs one debugging round trip, an unmasked credential costs a key rotation.
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisSecretName(String name) Returnstrueif a header, query parameter or other value with this name probably carries a credential: its name containsauth,key,token,secret,password,credential,cookie,signatureorsession, ignoring case.static @Nullable StringMasks a credential: a value of 20 or more characters is shown as its first 5 and last 2 characters (sk-pr...Xy), a shorter value is replaced by....static StringmaskUserInfo(String url) Replaces the user info of a URL with***:https://user:password@host/pathbecomeshttps://***@host/path.static @Nullable StringwithoutCredentials(@Nullable String url) Removes the user info, the query and the fragment of a URL, as all of them can carry credentials:https://user:password@host/path?key=secretbecomeshttps://host/path.
-
Method Details
-
isSecretName
Returnstrueif a header, query parameter or other value with this name probably carries a credential: its name containsauth,key,token,secret,password,credential,cookie,signatureorsession, ignoring case. -
mask
-
maskUserInfo
-
withoutCredentials
Removes the user info, the query and the fragment of a URL, as all of them can carry credentials:https://user:password@host/path?key=secretbecomeshttps://host/path. Also works for malformed URLs.- Returns:
- the URL without credentials, or
nullif the URL isnull
-