Package com.okta.commons.configcheck
Class ConfigurationValidator
java.lang.Object
com.okta.commons.configcheck.ConfigurationValidator
Configuration validation helper class to help validation of common configuration strings.
- Since:
- 1.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertApiToken(String token) Asserts that an API token is not null and contains does not contain the string{apiToken}.static voidassertClientId(String clientId) Asserts that aclientIdis not null and contains does not contain the string{clientId}.static voidassertClientSecret(String clientSecret) Asserts that a client secret is not null and contains does not contain the string{clientSecret}.static voidassertIssuer(String url) Asserts theurlis a well formed HTTPS URL and does not contain common typos.static voidassertOrgUrl(String url) Asserts theurlis a well formed HTTPS URL and does not contain common typos.static voidassertOrgUrl(String url, boolean allowNonHttpsForTesting) Deprecated.static ValidationResponsevalidateApiToken(String token) Returns aValidationResponsechecking to make sure the API token is not null and contains does not contain the string{apiToken}.static ValidationResponsevalidateClientId(String clientId) Returns aValidationResponsechecking theclientIdis not null and contains does not contain the string{apiToclientIdken}.static ValidationResponsevalidateClientSecret(String clientSecret) Returns aValidationResponsechecking theclientSecretis not null and contains does not contain the string{clientSecret}.static ValidationResponsevalidateIssuer(String url) Returns aValidationResponsechecking theurlis a well formed HTTPS URL and does not contain common typos.static ValidationResponsevalidateOrgUrl(String url) Returns aValidationResponsechecking to make sure theurlis a well formed HTTPS URL and does not contain common typos.static ValidationResponsevalidateOrgUrl(String url, boolean allowNonHttpsForTesting) Deprecated.usevalidateOrgUrl(String)instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios
-
Method Details
-
assertOrgUrl
Asserts theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validated- Throws:
IllegalArgumentException- Thrown if URL is invalid
-
assertOrgUrl
Deprecated.usevalidateOrgUrl(String)instead, disabling this check is NOT recommended, and should ONLY be done in testing scenariosAsserts theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validatedallowNonHttpsForTesting- Allow orgUrl to be non-https, likely used for testing.- Throws:
IllegalArgumentException- Thrown if URL is invalid
-
validateOrgUrl
Returns aValidationResponsechecking to make sure theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validated- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
validateOrgUrl
@Deprecated public static ValidationResponse validateOrgUrl(String url, boolean allowNonHttpsForTesting) Deprecated.usevalidateOrgUrl(String)instead, disabling this check is NOT recommended, and should ONLY be done in testing scenariosReturns aValidationResponsechecking to make sure theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validatedallowNonHttpsForTesting- Allow orgUrl to be non-https, likely used for testing.- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
assertApiToken
Asserts that an API token is not null and contains does not contain the string{apiToken}.- Parameters:
token- The API Token to be validated- Throws:
IllegalArgumentException- Thrown iftokenis invalid
-
validateApiToken
Returns aValidationResponsechecking to make sure the API token is not null and contains does not contain the string{apiToken}.- Parameters:
token- The API Token to be validated- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
assertIssuer
Asserts theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validated- Throws:
IllegalArgumentException- Thrown if URL is invalid
-
validateIssuer
Returns aValidationResponsechecking theurlis a well formed HTTPS URL and does not contain common typos. The checks include:- Contains {yourOktaDomain}
- Hostname ends with .com.com
- Contains -admin.okta.com
- Contains -admin.oktapreview.com
- Contains -admin.okta-emea.com
- Parameters:
url- The url to be validated- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
assertClientId
Asserts that aclientIdis not null and contains does not contain the string{clientId}.- Parameters:
clientId- The client Id to be validated- Throws:
IllegalArgumentException- Thrown if URL is invalid
-
validateClientId
Returns aValidationResponsechecking theclientIdis not null and contains does not contain the string{apiToclientIdken}.- Parameters:
clientId- The client Id to be validated- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
assertClientSecret
Asserts that a client secret is not null and contains does not contain the string{clientSecret}.- Parameters:
clientSecret- the Client Secret to be validated- Throws:
IllegalArgumentException- Thrown if URL is invalid
-
validateClientSecret
Returns aValidationResponsechecking theclientSecretis not null and contains does not contain the string{clientSecret}.- Parameters:
clientSecret- the Client Secret to be validated- Returns:
- a ValidationResponse containing the validation status and message (when invalid)
-
validateOrgUrl(String)instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios