Class Login

java.lang.Object
org.compiere.util.Login

public class Login extends Object
Login Manager
Version:
$Id: Login.java,v 1.6 2006/10/02 05:19:06 jjanke Exp $
Author:
Jorg Janke, victor.perez@e-evolution.com, e-Evolution http://www.e-evolution.com
  • Incorrect global Variable when you use multi Account Schema https://sourceforge.net/p/adempiere/bugs/1713/, teo.sarca@gmail.com
  • BF [ 2867246 ] Do not show InTrazit WHs on login https://sourceforge.net/p/adempiere/bugs/2136/
    • Constructor Details

      • Login

        public Login(Properties ctx)
        Parameters:
        ctx - context
    • Method Details

      • getLoginErrMsg

        public String getLoginErrMsg()
        Get login error message
        Returns:
        login error message
      • isPasswordExpired

        public boolean isPasswordExpired()
        Is user password has expire
        Returns:
        true if user password has expire
      • initTest

        @Deprecated public static Properties initTest(boolean isClient)
        Deprecated.
        Test Init - Set Environment for tests
        Parameters:
        isClient - client session
        Returns:
        Context
      • isJavaOK

        public static boolean isJavaOK(boolean isClient)
        Java Version Test, only use for client environment
        Parameters:
        isClient - client environment
        Returns:
        true if Java Version is OK
      • getRoles

        @Deprecated(since="2", forRemoval=true) protected KeyNamePair[] getRoles(CConnection cc, String app_user, String app_pwd, boolean force)
        Deprecated, for removal: This API element is subject to removal in a future version.
        (Test) Client Login.

        - Get Connection - Compare User info

        Sets Context with login info

        Parameters:
        cc - connection
        app_user - user
        app_pwd - pwd
        force - ignore pwd
        Returns:
        Array of Role KeyNamePair or null if error The error (NoDatabase, UserPwdError, DBLogin) is saved in the log
      • getRoles

        @Deprecated(since="2", forRemoval=true) public KeyNamePair[] getRoles(Principal app_user)
        Deprecated, for removal: This API element is subject to removal in a future version.
        (Web) Client Login.

        Compare User Info

        Sets Context with login info

        Parameters:
        app_user - Principal
        Returns:
        role array or null if in error. The error (NoDatabase, UserPwdError, DBLogin) is saved in the log
      • getRoles

        @Deprecated(since="2", forRemoval=true) public KeyNamePair[] getRoles(String app_user, String app_pwd)
        Deprecated, for removal: This API element is subject to removal in a future version.
        Client Login.

        Compare User Info

        Sets Context with login info

        Parameters:
        app_user - user id
        app_pwd - password
        Returns:
        role array or null if in error. The error (NoDatabase, UserPwdError, DBLogin) is saved in the log
      • getClients

        public KeyNamePair[] getClients(KeyNamePair role)
        Get Clients (AD_Client).

        Sets Role info in context and loads its clients

        Parameters:
        role - role information
        Returns:
        list of valid client KeyNamePairs or null if has error
      • getOrgs

        public KeyNamePair[] getOrgs(KeyNamePair rol)
        Get Organizations (AD_Org).

        Sets Client info in context and loads organizations that the role has access to

        Parameters:
        rol - role
        Returns:
        list of valid Org KeyNodePairs or null if in error
      • getWarehouses

        public KeyNamePair[] getWarehouses(KeyNamePair org)
        Get Warehouses
        Parameters:
        org - organization
        Returns:
        Array of Warehouse Info
      • validateLogin

        public String validateLogin(KeyNamePair org)
        Validate Login
        Parameters:
        org - login org
        Returns:
        error message or null
      • loadPreferences

        public String loadPreferences(KeyNamePair org, KeyNamePair warehouse, Timestamp timestamp, String printerName)
        Load Preferences into Context for selected client.

        Sets Org info in context and loads relevant field from - AD_Client/Info, - C_AcctSchema, - C_AcctSchema_Elements - AD_Preference

        Assumes that the context is set for #AD_Client_ID, #AD_User_ID, #AD_Role_ID

        Parameters:
        org - org information
        warehouse - optional warehouse information
        timestamp - optional date
        printerName - optional printer info
        Returns:
        AD_Message of error (NoValidAcctInfo) or ""
      • loadUserPreferences

        public void loadUserPreferences()
        Load user preferences
      • batchLogin

        public boolean batchLogin(Timestamp loginDate)
        Batch Login using Ini values
                
                        Adempiere.startup(true);
                        Ini.setProperty(Ini.P_UID,"SuperUser");
                        Ini.setProperty(Ini.P_PWD,"System");
                        Ini.setProperty(Ini.P_ROLE,"GardenAdmin");
                        Ini.setProperty(Ini.P_CLIENT, "Garden World");
                        Ini.setProperty(Ini.P_ORG,"HQ");
                        Ini.setProperty(Ini.P_WAREHOUSE,"HQ");
                        Ini.setProperty(Ini.P_LANGUAGE,"English");
                        Ini.setProperty(Ini.P_PRINTER,"MyPrinter");
                        Login login = new Login(Env.getCtx());
                        login.batchLogin();
                
          
        Parameters:
        loginDate - optional login date
        Returns:
        true if logged in using Ini values
      • batchLogin

        public boolean batchLogin()
        Batch Login with system date
        Returns:
        true if logged in
      • getPrincipal

        @Deprecated public Principal getPrincipal()
        Deprecated.
        Get SSO Principal
        Returns:
        principal
      • getClients

        public KeyNamePair[] getClients(String app_user, String app_pwd)
        Get clients (AD_Client)
        Parameters:
        app_user - login id
        app_pwd - login password
        Returns:
        list of accessible client
      • getClients

        public KeyNamePair[] getClients(String app_user, String app_pwd, String roleTypes)
        Validate Client Login. Sets Context with login info.
        Parameters:
        app_user - user id
        app_pwd - password
        roleTypes - comma separated list of the role types allowed to login (NULL can be added)
        Returns:
        client array or null if in error.
      • getClients

        public KeyNamePair[] getClients(String app_user, String app_pwd, String roleTypes, Object token)
        Validate Client Login.
        Sets Context with login info.
        Parameters:
        app_user - user id
        app_pwd - password, ignore for SSO login
        roleTypes - comma separated list of the role types allowed to login (NULL can be added)
        token - token to validate SSO login user (app_user).
        Returns:
        client array or null if in error.
      • getAppUser

        public static String getAppUser(String app_user)
        Get the user from the login text
        Parameters:
        app_user -
        Returns:
        user id
      • getRoles

        public KeyNamePair[] getRoles(String app_user, KeyNamePair client)
        Get roles of user
        Parameters:
        app_user -
        client -
        Returns:
        roles of user
      • getRoles

        public KeyNamePair[] getRoles(String app_user, KeyNamePair client, String roleTypes)
        Get Roles.

        Sets Client info in context and loads its roles.

        Parameters:
        client - client information
        roleTypes - comma separated list of the role types allowed to login (NULL can be added)
        Returns:
        list of valid roles KeyNodePairs or null if in error
      • getClients

        public KeyNamePair[] getClients()
        Get clients (AD_Client)
        Returns:
        clients
      • isMFARequired

        public boolean isMFARequired(String registerCookie)
        Validate if MFA is required taking into account the registerCookie and the IPAddress
        Parameters:
        registerCookie -
        Returns: