Compiere 3.1

org.compiere.util
Class Login

java.lang.Object
  extended by 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

Constructor Summary
Login(Ctx ctx)
          Login
 
Method Summary
 boolean batchLogin()
          Batch Login with system date
 boolean batchLogin(Timestamp loginDate, String printerName)
          Batch Login using Ini values Compiere.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"); Login login = new Login(Env.getCtx()); login.batchLogin();
 int getAD_Role_ID()
          Get Role
 int getAD_User_ID()
          Get User
 KeyNamePair[] getClients(KeyNamePair role)
          Load Clients.
 KeyNamePair[] getOrgs(KeyNamePair client)
          Load Organizations.
 Principal getPrincipal()
          Get SSO Principal
 KeyNamePair[] getRoles()
          Attempt to change roles using a previously authenticated Login.
protected  KeyNamePair[] getRoles(CConnection cc, String app_user, String app_pwd, boolean force)
          (Test) Client Login.
 KeyNamePair[] getRoles(Principal app_user)
          (Web) Client Login.
 KeyNamePair[] getRoles(String app_user, String app_pwd)
          Client Login.
 KeyNamePair[] getRoles(String app_user, String app_pwd, int W_Store_ID)
          Client Login.
 KeyNamePair[] getWarehouses(KeyNamePair org)
          Load Warehouses
static Ctx initTest(boolean isClient)
          Test Init - Set Environment for tests
static boolean isJavaOK(boolean isClient)
          Java Version Test
 String loadPreferences(KeyNamePair org, KeyNamePair warehouse, Timestamp timestamp, String printerName)
          Load Preferences into Context for selected client.
 Locale setLanguage(String langInfo)
          Set Language
 String validateLogin(KeyNamePair org)
          Validate Login.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Login

public Login(Ctx ctx)
Login

Parameters:
ctx - context
Method Detail

initTest

public static Ctx 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)
(Test) Client Login. (Translation, print.Viewer)

- 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

public KeyNamePair[] getRoles(Principal app_user)
(Web) Client Login. (Web Store)

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()
Attempt to change roles using a previously authenticated Login. This function should only be called after a successful login.

Returns:
role array or null if in error.

getRoles

public KeyNamePair[] getRoles(String app_user,
                              String app_pwd)
Client Login. (CM, Swing)

Compare User Info

Sets Conext 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

getRoles

public KeyNamePair[] getRoles(String app_user,
                              String app_pwd,
                              int W_Store_ID)
Client Login. (Web UI)

Compare User Info

Sets Conext with login info

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

getAD_Role_ID

public int getAD_Role_ID()
Get Role

Returns:
AD_Role_ID (or -1 - SystemAdmin is 0)

getAD_User_ID

public int getAD_User_ID()
Get User

Returns:
AD_User_ID (or -1 - System is 0)

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 client)
Load Organizations.

Sets Client info in context and loads its organization, the role has access to

Parameters:
client - client information
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. Creates session and calls ModelValidationEngine

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 information
warehouse - optional warehouse information
timestamp - optional date
printerName - optional printer info
Returns:
AD_Message of error (NoValidAcctInfo) or ""

batchLogin

public boolean batchLogin(Timestamp loginDate,
                          String printerName)
Batch Login using Ini values Compiere.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"); Login login = new Login(Env.getCtx()); login.batchLogin();

Parameters:
loginDate - optional login date
printerName - optional printer name
Returns:
true if logged in using Ini values

setLanguage

public Locale setLanguage(String langInfo)
Set Language

Parameters:
langInfo - language (en) or locale (en-US) or display name (English)
Returns:
locale (set as default for client)

batchLogin

public boolean batchLogin()
Batch Login with system date

Returns:
true if logged in

getPrincipal

public Principal getPrincipal()
Get SSO Principal

Returns:
principal

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.