Package org.compiere.util
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 Summary
Constructors Constructor Description Login(Properties ctx)Login
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanbatchLogin()Batch Login with system datebooleanbatchLogin(Timestamp loginDate)Batch Login using Ini valuesAdempiere.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();KeyNamePair[]getClients()KeyNamePair[]getClients(String app_user, String app_pwd)KeyNamePair[]getClients(String app_user, String app_pwd, String roleTypes)Validate Client Login.KeyNamePair[]getClients(KeyNamePair role)Load Clients.StringgetLoginErrMsg()KeyNamePair[]getOrgs(KeyNamePair rol)Load Organizations.PrincipalgetPrincipal()Get SSO PrincipalKeyNamePair[]getRoles(String app_user, String app_pwd)Deprecated.use public KeyNamePair[] getRoles(String app_user, KeyNamePair client)KeyNamePair[]getRoles(String app_user, KeyNamePair client)KeyNamePair[]getRoles(String app_user, KeyNamePair client, String roleTypes)Load Roles.KeyNamePair[]getRoles(Principal app_user)Deprecated.use public KeyNamePair[] getRoles(String app_user, KeyNamePair client)protected KeyNamePair[]getRoles(CConnection cc, String app_user, String app_pwd, boolean force)Deprecated.KeyNamePair[]getWarehouses(KeyNamePair org)Load Warehousesstatic PropertiesinitTest(boolean isClient)Test Init - Set Environment for testsstatic booleanisJavaOK(boolean isClient)Java Version TestbooleanisMFARequired(String registerCookie)Validate if MFA is required taking into account the registerCookie and the IPAddressbooleanisPasswordExpired()StringloadPreferences(KeyNamePair org, KeyNamePair warehouse, Timestamp timestamp, String printerName)Load Preferences into Context for selected client.voidloadUserPreferences()Load preferences based on userStringvalidateLogin(KeyNamePair org)Validate Login
-
-
-
Constructor Detail
-
Login
public Login(Properties ctx)
Login- Parameters:
ctx- context
-
-
Method Detail
-
getLoginErrMsg
public String getLoginErrMsg()
-
isPasswordExpired
public boolean isPasswordExpired()
-
initTest
public static Properties initTest(boolean isClient)
Test Init - Set Environment for tests- Parameters:
isClient- client session- Returns:
- Context
-
isJavaOK
public static boolean isJavaOK(boolean isClient)
Java Version Test- Parameters:
isClient- client connection- Returns:
- true if Java Version is OK
-
getRoles
protected KeyNamePair[] getRoles(CConnection cc, String app_user, String app_pwd, boolean force)
Deprecated.(Test) Client Login.- Get Connection - Compare User info
Sets Context with login info
- Parameters:
cc- connectionapp_user- userapp_pwd- pwdforce- ignore pwd- Returns:
- Array of Role KeyNamePair or null if error The error (NoDatabase, UserPwdError, DBLogin) is saved in the log
-
getRoles
public KeyNamePair[] getRoles(Principal app_user)
Deprecated.use public KeyNamePair[] getRoles(String app_user, KeyNamePair client)(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
public KeyNamePair[] getRoles(String app_user, String app_pwd)
Deprecated.use public KeyNamePair[] getRoles(String app_user, KeyNamePair client)Client Login.Compare User Info
Sets Context with login info
- Parameters:
app_user- user idapp_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)
Load Clients.Sets Role info in context and loads its clients
- Parameters:
role- role information- Returns:
- list of valid client KeyNodePairs or null if in error
-
getOrgs
public KeyNamePair[] getOrgs(KeyNamePair rol)
Load Organizations.Sets Client info in context and loads its organization, the role has access to
- Parameters:
rol-- Returns:
- list of valid Org KeyNodePairs or null if in error
-
getWarehouses
public KeyNamePair[] getWarehouses(KeyNamePair org)
Load Warehouses- Parameters:
org- organization- Returns:
- Array of Warehouse Info
-
validateLogin
public String validateLogin(KeyNamePair org)
Validate Login- Parameters:
org- log-in org- Returns:
- error message
-
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 informationwarehouse- optional warehouse informationtimestamp- optional dateprinterName- optional printer info- Returns:
- AD_Message of error (NoValidAcctInfo) or ""
-
loadUserPreferences
public void loadUserPreferences()
Load preferences based on user
-
batchLogin
public boolean batchLogin(Timestamp loginDate)
Batch Login using Ini valuesAdempiere.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
public Principal getPrincipal()
Get SSO Principal- Returns:
- principal
-
getClients
public KeyNamePair[] getClients(String app_user, String app_pwd)
-
getClients
public KeyNamePair[] getClients(String app_user, String app_pwd, String roleTypes)
Validate Client Login. Sets Context with login info- Parameters:
app_user- user idapp_pwd- passwordroleTypes- comma separated list of the role types allowed to login (NULL can be added)- Returns:
- client array or null if in error.
-
getRoles
public KeyNamePair[] getRoles(String app_user, KeyNamePair client)
-
getRoles
public KeyNamePair[] getRoles(String app_user, KeyNamePair client, String roleTypes)
Load Roles.Sets Client info in context and loads its roles
- Parameters:
client- client informationroleTypes- 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()
-
isMFARequired
public boolean isMFARequired(String registerCookie)
Validate if MFA is required taking into account the registerCookie and the IPAddress- Parameters:
registerCookie-- Returns:
-
-