Class AuthTool


  • public class AuthTool
    extends java.lang.Object
    Simplicite(R) authentication toolbox
    • Constructor Summary

      Constructors 
      Constructor Description
      AuthTool()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int getAuthMethodFromType​(java.lang.String type)
      Get auth type code from auth type name
      static java.lang.String getAuthorizeURL​(java.lang.String provider, java.lang.String defaultValue)
      Get OAuth2 authorize endpoint URL
      static org.json.JSONObject getAuthProvider​(int method, java.lang.String name)
      Get specified auth provider definition
      static org.json.JSONArray getAuthProviders()
      Get all auth providers definition
      static org.json.JSONArray getAuthProviders​(int method)
      Get auth providers definition for specified auth method
      static java.lang.String getAuthTypeFromMethod​(int method)
      Get auth type name from auth method code
      static boolean getBooleanSetting​(java.lang.String providerName, int providerType, java.lang.String name, boolean defaultValue)
      Get boolean setting
      static java.lang.String getClientID​(java.lang.String provider)
      Get OAuth2 client ID
      static java.lang.String getClientSecret​(java.lang.String provider)
      Get OAuth2 client secret
      static org.json.JSONObject getLocalAuthProvider()
      LGet local OAUTH2 provider definition
      static java.lang.String getLogoutURL​(java.lang.String provider, java.lang.String defaultValue)
      Get OAuth2 logout endpoint URL
      static java.lang.String getOAuth2BaseURL​(java.lang.String provider)
      Get OAuth2 base URL
      static java.lang.String getRedirectURI​(java.lang.String provider, java.lang.String defaultValue)
      Get redirect URI
      static java.lang.String getScopes​(java.lang.String provider)
      Get OAuth2 scopes
      static java.lang.String getSetting​(java.lang.String providerName, int providerType, java.lang.String name, java.lang.String defaultValue)
      Get string setting
      static org.json.JSONObject getTokenInfoMappings​(java.lang.String provider)
      Get OAuth2 token info fields mappings
      static java.lang.String getTokenInfoURL​(java.lang.String provider, java.lang.String defaultValue)
      Get OAuth2 token info endpoint URL
      static java.lang.String getTokenURL​(java.lang.String provider, java.lang.String defaultValue)
      Get OAuth2 token endpoint URL
      static org.json.JSONObject getUserInfoMappings​(java.lang.String provider)
      Get OAuth2 user info fields mappings
      static java.lang.String getUserInfoURL​(java.lang.String provider, java.lang.String defaultValue)
      Get OAuth2 user info endpoint URL
      static boolean isSync​(java.lang.String provider, int providerType)
      Is user and responsibilities synchronization required?
      static boolean useCrowd()
      Is at least one CROWD authentication provider configured?
      static boolean useLDAP()
      Is at least one LDAP authentication provider configured?
      static boolean useOAuth2()
      Is at least one OAuth2 authentication provider configured?
      static boolean useSAML()
      Is at least one SAML authentication provider configured?
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • AUTH_DEFAULT_URL

        public static final java.lang.String AUTH_DEFAULT_URL
        Default authentication form action
        See Also:
        Constant Field Values
      • AUTH_METHOD_NONE

        public static final int AUTH_METHOD_NONE
        No authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_DEFAULT

        public static final int AUTH_METHOD_DEFAULT
        Default (server managed: JAAS, Relam, ...) authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_INTERNAL

        public static final int AUTH_METHOD_INTERNAL
        Internal OAuth2 authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_OAUTH2

        public static final int AUTH_METHOD_OAUTH2
        External OAuth2 authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_SAML

        public static final int AUTH_METHOD_SAML
        External SAML authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_LDAP

        public static final int AUTH_METHOD_LDAP
        LDAP authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_CROWD

        public static final int AUTH_METHOD_CROWD
        Crowd authentication method
        See Also:
        Constant Field Values
      • AUTH_METHOD_CUSTOM

        public static final int AUTH_METHOD_CUSTOM
        Custom authentication method
        See Also:
        Constant Field Values
      • AUTH_DEFAULT_ERROR

        public static final java.lang.String AUTH_DEFAULT_ERROR
        Default authentication error message
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_DEFAULT

        public static final java.lang.String AUTH_PROVIDER_DEFAULT
        Default (server-managed: JAAS, Relam, ...) authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_INTERNAL

        public static final java.lang.String AUTH_PROVIDER_INTERNAL
        Internal OAuth2 authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_OAUTH2_GOOGLE

        public static final java.lang.String AUTH_PROVIDER_OAUTH2_GOOGLE
        Google external OAuth2 authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_OAUTH2_MICROSOFT

        public static final java.lang.String AUTH_PROVIDER_OAUTH2_MICROSOFT
        Microsoft Live external OAuth2 authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_OAUTH2_LINKEDIN

        public static final java.lang.String AUTH_PROVIDER_OAUTH2_LINKEDIN
        LinkedIn external OAuth2 authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_OAUTH2_FRANCECONNECT

        public static final java.lang.String AUTH_PROVIDER_OAUTH2_FRANCECONNECT
        FranceConnect external OAuth2 authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_SAML_GOOGLE

        public static final java.lang.String AUTH_PROVIDER_SAML_GOOGLE
        Google external SAML authentication provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_CROWD

        public static final java.lang.String AUTH_PROVIDER_CROWD
        Generic Crowd provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_LDAP

        public static final java.lang.String AUTH_PROVIDER_LDAP
        Generic LDAP provider name
        See Also:
        Constant Field Values
      • AUTH_PROVIDER_CUSTOM

        public static final java.lang.String AUTH_PROVIDER_CUSTOM
        Generic custom provider name
        See Also:
        Constant Field Values
      • OAUTH2_FRANCECONNECT_URL_FOR_INDVIDUALS

        public static final java.lang.String OAUTH2_FRANCECONNECT_URL_FOR_INDVIDUALS
        FranceConnect URL for individuals
        See Also:
        Constant Field Values
      • OAUTH2_FRANCECONNECT_URL_FOR_COMPANIES

        public static final java.lang.String OAUTH2_FRANCECONNECT_URL_FOR_COMPANIES
        FranceConnect URL for companies
        See Also:
        Constant Field Values
      • OAUTH2_LINKEDIN_URL

        public static final java.lang.String OAUTH2_LINKEDIN_URL
        LinkedIn URL
        See Also:
        Constant Field Values
    • Constructor Detail

      • AuthTool

        public AuthTool()
    • Method Detail

      • getAuthTypeFromMethod

        public static java.lang.String getAuthTypeFromMethod​(int method)
        Get auth type name from auth method code
        Parameters:
        method - Auth method code
        Returns:
        Auth type name
      • getAuthMethodFromType

        public static int getAuthMethodFromType​(java.lang.String type)
        Get auth type code from auth type name
        Parameters:
        type - Auth type name
        Returns:
        Auth type code
      • getAuthProviders

        public static final org.json.JSONArray getAuthProviders​(int method)
        Get auth providers definition for specified auth method
        Parameters:
        method - Auth method (one of Globals.AUTH_METHOD_*)
        Returns:
        JSON array
      • getAuthProviders

        public static final org.json.JSONArray getAuthProviders()
        Get all auth providers definition
        Returns:
        JSON array
      • getLocalAuthProvider

        public static final org.json.JSONObject getLocalAuthProvider()
        LGet local OAUTH2 provider definition
        Returns:
        JSON object
      • getAuthProvider

        public static final org.json.JSONObject getAuthProvider​(int method,
                                                                java.lang.String name)
        Get specified auth provider definition
        Parameters:
        method - Auth method (one of Globals.AUTH_METHOD_*)
        name - Provider name
        Returns:
        JSON object
      • useOAuth2

        public static final boolean useOAuth2()
        Is at least one OAuth2 authentication provider configured?
        Returns:
        True if at least one OAuth2 authentication provider is configured
      • useSAML

        public static final boolean useSAML()
        Is at least one SAML authentication provider configured?
        Returns:
        True if at least one SAML authentication provider is configured
      • useCrowd

        public static final boolean useCrowd()
        Is at least one CROWD authentication provider configured?
        Returns:
        True if at least one CROWD authentication provider is configured
      • useLDAP

        public static final boolean useLDAP()
        Is at least one LDAP authentication provider configured?
        Returns:
        True if at least one LDAP authentication provider is configured
      • getSetting

        public static java.lang.String getSetting​(java.lang.String providerName,
                                                  int providerType,
                                                  java.lang.String name,
                                                  java.lang.String defaultValue)
        Get string setting
        Parameters:
        providerName - Provider name
        providerType - Provider type (one of Globals.AUTH_METHOD_*)
        name - Setting name
        defaultValue - Default value
        Returns:
        Setting value or default if not found
      • getBooleanSetting

        public static boolean getBooleanSetting​(java.lang.String providerName,
                                                int providerType,
                                                java.lang.String name,
                                                boolean defaultValue)
        Get boolean setting
        Parameters:
        providerName - Provider name
        providerType - Provider type (one of Globals.AUTH_METHOD_*)
        name - Setting name
        defaultValue - Default value
        Returns:
        Setting boolean value or default if not found
      • isSync

        public static boolean isSync​(java.lang.String provider,
                                     int providerType)
        Is user and responsibilities synchronization required?
        Parameters:
        provider - Provider name
        providerType - Provider type (one of Globals.AUTH_METHOD_*)
        Returns:
        True if synchronization is required
      • getOAuth2BaseURL

        public static java.lang.String getOAuth2BaseURL​(java.lang.String provider)
        Get OAuth2 base URL
        Parameters:
        provider - Provider name
        Returns:
        OAuth2 base URL
      • getAuthorizeURL

        public static java.lang.String getAuthorizeURL​(java.lang.String provider,
                                                       java.lang.String defaultValue)
        Get OAuth2 authorize endpoint URL
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Oauth2 authorize endpoint URL
      • getTokenURL

        public static java.lang.String getTokenURL​(java.lang.String provider,
                                                   java.lang.String defaultValue)
        Get OAuth2 token endpoint URL
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Oauth2 token endpoint URL
      • getUserInfoURL

        public static java.lang.String getUserInfoURL​(java.lang.String provider,
                                                      java.lang.String defaultValue)
        Get OAuth2 user info endpoint URL
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Oauth2 user info endpoint URL
      • getUserInfoMappings

        public static org.json.JSONObject getUserInfoMappings​(java.lang.String provider)
        Get OAuth2 user info fields mappings
        Parameters:
        provider - Provider
        Returns:
        User info as JSON object
      • getTokenInfoURL

        public static java.lang.String getTokenInfoURL​(java.lang.String provider,
                                                       java.lang.String defaultValue)
        Get OAuth2 token info endpoint URL
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Oauth2 token info URL
      • getTokenInfoMappings

        public static org.json.JSONObject getTokenInfoMappings​(java.lang.String provider)
        Get OAuth2 token info fields mappings
        Parameters:
        provider - Provider name
        Returns:
        Oauth2 token info fields mapping as JSON object
      • getLogoutURL

        public static java.lang.String getLogoutURL​(java.lang.String provider,
                                                    java.lang.String defaultValue)
        Get OAuth2 logout endpoint URL
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Logout URL
      • getRedirectURI

        public static java.lang.String getRedirectURI​(java.lang.String provider,
                                                      java.lang.String defaultValue)
        Get redirect URI
        Parameters:
        provider - Provider name
        defaultValue - Default value
        Returns:
        Redirect URI
      • getClientID

        public static java.lang.String getClientID​(java.lang.String provider)
        Get OAuth2 client ID
        Parameters:
        provider - Provider name
        Returns:
        OAuth2 client ID
      • getClientSecret

        public static java.lang.String getClientSecret​(java.lang.String provider)
        Get OAuth2 client secret
        Parameters:
        provider - Provider name
        Returns:
        OAuth2 client secret
      • getScopes

        public static java.lang.String getScopes​(java.lang.String provider)
        Get OAuth2 scopes
        Parameters:
        provider - Provider name
        Returns:
        Oauth2 scopes