Class ConfigurationValidator

java.lang.Object
com.okta.commons.configcheck.ConfigurationValidator

public final class ConfigurationValidator extends Object
Configuration validation helper class to help validation of common configuration strings.
Since:
1.0.0
  • Method Details

    • assertOrgUrl

      public static void assertOrgUrl(String url)
      Asserts the url is 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 public static void assertOrgUrl(String url, boolean allowNonHttpsForTesting)
      Deprecated.
      use validateOrgUrl(String) instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios
      Asserts the url is 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
      allowNonHttpsForTesting - Allow orgUrl to be non-https, likely used for testing.
      Throws:
      IllegalArgumentException - Thrown if URL is invalid
    • validateOrgUrl

      public static ValidationResponse validateOrgUrl(String url)
      Returns a ValidationResponse checking to make sure the url is 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.
      use validateOrgUrl(String) instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios
      Returns a ValidationResponse checking to make sure the url is 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
      allowNonHttpsForTesting - Allow orgUrl to be non-https, likely used for testing.
      Returns:
      a ValidationResponse containing the validation status and message (when invalid)
    • assertApiToken

      public static void assertApiToken(String token)
      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 if token is invalid
    • validateApiToken

      public static ValidationResponse validateApiToken(String token)
      Returns a ValidationResponse checking 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

      public static void assertIssuer(String url)
      Asserts the url is 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

      public static ValidationResponse validateIssuer(String url)
      Returns a ValidationResponse checking the url is 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

      public static void assertClientId(String clientId)
      Asserts that a clientId is 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

      public static ValidationResponse validateClientId(String clientId)
      Returns a ValidationResponse checking the clientId is 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

      public static void assertClientSecret(String clientSecret)
      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

      public static ValidationResponse validateClientSecret(String clientSecret)
      Returns a ValidationResponse checking the clientSecret is 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)