Class ConfigurationValidator


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

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static void assertApiToken​(java.lang.String token)
      Asserts that an API token is not null and contains does not contain the string {apiToken}.
      static void assertClientId​(java.lang.String clientId)
      Asserts that a clientId is not null and contains does not contain the string {clientId}.
      static void assertClientSecret​(java.lang.String clientSecret)
      Asserts that a client secret is not null and contains does not contain the string {clientSecret}.
      static void assertIssuer​(java.lang.String url)
      Asserts the url is a well formed HTTPS URL and does not contain common typos.
      static void assertOrgUrl​(java.lang.String url)
      Asserts the url is a well formed HTTPS URL and does not contain common typos.
      static void assertOrgUrl​(java.lang.String url, boolean allowNonHttpsForTesting)
      Deprecated.
      use validateOrgUrl(String) instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios
      static ValidationResponse validateApiToken​(java.lang.String token)
      Returns a ValidationResponse checking to make sure the API token is not null and contains does not contain the string {apiToken}.
      static ValidationResponse validateClientId​(java.lang.String clientId)
      Returns a ValidationResponse checking the clientId is not null and contains does not contain the string {apiToclientIdken}.
      static ValidationResponse validateClientSecret​(java.lang.String clientSecret)
      Returns a ValidationResponse checking the clientSecret is not null and contains does not contain the string {clientSecret}.
      static ValidationResponse validateIssuer​(java.lang.String url)
      Returns a ValidationResponse checking the url is a well formed HTTPS URL and does not contain common typos.
      static ValidationResponse validateOrgUrl​(java.lang.String url)
      Returns a ValidationResponse checking to make sure the url is a well formed HTTPS URL and does not contain common typos.
      static ValidationResponse validateOrgUrl​(java.lang.String url, boolean allowNonHttpsForTesting)
      Deprecated.
      use validateOrgUrl(String) instead, disabling this check is NOT recommended, and should ONLY be done in testing scenarios
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • assertOrgUrl

        public static void assertOrgUrl​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if URL is invalid
      • assertOrgUrl

        @Deprecated
        public static void assertOrgUrl​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if URL is invalid
      • validateOrgUrl

        public static ValidationResponse validateOrgUrl​(java.lang.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​(java.lang.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​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if token is invalid
      • validateApiToken

        public static ValidationResponse validateApiToken​(java.lang.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​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if URL is invalid
      • validateIssuer

        public static ValidationResponse validateIssuer​(java.lang.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​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if URL is invalid
      • validateClientId

        public static ValidationResponse validateClientId​(java.lang.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​(java.lang.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:
        java.lang.IllegalArgumentException - Thrown if URL is invalid
      • validateClientSecret

        public static ValidationResponse validateClientSecret​(java.lang.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)