} // findInterestArea /// <summary> /// Log Access /// </summary> /// <param name="AD_Client_ID">client</param> /// <param name="AD_User_ID">user</param> /// <param name="R_InterestArea_ID">interested area</param> /// <param name="A_Asset_ID">id</param> /// <param name="info">info</param> /// <param name="error">error</param> /// <param name="remoteHost">remote info</param> /// <param name="remoteAddr">remote info</param> /// <returns></returns> private MLdapAccess LogAccess(int AD_Client_ID, int AD_User_ID, int R_InterestArea_ID, int A_Asset_ID, String info, String error, String remoteHost, String remoteAddr) { if (error != null) { log.Log(Level.CONFIG, info); _error++; } else { log.Log(Level.INFO, info); _ok++; } // MLdapAccess access = new MLdapAccess(GetCtx(), 0, null); access.SetAD_Client_ID(AD_Client_ID); access.SetAD_Org_ID(0); access.SetAD_LdapProcessor_ID(GetAD_LdapProcessor_ID()); access.SetAD_User_ID(AD_User_ID); access.SetR_InterestArea_ID(R_InterestArea_ID); access.SetA_Asset_ID(A_Asset_ID); access.SetRemote_Host(remoteHost); access.SetRemote_Addr(remoteAddr); access.SetIsError(error != null); access.SetSummary(info); access.Save(); return(access); } // logAccess
} // authenticateSubscription /// <summary> /// Authenticate Product Asset /// </summary> /// <param name="ldapUser">user</param> /// <param name="AD_User_ID">id</param> /// <param name="usr">user authentification (email, ...)</param> /// <param name="M_Product_ID">product</param> /// <param name="AD_Client_ID">client</param> /// <param name="remoteHost">remote info</param> /// <param name="remoteAddr">remote info</param> /// <returns>user with error message set if error</returns> private MLdapUser AuthenticateAsset(MLdapUser ldapUser, int AD_User_ID, String usr, int M_Product_ID, int AD_Client_ID, String remoteHost, String remoteAddr) { String error = null; String info = null; // Query 2 - Validate Asset MAsset asset = null; String sql = "SELECT * " + "FROM A_Asset " + "WHERE M_Product_ID=@param1" + " AND AD_User_ID=@param2"; // only specific user // Will have problems with multiple assets SqlParameter[] param = new SqlParameter[2]; IDataReader idr = null; try { //pstmt = DataBase.prepareStatement (sql, null); //pstmt.setInt (1, M_Product_ID); param[0] = new SqlParameter("@param1", M_Product_ID); //pstmt.setInt (2, AD_User_ID); param[1] = new SqlParameter("@param2", AD_User_ID); idr = DataBase.DB.ExecuteReader(sql, param, null); if (idr.Read()) { asset = new MAsset(GetCtx(), idr, null); } idr.Close(); } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); error = "System Error (3)"; } // System Error if (error != null) { _error++; ldapUser.SetErrorString(error); return(ldapUser); } int A_Asset_ID = 0; if (asset == null) { error = "@UserNoAsset@ User="******"No Asset - " + usr + " - " + M_Product_ID; } else if (!asset.IsActive()) { A_Asset_ID = asset.GetA_Asset_ID(); error = "@UserNoAsset@ User="******"Asset not active - " + usr; } else if (!asset.IsActive(true)) { A_Asset_ID = asset.GetA_Asset_ID(); error = "@UserNoAsset@ User="******" @GuaranteeDate@=" + asset.GetGuaranteeDate(); info = "Expired - " + usr + " - GuaranteeDate=" + asset.GetGuaranteeDate(); } else { info = "Asset - " + usr; } if (error != null) // should use Language of the User { LogAccess(AD_Client_ID, AD_User_ID, 0, A_Asset_ID, info, error, remoteHost, remoteAddr); ldapUser.SetErrorString(Msg.Translate(GetCtx(), error)); return(ldapUser); } // Done OK MLdapAccess log = LogAccess(AD_Client_ID, AD_User_ID, 0, asset.GetA_Asset_ID(), info, null, remoteHost, remoteAddr); MAssetDelivery ad = new MAssetDelivery(asset, null, log.ToString(), AD_User_ID); ad.SetRemote_Host(remoteHost); ad.SetRemote_Addr(remoteAddr); ad.Save(); return(ldapUser); } // authenticateAsset