diff --git a/400-SOURCECODE/AIAHTML5+FlexCB/AppStartup.mxml b/400-SOURCECODE/AIAHTML5+FlexCB/AppStartup.mxml new file mode 100644 index 0000000..4e17fe7 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5+FlexCB/AppStartup.mxml @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + diff --git a/400-SOURCECODE/AIAHTML5+FlexCB/Default.aspxPassingunamePassForOldCB b/400-SOURCECODE/AIAHTML5+FlexCB/Default.aspxPassingunamePassForOldCB new file mode 100644 index 0000000..02bc003 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5+FlexCB/Default.aspxPassingunamePassForOldCB @@ -0,0 +1,225 @@ +<%@ Page Language="C#" AutoEventWireup="True" Inherits="_Default" Codebehind="Default.aspx.cs" %> + + + + + + + A.D.A.M. Interactive Anatomy + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ +
+ + \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5+FlexCB/ShadowedTextToggleButtonBar.as b/400-SOURCECODE/AIAHTML5+FlexCB/ShadowedTextToggleButtonBar.as new file mode 100644 index 0000000..1a188d8 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5+FlexCB/ShadowedTextToggleButtonBar.as @@ -0,0 +1,154 @@ +package com.magic.component +{ + import flash.events.MouseEvent; + + import mx.controls.ToggleButtonBar; + import mx.core.ClassFactory; + import mx.core.IFlexDisplayObject; + import mx.core.IUITextField; + import mx.styles.CSSStyleDeclaration; + import flash.events.KeyboardEvent; + import mx.styles.StyleManager; + + public class ShadowedTextToggleButtonBar extends ToggleButtonBar + { + private var navItemFactory:ClassFactory; + + private var buttonStyleNameProp:String = "buttonStyleName"; + + /** + * @private + * Name of style used to specify buttonStyleName. + * Overridden by TabBar. + */ + private var firstButtonStyleNameProp:String = "firstButtonStyleName"; + + /** + * @private + * Name of style used to specify buttonStyleName. + * Overridden by TabBar. + */ + private var lastButtonStyleNameProp:String = "lastButtonStyleName"; + + /** + * @private + * Name of style used to specify buttonWidth. + * Overridden by TabBar. + */ + private var buttonWidthProp:String = "buttonWidth"; + + /** + * @private + * Name of style used to specify buttonHeight. + * Overridden by TabBar. + */ + private var buttonHeightProp:String = "buttonHeight"; + + private var recalcButtonWidths:Boolean = false; + + /** + * @private + * Flag indicating whether buttons heights should be recalculated. + */ + private var recalcButtonHeights:Boolean = false; + + public function ShadowedTextToggleButtonBar() + { + //TODO: implement function + super(); + navItemFactory = new ClassFactory(ShadowedTextButton); + } + // overridden to block keyboard temporarily. + override protected function keyDownHandler(event:KeyboardEvent):void + { + //do nothing + } + override protected function createNavItem(strLabel:String, clsIcon:Class=null):IFlexDisplayObject + { + var newButton:ShadowedTextButton = ShadowedTextButton(navItemFactory.newInstance()); + // Set tabEnabled to false so individual buttons don't get focus. + newButton.focusEnabled = false; + + var buttonStyleName:String = getStyle(buttonStyleNameProp); + var firstButtonStyleName:String = getStyle(firstButtonStyleNameProp); + var lastButtonStyleName:String = getStyle(lastButtonStyleNameProp); + + if (!buttonStyleName) + buttonStyleName = "ButtonBarButton"; + if (!firstButtonStyleName) + firstButtonStyleName = buttonStyleName; + if (!lastButtonStyleName) + lastButtonStyleName = buttonStyleName; + + var n:int = numChildren; + if (n == 0) + { + newButton.styleName = buttonStyleName; + } + else + { + if(strLabel!="Curriculum Builder"){ + newButton.styleName = lastButtonStyleName; + //var CBuilderButton:ShadowedTextButton = ShadowedTextButton(getChildAt(6)); + //CBuilderButton.setStyle("color","#000000"); + } + else{ + newButton.setStyle("color","#0000FF"); + } + var cssStyleDeclaration:CSSStyleDeclaration = + StyleManager.getStyleDeclaration("." + lastButtonStyleName); + + if (cssStyleDeclaration && + !cssStyleDeclaration.getStyle("focusRoundedCorners")) + { + newButton.setStyle("focusRoundedCorners", "tr br"); + } + + // Refresh the skins for the last button that was in this position. + var first:Boolean = (n == 1); + var lastButton:ShadowedTextButton = ShadowedTextButton(getChildAt(first ? 0 : n - 1)); + + if (first) + { + lastButton.styleName = firstButtonStyleName; + cssStyleDeclaration = + StyleManager.getStyleDeclaration("." + firstButtonStyleName); + + if (cssStyleDeclaration && + !cssStyleDeclaration.getStyle("focusRoundedCorners")) + { + lastButton.setStyle("focusRoundedCorners", "tl bl"); + } + } + else + { + lastButton.styleName = buttonStyleName; + cssStyleDeclaration = + StyleManager.getStyleDeclaration("." + buttonStyleName); + + if (cssStyleDeclaration && + !cssStyleDeclaration.getStyle("focusRoundedCorners")) + { + lastButton.setStyle("focusRoundedCorners", ""); + } + } + + // lastButton.changeSkins(); + lastButton.invalidateDisplayList(); + } + + newButton.label = strLabel; + // newButton.setStyle("icon", icon); + newButton.minHeight=35; + //newButton.maxHeight=38; + newButton.addEventListener(MouseEvent.CLICK, clickHandler); + + this.addChild(newButton); + + recalcButtonWidths = recalcButtonHeights = true; + newButton.addTextFilter(); + return newButton; + } + + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj index 90933ca..033b085 100644 --- a/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj +++ b/400-SOURCECODE/AIAHTML5.API/AIAHTML5.API.csproj @@ -120,6 +120,7 @@ + @@ -131,6 +132,7 @@ Global.asax + @@ -146,7 +148,9 @@ - + + Designer + SettingsSingleFileGenerator Settings.Designer.cs diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs index 04a295c..c203cd8 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/AIAConstants.cs @@ -44,5 +44,44 @@ namespace AIAHTML5.API.Constants public const string LAB_EXERCISE_SAVE_SUCCESS = "Your lab exercise attempt is saved."; public const string LAB_EXERCISE_SAVE_FAILURE = "We are unable to save your lab exercise attempt, please try again."; public const string SAVED_LAB_EXERCISE_NOT_FOUND = "Saved Lab Exercise not found."; + public const string VALIDATED_CLIENT = "Valid Client."; + public const string INVALID_CLIENT = "InValid Client."; + public const string MSG_NOT_AUTHORIZE_SITE_USER = "User is not authorized."; + + + public const string STATUS_OK = "ok"; + public const string STATUS_NOT_OK = "notok"; + public const int NO_ERROR = 0; + public const int RUN_TIME_EXCEPTION = 10000; + + public const String SITE_IP = "siteIP"; + public const String SITE_ID = "siteId"; + public const String TERM_CONDITION = "termCondition"; + public const String MODESTY_SETTING = "modestySetting"; + + public const Byte SUPER_ADMIN = 1; + public const Byte GENERAL_ADMIN = 2; + public const String USER_NAME = "username"; + public const String PASSWORD = "password"; + public const String ERROR_ID = "errorId"; + public const String LICENSE_ACTIVE = "licenceActive"; + public const String ACCOUNT_NUMBER = "accountNumber"; + public const String LICENSE_TYPE_ID = "licenceTypeId"; + public const String TOTAL_LOGIN = "totalLogin"; + public const String EDITION_ID = "editionId"; + public const String URL_REFERER = "urlReferer"; + public const String USER_CONTEXT = "usercontext"; + + public const Byte CONCURRENT_USER = 6; + public const Byte SINGLE_USER = 5; + public const Byte SITE_USER = 9; + + public const String LICENSE_ID = "licenseId"; + public const Byte LICENSE_TYPE_CONCURRENT = 1; + public const Byte LICENSE_TYPE_SINGLE = 2; + public const Byte LICENSE_TYPE_SITE = 3; + public const Byte LICENSE_TYPE_RESELLER = 4; + public const Byte LICENSE_TYPE_TEST = 5; + } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs index a2d5ffb..f256911 100644 --- a/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs +++ b/400-SOURCECODE/AIAHTML5.API/Constants/DBConstants.cs @@ -29,6 +29,10 @@ namespace AIAHTML5.API.Constants public const string GET_BLOCKED_USERS_BY_USER_TYPE = "GetBlockedUserByUserType"; public const string SAVE_LAB_EXERCISE_ATTEMPT = "usp_SaveLabExerciseAttempts"; public const string GET_LAB_EXERCISE = "GetLabExcerciseByUserId"; + public const string GET_LICENSEINFO_BY_SITE_URL = "GetLicenseIdBySiteUrl"; + public const string GET_LICENSE_BY_SITE_ID = "GetLicenseBySiteId"; + public const string GET_LICENSE_EDITIONS_FOR_MODESTY = "GetLicenseEditionsForModesty"; + public const string GET_PRODUCT_FEATURES = "GetProductFeatures"; } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs new file mode 100644 index 0000000..4209f1e --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Controllers/ClientController.cs @@ -0,0 +1,112 @@ +using AIAHTML5.API.Constants; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Web.Http; +using AIAHTML5.API.Models; +using Newtonsoft.Json.Linq; +using System.Data.SqlClient; +using System.Collections; +using log4net; +using Newtonsoft.Json; + +namespace AIAHTML5.API.Controllers +{ + public class ClientController : ApiController + { + // GET api/client + public IEnumerable Get() + { + return new string[] { "value1", "value2" }; + } + + // GET api/client/5 + public string Get(int id) + { + return "value"; + } + + // POST api/client + public HttpResponseMessage Post([FromBody]JObject siteUrl) + { + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); + logger.Debug("inside POST in ClientController"); + try{ + HttpResponseMessage response = null; + if (siteUrl != null) + { + if (!string.IsNullOrEmpty(siteUrl["siteIP"].ToString()) && !string.IsNullOrEmpty(siteUrl["remoteIPAddress"].ToString()) && !string.IsNullOrEmpty(siteUrl["accountNumber"].ToString()) && !string.IsNullOrEmpty(siteUrl["edition"].ToString())) + + { + + int siteId = AIAHTML5.API.Models.Users.ValidateLicenseSiteIP(siteUrl["siteIP"].ToString(), siteUrl["remoteIPAddress"].ToString(), siteUrl["accountNumber"].ToString(), Convert.ToByte(siteUrl["edition"].ToString())); + if (siteId > 0) + { + dynamic uerinfo = AIAHTML5.API.Models.Users.ValidateSiteLogin(siteUrl["siteIP"].ToString(), siteUrl["accountNumber"].ToString(), siteUrl["urlReferer"].ToString(), siteUrl["edition"].ToString(), siteId); + if (uerinfo != null) + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(JsonConvert.SerializeObject(uerinfo)) }; + else + { + //ser user = new User(); + //user.LoginFailureCauseId = AIAConstants.INVALID_CLIENT; + //dynamic userinfo = user; + //response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(userInfo) }; + + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.INVALID_CLIENT) }; + } + } + + else + { + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MSG_NOT_AUTHORIZE_SITE_USER) }; + + } + } + } + else + { + response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = null }; + + } + + return response; + } + catch (SqlException e) + { + + logger.Fatal("SqlException occured for siteUrl =" + siteUrl["siteIP"].ToString() + " and siteUrl= " + siteUrl["siteIP"].ToString() + " & accountNumber = " + siteUrl["accountNumber"].ToString() + " &edition = " + siteUrl["edition"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + + ArrayList supportMailList = UserUtility.GetSupportMailList(); + string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + UserUtility.SendEmailForException(0, supportMailList, "", mailSubject, mailBody,true,siteUrl); + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; + } + catch (Exception e) + { + + logger.Fatal("Exception occured for loginId =" + siteUrl["siteIP"].ToString() + " and siteUrl= " + siteUrl["siteIP"].ToString() + " & accountNumber = " + siteUrl["accountNumber"].ToString() + " &edition = " + siteUrl["edition"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); + ArrayList supportMailList = UserUtility.GetSupportMailList(); + string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; + UserUtility.SendEmailForException(0, supportMailList, "", mailSubject, mailBody, true, siteUrl); + + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; + + } + } + + // PUT api/client/5 + public void Put(int id, [FromBody]string value) + { + } + + // DELETE api/client/5 + public void Delete(int id) + { + } + } +} diff --git a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs index 7c48a86..11be152 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/DBModel.cs @@ -980,5 +980,151 @@ namespace AIAHTML5.API.Models // return 1; //} + + internal DataTable GetLicenseInfoBySiteUrl(string licenceAccount, int editionId) + { + logger.Debug(" inside GetLicenseIdBySiteUrl for UserId= " + editionId + ",licenceAccount = " + licenceAccount); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSEINFO_BY_SITE_URL; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@sLicenseAccount", licenceAccount); + cmd.Parameters.AddWithValue("@iEditionId", editionId); + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + } + + internal DataTable GetLicenseBySiteId(int siteId) + { + logger.Debug(" inside GetLicenseBySiteId for siteId= " + siteId); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSE_BY_SITE_ID; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@sSiteId", siteId); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + + } + internal DataTable GetEditionsForModesty(int licenceId, int buildingLevelAcc) + { + logger.Debug(" inside GetEditionsForModesty for licenceId= " + licenceId); + + // SiteUrl siteUrl = null; + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_LICENSE_EDITIONS_FOR_MODESTY; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@iLicenseId", licenceId); + cmd.Parameters.AddWithValue("@iBuildingLevelId", buildingLevelAcc); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + //if (dt != null && dt.Rows.Count > 0) + //{ + // siteUrl = new SiteUrl(); + // foreach (DataRow dr in dt.Rows) + // { + // siteUrl.Id = Convert.ToInt32(dr["Id"]); + // siteUrl.SiteIp = dr["SiteIp"].ToString(); + // siteUrl.SiteIpTo = dr["SiteIpTo"].ToString(); + // siteUrl.SiteMasterIpTo = dr["SiteMasterIpTo"].ToString(); + // siteUrl.IsMaster = Convert.ToInt32(dr["IsMaster"]); + + // } + //} + + //return siteUrl; + return dt; + } + + internal Hashtable GetEditionFeatures(byte editionId) + { + Hashtable objFeatures = new Hashtable(); + + DataTable dt = null; + + SqlConnection conn = new SqlConnection(dbConnectionString); + SqlCommand cmd = new SqlCommand(); + cmd.Connection = conn; + cmd.CommandText = DBConstants.GET_PRODUCT_FEATURES; + cmd.CommandType = CommandType.StoredProcedure; + cmd.Parameters.AddWithValue("@EditionId", editionId); + + SqlDataAdapter da = new SqlDataAdapter(); + da.SelectCommand = cmd; + dt = new DataTable(); + da.Fill(dt); + + if (dt != null && dt.Rows.Count > 0) + { + foreach (DataRow dr in dt.Rows) + { + if (Convert.ToBoolean(dr["IsActive"])) + { + objFeatures.Add(dr["Id"], dr["Title"]); + } + + + } + } + + return objFeatures; + } } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs b/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs new file mode 100644 index 0000000..44785c7 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.API/Models/IPValidator.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Web; + +namespace AIAHTML5.API.Models +{ + public class IPValidator + { + public static Double ChangeIpToDouble(String ipVal) + { + String[] resultArray = new String[20]; + //Array resultArray ; + String n = ipVal; + String[] array = n.Split('.'); + for (int i = 0; i < array.Length; i++) + { + if (array[i].Length == 1) + { + array[i] = "00" + array[i]; + resultArray[i] = (array[i]); + } + else if (array[i].Length == 2) + { + array[i] = "0" + array[i]; + resultArray[i] = (array[i]); + } + else + { + array[i] = array[i]; + resultArray[i] = (array[i]); + } + } + + //String theContent = resultArray.ToString(); + String theContent = ""; + + for (int i = 0; i <= resultArray.Length - 1; i++) + { + if (!String.IsNullOrEmpty(resultArray[i])) + theContent += resultArray[i]; + } + theContent = (theContent == "" ? "0" : theContent); + + return Convert.ToDouble(theContent); + //return theContent; + } + + + public static bool ValidateIP(String strSiteIp, String strSiteIPTo, String strSiteMasterIPTo, String strIPToValidate, int intIsMaster) + { + Double dblSiteIP = 0; + Double dblSiteIPTo = 0; + Double dblSiteMIPTo = 0; + Double dblIPToValidate = 0; + bool boolReturn = false; + + try + { + // Convert all IP to double values + dblSiteIP = ChangeIpToDouble(((strSiteIp == "" || IsNumericIP(strSiteIp) == false) ? "0" : strSiteIp)); + dblSiteIPTo = ChangeIpToDouble(((strSiteIPTo == "" || IsNumericIP(strSiteIPTo) == false) ? "0" : strSiteIPTo)); + dblSiteMIPTo = ChangeIpToDouble(((strSiteMasterIPTo == "" || IsNumericIP(strSiteMasterIPTo) == false) ? "0" : strSiteMasterIPTo)); + dblIPToValidate = ChangeIpToDouble(((strIPToValidate == "" || IsNumericIP(strIPToValidate) == false) ? "0" : strIPToValidate)); + + if (intIsMaster > 0) + { + if (dblSiteIP == dblIPToValidate) + boolReturn = true; + + if (dblSiteIPTo > 0 && dblSiteMIPTo > 0) + { + if (isBetween(dblIPToValidate, dblSiteIPTo, dblSiteMIPTo) == true) + { + boolReturn = true; + } + } + else if (dblSiteIPTo > 0) + { + if (dblSiteIPTo == dblIPToValidate) + boolReturn = true; + } + else if (dblSiteMIPTo > 0) + { + if (dblSiteMIPTo == dblIPToValidate) + boolReturn = true; + } + } + else + { + if (dblSiteIP > 0 && dblSiteIPTo > 0) + { + if (isBetween(dblIPToValidate, dblSiteIP, dblSiteIPTo) == true) + { + boolReturn = true; + } + } + else if (dblSiteIP > 0) + { + if (dblSiteIP == dblIPToValidate) + boolReturn = true; + } + else if (dblSiteIPTo > 0) + { + if (dblSiteIPTo == dblIPToValidate) + boolReturn = true; + } + } + + return boolReturn; + } + catch (Exception objExp) + { + return false; + } + } + + public static String FormatURLToIP(String strURL) + { + strURL = strURL.Replace("www.", ""); + strURL = strURL.Replace("http://", ""); + strURL = strURL.Replace("https://", ""); + strURL = strURL.Replace("/", ""); + + if (strURL.IndexOf(":") != -1) + { + char[] delimiters = new char[] { ':' }; + string[] parts = strURL.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + strURL = parts[0]; + } + + return strURL; + } + + /// + /// + /// + /// + /// + /// + /// + private static bool isBetween(Double iNum, Double iFrom, Double iTo) + { + if (iNum == 0) + return false; + + if (iNum >= iFrom && iNum <= iTo) + { + return true; + } + return false; + } + + /// + /// + /// + /// + /// + public static bool IsNumericIP(string text) + { + //Regex objRegex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$"); + Regex objRegex = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$*\.?[0-9]+$*\.?[0-9]+$*\.?[0-9]+$"); + + return objRegex.IsMatch(text); + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/User.cs b/400-SOURCECODE/AIAHTML5.API/Models/User.cs index ba34df4..a6898d8 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/User.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/User.cs @@ -14,6 +14,11 @@ namespace AIAHTML5.API.Models public string EmailId { get; set; } public string LoginId { get; set; } public string Password { get; set; } + public string AccountNumber { get; set; } + public byte LicenseTypeId { get; set; } + public bool Modesty { get; set; } + public bool ModestyMode { get; set; } + public Hashtable objEditionFeatures { get; set; } public int? SecurityQuestionId { get; set; } public string SecurityAnswer { get; set; } public int? CreatorId { get; set; } @@ -49,6 +54,8 @@ namespace AIAHTML5.API.Models public const string RESELLER = "Reseller"; public const string TEST_ACCOUNT = "Test Account"; public const string SITE_USER = "Site User"; + + } public enum UserType @@ -113,4 +120,18 @@ namespace AIAHTML5.API.Models public string AccountNumber { get; set; } public DateTime LoginTime { get; set; } } + + public class SiteUrl + { + public int Id { get; set; } + public string SiteIp { get; set; } + public string SiteIpTo { get; set; } + public string SiteMasterIpTo { get; set; } + public int IsMaster { get; set; } + + + + + } + } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs index 52f2547..0154fb2 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/UserUtility.cs @@ -16,6 +16,7 @@ using System.Configuration; using System.Collections; using System.Data; using System.Reflection; +using Newtonsoft.Json.Linq; namespace AIAHTML5.API.Models { @@ -216,10 +217,10 @@ namespace AIAHTML5.API.Models } } - public static bool SendEmailForException(int userid, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "") + public static bool SendEmailForException(int userid, ArrayList mailToList, string sender, string mailSubject = "", string mailBody = "", bool isMailForClentSite=false, JObject info=null) { ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); - logger.Debug("Inside SendEmail with userid =" + userid); + // logger.Debug("Inside SendEmail with userid =" + userid); try { @@ -235,8 +236,14 @@ namespace AIAHTML5.API.Models lstToAddress.Add(email); } - emailMessage = "Unable to process request for userid: " + userid; - + if (isMailForClentSite && info!=null) + { + emailMessage = "Unable to process request for siteUrl =" + info["siteIP"].ToString() + " and siteIP= " + info["siteIP"].ToString() + " & accountNumber = " + info["accountNumber"].ToString() + " &edition = " + info["edition"].ToString() ; + } + else + { + emailMessage = "Unable to process request for userid: " + userid; + } if (string.IsNullOrEmpty(sender)) @@ -264,7 +271,13 @@ namespace AIAHTML5.API.Models return true; } catch (Exception ex) - { + { + if (isMailForClentSite){ + logger.Fatal("exception in SendEmail for siteUrl =" + info["siteIP"].ToString()+ ". msg= " + ex.Message + ", stacktrace= " + ex.StackTrace); + + } + + else logger.Fatal("exception in SendEmail for userid"+userid+ ". msg= " + ex.Message + ", stacktrace= " + ex.StackTrace); return false; } diff --git a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs index f070dcc..1883ca1 100644 --- a/400-SOURCECODE/AIAHTML5.API/Models/Users.cs +++ b/400-SOURCECODE/AIAHTML5.API/Models/Users.cs @@ -11,7 +11,9 @@ using AIAHTML5.API.Models; using Newtonsoft.Json; using System.Collections; using System.Data.SqlClient; - +using System.Net; +using System.Data; +using AIAHTML5.API.Constants; namespace AIAHTML5.API.Models { public class Users @@ -22,22 +24,22 @@ namespace AIAHTML5.API.Models logger.Debug("inside AuthenticateUser for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString()); dynamic userDetails = null; - - User user = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); - //string userDetails = DBModel.GetUserDetailsByLoginId2(credentials["username"].ToString()); - if (user != null) - { - logger.Debug("userDetails.loginId= " + user.LoginId); // .loginId); + User user = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); + //string userDetails = DBModel.GetUserDetailsByLoginId2(credentials["username"].ToString()); + + if (user != null) + { + logger.Debug("userDetails.loginId= " + user.LoginId); // .loginId); + + userDetails = JsonConvert.SerializeObject(user); + } + else + { + userDetails = AIAConstants.USER_NOT_FOUND; + } - userDetails = JsonConvert.SerializeObject(user); - } - else - { - userDetails = AIAConstants.USER_NOT_FOUND; - } - return userDetails; } @@ -45,32 +47,32 @@ namespace AIAHTML5.API.Models { logger.Debug(" inside GetUserByEmail for emailId = " + userInfo["emailId"]); - - User objUser = DBModel.GetUserDetailsByEmailId(userInfo["emailId"].ToString()); - //dynamic userDetails; + User objUser = DBModel.GetUserDetailsByEmailId(userInfo["emailId"].ToString()); + + //dynamic userDetails; + + if (objUser != null) + { + logger.Debug("userDetails.loginId= " + objUser.LoginId); + //return userDetails = JsonConvert.SerializeObject(objUser); + return objUser; + } + else + { + return AIAConstants.USER_NOT_FOUND; + } - if (objUser!= null) - { - logger.Debug("userDetails.loginId= " + objUser.LoginId); - //return userDetails = JsonConvert.SerializeObject(objUser); - return objUser; - } - else - { - return AIAConstants.USER_NOT_FOUND; - } - } internal static dynamic UpdatePassword(Newtonsoft.Json.Linq.JObject userInfo, string sLoginId, string sEmailId) { - - int result = DBModel.UpdateUserPassword(userInfo, sLoginId, sEmailId); - return result; - + int result = DBModel.UpdateUserPassword(userInfo, sLoginId, sEmailId); + + return result; + } internal static dynamic UpdateLicenseTerm(Newtonsoft.Json.Linq.JObject userLicenseInfo) @@ -83,13 +85,13 @@ namespace AIAHTML5.API.Models userInfo.Add("accountNumber", accountNumber); - - result = DBModel.UpdateLicenseTermStatus(accountNumber); - if (result < 0) - { - logger.Fatal("Unable to update LicenseTermAccepted status for AccountNumber =" + accountNumber); - } + result = DBModel.UpdateLicenseTermStatus(accountNumber); + + if (result < 0) + { + logger.Fatal("Unable to update LicenseTermAccepted status for AccountNumber =" + accountNumber); + } return result; } @@ -106,10 +108,10 @@ namespace AIAHTML5.API.Models logger.Debug("inside getUserDetails for loginId =" + credentials["username"].ToString() + " and password= " + credentials["password"].ToString()); User userDetails = null; - - userDetails = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); - return userDetails; + userDetails = DBModel.GetUserDetailsByLoginId(credentials["username"].ToString()); + + return userDetails; } internal static void getLicenseIdForThisUser(int userId, out int licenseId, out int editionId) @@ -120,18 +122,18 @@ namespace AIAHTML5.API.Models licenseId = 0; editionId = 0; - - DBModel objModel = new DBModel(); - Hashtable licenseEditionHash = objModel.GetLicenseDetailByUserId(userId); - if (licenseEditionHash.ContainsKey(AIAConstants.LICENSE_KEY_ID)) - licenseId = Convert.ToInt32(licenseEditionHash[AIAConstants.LICENSE_KEY_ID]); + DBModel objModel = new DBModel(); + Hashtable licenseEditionHash = objModel.GetLicenseDetailByUserId(userId); + + if (licenseEditionHash.ContainsKey(AIAConstants.LICENSE_KEY_ID)) + licenseId = Convert.ToInt32(licenseEditionHash[AIAConstants.LICENSE_KEY_ID]); + + if (licenseEditionHash.ContainsKey(AIAConstants.EDITION_KEY_ID)) + editionId = Convert.ToInt32(licenseEditionHash[AIAConstants.EDITION_KEY_ID]); + - if (licenseEditionHash.ContainsKey(AIAConstants.EDITION_KEY_ID)) - editionId = Convert.ToInt32(licenseEditionHash[AIAConstants.EDITION_KEY_ID]); - - } internal static int insertLoginDetails(int userId) @@ -139,12 +141,12 @@ namespace AIAHTML5.API.Models logger.Debug("inside insertLoginDetails for UserId =" + userId); int result = 0; - - DBModel objModel = new DBModel(); - result = objModel.InsertLoginDetails(userId); - - return result; + DBModel objModel = new DBModel(); + + result = objModel.InsertLoginDetails(userId); + + return result; } internal static bool isUSerActive(User user) @@ -160,7 +162,7 @@ namespace AIAHTML5.API.Models expirationDate = string.Empty; bool isLicenseExpired = false; - if (subscriptionDetail!= null) + if (subscriptionDetail != null) { DateTime? subscriptionValidThrough = subscriptionDetail.SubscriptionValidThrough; if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) @@ -171,7 +173,7 @@ namespace AIAHTML5.API.Models { isLicenseExpired = true; expirationDate = subscriptionDetail.SubscriptionValidThrough.Value.Date.ToString("MM/dd/yyyy").ToString(); - } + } } return isLicenseExpired; } @@ -182,13 +184,13 @@ namespace AIAHTML5.API.Models ArrayList licensedModulesList = new ArrayList(); - - DBModel objModel = new DBModel(); - licensedModulesList = objModel.GetUserModulesByLicenseId(licenseId); - - return licensedModulesList; + DBModel objModel = new DBModel(); + licensedModulesList = objModel.GetUserModulesByLicenseId(licenseId); + + + return licensedModulesList; } internal static int deletePastWrongAttempts(int userId) @@ -197,10 +199,10 @@ namespace AIAHTML5.API.Models int result = 0; - - DBModel objModel = new DBModel(); - result = objModel.DeleteIncorrectLoginAttempts(userId); - return result; + + DBModel objModel = new DBModel(); + result = objModel.DeleteIncorrectLoginAttempts(userId); + return result; } internal static int checkNoOfWrongAttempts(int userId) @@ -209,10 +211,10 @@ namespace AIAHTML5.API.Models int incorrectLoginAttemptCount = 0; - - DBModel objModel = new DBModel(); - incorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(userId); - return incorrectLoginAttemptCount; + + DBModel objModel = new DBModel(); + incorrectLoginAttemptCount = objModel.GetIncorrectLoginAttempts(userId); + return incorrectLoginAttemptCount; } internal static int saveWrongAttemptOfUser(int userId, int previousIncorrectLoginAttempts) @@ -220,18 +222,18 @@ namespace AIAHTML5.API.Models logger.Debug("inside saveWrongAttemptofUser for UserId =" + userId); int result = 0; - - DBModel objModel = new DBModel(); - if (previousIncorrectLoginAttempts < 1) - { - result = objModel.InsertIncorrectLoginAttempts(userId); - } - else - { - result = objModel.UpdateIncorrectLoginAttempts(userId); - } - + DBModel objModel = new DBModel(); + + if (previousIncorrectLoginAttempts < 1) + { + result = objModel.InsertIncorrectLoginAttempts(userId); + } + else + { + result = objModel.UpdateIncorrectLoginAttempts(userId); + } + return result; } @@ -241,16 +243,16 @@ namespace AIAHTML5.API.Models logger.Debug("inside isLicenseActive for LicenseId =" + licenseId); bool result = false; - DBModel objModel = new DBModel(); - License userLicense = objModel.GetLicenseDetailsByLicenseId(licenseId); + DBModel objModel = new DBModel(); + License userLicense = objModel.GetLicenseDetailsByLicenseId(licenseId); - if (userLicense.IsActive) - result = true; - else - result = false; - - return result; + if (userLicense.IsActive) + result = true; + else + result = false; + + return result; } internal static License getLicenseDetails(int licenseId) @@ -259,11 +261,11 @@ namespace AIAHTML5.API.Models License userLicense = null; - - DBModel objModel = new DBModel(); - userLicense = objModel.GetLicenseDetailsByLicenseId(licenseId); - - return userLicense; + + DBModel objModel = new DBModel(); + userLicense = objModel.GetLicenseDetailsByLicenseId(licenseId); + + return userLicense; } internal static LicenseSubscriptionDetails getLicenseSubscriptionDetails(int licenseId) @@ -272,19 +274,19 @@ namespace AIAHTML5.API.Models LicenseSubscriptionDetails userSubscriptionDetail = null; - - DBModel objModel = new DBModel(); - userSubscriptionDetail = objModel.GetLicenseSubscriptionDetailsByLicenseId(licenseId); - + + DBModel objModel = new DBModel(); + userSubscriptionDetail = objModel.GetLicenseSubscriptionDetailsByLicenseId(licenseId); + return userSubscriptionDetail; } internal static void isCredentialCorrect(Newtonsoft.Json.Linq.JObject credentials, User userInfo, out bool isCorrectLoginId, out bool isCorrectPassword) { isCorrectLoginId = false; - isCorrectPassword = false; + isCorrectPassword = false; - if (userInfo.Id> 0) + if (userInfo.Id > 0) { if (string.Equals(credentials["username"].ToString().ToUpper(), userInfo.LoginId.ToUpper())) isCorrectLoginId = true; @@ -302,10 +304,10 @@ namespace AIAHTML5.API.Models int result = 0; - - DBModel objModel = new DBModel(); - result = objModel.InsertUserLoginLog(accountNumber, failureId, null, edition, null); - + + DBModel objModel = new DBModel(); + result = objModel.InsertUserLoginLog(accountNumber, failureId, null, edition, null); + return result; } @@ -316,21 +318,21 @@ namespace AIAHTML5.API.Models ArrayList arrTermsOfService = new ArrayList(); - DBModel objModel = new DBModel(); - arrTermsOfService = DBModel.GetTermsAndConditions(); - + DBModel objModel = new DBModel(); + arrTermsOfService = DBModel.GetTermsAndConditions(); + return arrTermsOfService; } internal static ArrayList getAllModulesList() { logger.Debug("inside getAllModulesList"); - ArrayList modulesList = new ArrayList (); + ArrayList modulesList = new ArrayList(); + + + DBModel objModel = new DBModel(); + modulesList = objModel.GetAllModules(); - - DBModel objModel = new DBModel(); - modulesList = objModel.GetAllModules(); - return modulesList; } @@ -340,19 +342,261 @@ namespace AIAHTML5.API.Models bool isUserBlocked = false; blockTime = new DateTime(); - - DBModel objModel = new DBModel(); - BlockedUser blockedUser = objModel.GetUserBlockedStatusByUserId(userId); - if (blockedUser!= null) + DBModel objModel = new DBModel(); + BlockedUser blockedUser = objModel.GetUserBlockedStatusByUserId(userId); + + if (blockedUser != null) + { + blockTime = blockedUser.LoginTime; + isUserBlocked = true; + } + else + isUserBlocked = false; + + return isUserBlocked; + } + + + + public static int ValidateLicenseSiteIP(string strLicenseSiteIP, string remoteIpAddress, string strAccountNumber, byte editionId) + { + if (strLicenseSiteIP == null) + strLicenseSiteIP = remoteIpAddress; + + int intReturn = 0; + DBModel objDBModel = new DBModel(); + DataTable dtLicense = objDBModel.GetLicenseInfoBySiteUrl(strAccountNumber, (byte)editionId); + + if (dtLicense.Rows.Count > 0) + { + //strLicenseSiteIP + String strSiteIP = ""; + String strSiteIPTo = ""; + String strSiteMIPTo = ""; + + IPAddress[] arrHostIP = new IPAddress[2]; + try { - blockTime = blockedUser.LoginTime; - isUserBlocked = true; + arrHostIP.SetValue(IPAddress.Parse(remoteIpAddress), 0); + arrHostIP.SetValue(IPAddress.Parse(strLicenseSiteIP), 1); } - else - isUserBlocked = false; - - return isUserBlocked; + catch (Exception e) + { + //NOTE: if no domain name found we try to resolve by IP. + //arrHostIP.SetValue(Dns.GetHostAddresses(strLicenseSiteIP),1); //I SHould remove this feature it is useless + }; + + // foreach (IPAddress address in arrHostIP) + foreach (IPAddress address in arrHostIP) + { + if (address == null) + continue; + String ipStr = address.ToString(); + if (ipStr == "::1" || ipStr == "") continue; + foreach (DataRow objLicenseRow in dtLicense.Rows) + { + strSiteIP = (String.IsNullOrEmpty(objLicenseRow["SiteIp"].ToString()) ? "" : objLicenseRow["SiteIp"].ToString()); + strSiteIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteIPTo"].ToString()) ? "" : objLicenseRow["SiteIPTo"].ToString()); + //if (String.IsNullOrEmpty(objLicenseRow.SiteIPTo) == false) + //strSiteIPTo = objLicenseRow.SiteIPTo; + strSiteMIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteMasterIPTo"].ToString()) ? "" : objLicenseRow["SiteMasterIPTo"].ToString()); + if (IPValidator.ValidateIP(strSiteIP.ToLower(), strSiteIPTo.ToLower(), strSiteMIPTo.ToLower(), ipStr.ToLower(), Convert.ToInt16(objLicenseRow["IsMaster"])) == true) + { + intReturn = Convert.ToInt32(objLicenseRow["Id"]); + return intReturn; + } + } + } + + if (IPValidator.IsNumericIP(strLicenseSiteIP) == false) + { + foreach (DataRow objLicenseRow in dtLicense.Rows) + { + strSiteIP = (String.IsNullOrEmpty(objLicenseRow["SiteIp"].ToString()) ? "" : objLicenseRow["SiteIp"].ToString()); + // strSiteIPTo = (String.IsNullOrEmpty(objLicenseRow.SiteIPTo) ? "" : objLicenseRow.SiteIPTo); + if (String.IsNullOrEmpty(objLicenseRow["SiteIPTo"].ToString()) == false) + strSiteIPTo = objLicenseRow["SiteIPTo"].ToString(); + strSiteMIPTo = (String.IsNullOrEmpty(objLicenseRow["SiteMasterIPTo"].ToString()) ? "" : objLicenseRow["SiteMasterIPTo"].ToString()); + // if provided ip is not numeric, then compare directly with all the fields + if ((strLicenseSiteIP.ToLower() == strSiteIP.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteIP).ToLower()) || + (strLicenseSiteIP.ToLower() == strSiteIPTo.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteIPTo).ToLower()) || + (strLicenseSiteIP.ToLower() == strSiteMIPTo.ToLower()) || + (strLicenseSiteIP.ToLower() == IPValidator.FormatURLToIP(strSiteMIPTo).ToLower())) + { + intReturn = Convert.ToInt32(objLicenseRow["Id"]); + return intReturn; + } + } + } + } + return intReturn; + } + + public static User ValidateSiteLogin(String strSiteIP, String strAcccountNumber, String strUrlReferer, string strEdition, int intSiteId) + { + Int32 intUserId = 0; + bool isExpired = false; + User userInfo = null; + //try { + Int16 intErrorID = ErrorHelper.E_NO_ERROR; + String strStatus = AIAConstants.STATUS_OK; + + int intLicenseId = 0; + int intEditionId = Convert.ToInt16(strEdition); + + DateTime dtLogDate = DateTime.Now; + //strSiteIP = (String)objRequest.GetData(AIAConstants.SITE_IP); + //strAcccountNumber = (String)objRequest.GetData(AIAConstants.ACCOUNT_NUMBER); + //intEditionId = Convert.ToInt16(objRequest.GetData(AIAConstants.EDITION_ID)); + //strUrlReferer = (String)objRequest.GetData(AIAConstants.URL_REFERER); + //strEdition = (String)objRequest.GetData(AIAConstants.EDITION_ID); + //intSiteId = (Int32)objRequest.GetData(AIAConstants.SITE_ID); + //AdminDAL.AdminDal.GetLicenseBySiteIdDataTable dtLicense = new ADAM.AIA50.AdminDAL.AdminDal.GetLicenseBySiteIdDataTable(); + if (string.IsNullOrEmpty(strAcccountNumber)) + { + //----logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.ACCOUNT_NUMBER_NOT_NULL, strSiteIP, strEdition, strUrlReferer); + //intErrorID = ErrorHelper.E_ACCOUNT_NUMBER_NOT_NULL; + //strStatus = AIAConstants.STATUS_NOT_OK; + + userInfo.LoginFailureCauseId = ErrorHelper.E_ACCOUNT_NUMBER_NOT_NULL; + } + else if (string.IsNullOrEmpty(strEdition)) + { + strEdition = "0"; + //----logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.EDITION_ID_NOT_NULL, strSiteIP, strEdition, strUrlReferer); + //intErrorID = ErrorHelper.E_EDITION_ID_NOT_NULL; + //strStatus = AIAConstants.STATUS_NOT_OK; + userInfo.LoginFailureCauseId = ErrorHelper.E_EDITION_ID_NOT_NULL; + + } + else + { + DBModel objDBModel = new DBModel(); + DataTable dtLicense = objDBModel.GetLicenseBySiteId(intSiteId); + if (dtLicense.Rows.Count > 0) + { + //foreach (DataRow licRow in dtLicense.Rows) + //{ + DataRow licRow = dtLicense.Rows[0]; + //isExpired = LicenseHelper.IsLicenseExpired(licRow["Id"]); + userInfo = new User(); + userInfo.LicenseInfo = AIAHTML5.API.Models.Users.getLicenseDetails(Convert.ToInt32(licRow["Id"])); + + if (userInfo.LicenseInfo != null) + { + //05.3 get licenseSubscription details + userInfo.LicenseSubscriptions = AIAHTML5.API.Models.Users.getLicenseSubscriptionDetails( userInfo.LicenseInfo.Id); + + //05.4 check the License expiration irespective of either user is active or not because on AIA + //we shows the License expiration message for inactive users too + + + if (userInfo.LicenseSubscriptions != null) + { + DateTime? subscriptionValidThrough = userInfo.LicenseSubscriptions.SubscriptionValidThrough; + if (subscriptionValidThrough != null && subscriptionValidThrough.Value.Date >= DateTime.Now.Date) + { + isExpired = false; + } + else + { + isExpired = true; + } + } + + + + if (!isExpired && Convert.ToBoolean(licRow["IsActive"]) == true) + { + //User objUserContext = new User(); + userInfo.Id = 0; + userInfo.FirstName = licRow["LicenseeFirstName"].ToString(); + userInfo.LastName = licRow["LicenseeLastName"].ToString(); + userInfo.UserTypeId = AIAConstants.SITE_USER; + if (licRow["EmailId"].ToString() != null) + { + userInfo.EmailId = licRow["EmailId"].ToString(); + } + else + { + userInfo.EmailId = null; + } + userInfo.AccountNumber = strAcccountNumber; + userInfo.EditionId = (Byte)intEditionId; + userInfo.LicenseTypeId = (byte)licRow["LicenseTypeId"]; + userInfo.LicenseId = Convert.ToInt32(licRow["Id"]); + userInfo.LoginId = ""; + userInfo.Modesty = (bool)licRow["IsModesty"]; + //Retreive ModestyMode + userInfo.ModestyMode = false; + + intLicenseId = Convert.ToInt32(licRow["Id"]); + + + DataTable dtblEditionForModesty = new DBModel().GetEditionsForModesty(userInfo.LicenseId, 0); + //This table result set should return always have 0 or 1 record if modesty mode is present. + foreach (DataRow drEditionForModesty in dtblEditionForModesty.Rows) + { + if ((bool)drEditionForModesty["IsModesty"]) + { + userInfo.Modesty = true; + userInfo.ModestyMode = true; + } + } + + // get edition features details + userInfo.objEditionFeatures = objDBModel.GetEditionFeatures((Byte)intEditionId); + + + + if (intLicenseId > 0) + userInfo.Modules = getModuleListByLicenseId(intLicenseId); + else + userInfo.Modules = getAllModulesList(); + + // objResponse.AddData(LoginConst.USER_CONTEXT, objUserContext); + + + // Hashtable arrModuleList = LicenseHelper.GetInstance().GetAllModuleByLicenseId(objLicenseRow.Id); + //if (arrModuleList[9].Equals(true)) { + // SessionManager.GetInstance().AddModSession("ModuleNameIP10", "IP10"); + //} + + //logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, 0, strSiteIP, strEdition, strUrlReferer); + } + else + { + // logAuthenticationTryForAccountNumber(strAcccountNumber, dtLogDate, ErrorHelper.LICENSE_INACTIVE, strSiteIP, Convert.ToString(intEditionId), strUrlReferer); + // intErrorID = ErrorHelper.E_LICENCE_IS_INACTIVE; + // strStatus = AIAConstants.STATUS_NOT_OK; + userInfo.LoginFailureCauseId = ErrorHelper.LICENSE_INACTIVE; + } + } + else + { + + // intErrorID = ErrorHelper.E_EDITION_NOT_LINKED_WITH_SITE; + // strStatus = AIAConstants.STATUS_NOT_OK; + userInfo.LoginFailureCauseId = ErrorHelper.E_EDITION_NOT_LINKED_WITH_SITE; + } + //} + } + } + //objResponse.ErrorCode = intErrorID; + //objResponse.Status = strStatus; + //objResponse.ErrorDesc = ErrorHelper.GetInstance().GetErrorDescriptionHelper(intErrorID).ToString(); + //} catch (Exception objExp) { + // objResponse.Status = GlobalConstant.STATUS_NOT_OK; + // objResponse.ErrorCode = GlobalConstant.RUN_TIME_EXCEPTION; + // objResponse.strErrorDesc = objExp.Message; + //} + //if (isExpired != null && (bool)isExpired["result"]) + // objResponse.strErrorDesc = objResponse.strErrorDesc.Replace("{0}", (string)isExpired["date"]); + //return intUserId; + return userInfo; } } } \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj index 0fb61dc..9bb9c3a 100644 --- a/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj +++ b/400-SOURCECODE/AIAHTML5.Web/AIAHTML5.Web.csproj @@ -45202,7 +45202,8 @@ - + + @@ -45445,6 +45446,20 @@ ..\packages\log4net.2.0.7\lib\net45-full\log4net.dll True + + + + + + + + + index.aspx + ASPXCodeBehind + + + index.aspx + 10.0 diff --git a/400-SOURCECODE/AIAHTML5.Web/Web.config b/400-SOURCECODE/AIAHTML5.Web/Web.config index 9a16866..d92fcca 100644 --- a/400-SOURCECODE/AIAHTML5.Web/Web.config +++ b/400-SOURCECODE/AIAHTML5.Web/Web.config @@ -49,6 +49,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js index d6f0664..1b3231f 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/CurrBuildController.js @@ -1,90 +1,106 @@ -AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location", -function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location) { - - // $rootScope.currentActiveModuleTitle = pages[6].name; - $scope.showTabButton = false; - $scope.listCurriculumBuilder = null; - $scope.dataPopup = null; - $scope.countLeftlist; - $scope.countRightlist; - $scope.IsVisible = function () { - $scope.scroll(); - - } - - $scope.scroll = function () { - // $window.scrollTo(0, 0); - $("html,body").scrollTop(0); - //alert("scroll"); - } - //load json data - $scope.loadCurriculumBuiderData = function () { - - if ($rootScope.refreshcheck == null) { - $location.path('/'); - } - //get current path - var currentURL = $location.path(); - var selectedModuleName = ''; - //set module title - angular.forEach($rootScope.userModules, function (value, key) { - if (value.slug === currentURL.replace('/', '')) { - selectedModuleName = value.name; - } - $rootScope.currentActiveModuleTitle = selectedModuleName; - }) - - //get current path - var currentURL = $location.path(); - - $http({ method: 'GET', url: 'content/data/json/cb/cb_list_content.json' }).success(function (data) { - - $scope.listCurriculumBuilder = data; - //load default body view list - $scope.getCBViewList(); - }) - .error(function (data, status, headers, config) { - console.log(data); - }); - } - //get CB body view list - $scope.getCBViewList = function ($event) { - - $('#leftBodyViewList').empty(); - $scope.countLeftlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length / 2; - $scope.loadleftBodyViewList = new jinqJs() - .from($scope.listCurriculumBuilder.slideshows.slideshow) - .select(); - for (var i = 0; i < $scope.countLeftlist; i++) { - console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); - //alert($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); - var $el = $('
  • ' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '
  • ').appendTo('#leftBodyViewList'); - $compile($el)($scope); - } - - $scope.countRightlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length; - for (var i = $scope.countLeftlist; i < $scope.countRightlist; i++) { - console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); - var $el1 = $('
  • ' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '
  • ').appendTo('#rightBodyViewList'); - $compile($el)($scope); - } - - } - - $scope.loadSlideShowXmldata = function (e) { - - // alert(e); - $http({ method: 'GET', url: 'content/data/json/cb/SlideShow/AIA_Curriculum_Builder_Guide.sldshw' }).success(function (data) { - - $scope.dataPopup = data; - alert($scope.dataPopup); - }) - .error(function (data, status, headers, config) { - console.log(data); - }); - } -}] - - - +AIA.controller("CurrBuildController", ["$scope", "$rootScope", "pages", "$log", "Modules", "$http", "$compile", "$location", +function ($scope, $rootScope, pages, log, Modules, $http, $compile, $location) { + + // $rootScope.currentActiveModuleTitle = pages[6].name; + $scope.showTabButton = false; + $scope.listCurriculumBuilder = null; + $scope.dataPopup = null; + $scope.countLeftlist; + $scope.countRightlist; + $scope.IsVisible = function () { + $scope.scroll(); + + } + + $scope.scroll = function () { + // $window.scrollTo(0, 0); + $("html,body").scrollTop(0); + //alert("scroll"); + } + + $scope.openAIAFlexCB = function () { + var userInfo = ($rootScope.userData); + + + var key = CryptoJS.enc.Base64.parse("MTIzNDU2NzgxMjM0NTY3OA"); + var iv = CryptoJS.enc.Base64.parse("EBESExQVFhcYGRobHB0eHw"); + + var encryptedUserName = CryptoJS.AES.encrypt(userInfo.LoginId, key, { iv: iv }); + var encryptedPassword = CryptoJS.AES.encrypt(userInfo.Password, key, { iv: iv }); + + $location.url('/'); + + window.open('http://qa.interactiveanatomy.com/Default.aspx?un=' + encryptedUserName + '&up=' + encryptedPassword); + + } + //load json data + $scope.loadCurriculumBuiderData = function () { + + if ($rootScope.refreshcheck == null) { + $location.path('/'); + } + //get current path + var currentURL = $location.path(); + var selectedModuleName = ''; + //set module title + angular.forEach($rootScope.userModules, function (value, key) { + if (value.slug === currentURL.replace('/', '')) { + selectedModuleName = value.name; + } + $rootScope.currentActiveModuleTitle = selectedModuleName; + }) + + //get current path + var currentURL = $location.path(); + + $http({ method: 'GET', url: 'content/data/json/cb/cb_list_content.json' }).success(function (data) { + + $scope.listCurriculumBuilder = data; + //load default body view list + $scope.getCBViewList(); + }) + .error(function (data, status, headers, config) { + console.log(data); + }); + } + //get CB body view list + $scope.getCBViewList = function ($event) { + + $('#leftBodyViewList').empty(); + $scope.countLeftlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length / 2; + $scope.loadleftBodyViewList = new jinqJs() + .from($scope.listCurriculumBuilder.slideshows.slideshow) + .select(); + for (var i = 0; i < $scope.countLeftlist; i++) { + console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); + //alert($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); + var $el = $('
  • ' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '
  • ').appendTo('#leftBodyViewList'); + $compile($el)($scope); + } + + $scope.countRightlist = Object.keys($scope.listCurriculumBuilder.slideshows.slideshow).length; + for (var i = $scope.countLeftlist; i < $scope.countRightlist; i++) { + console.log($scope.listCurriculumBuilder.slideshows.slideshow[i]._label); + var $el1 = $('
  • ' + $scope.listCurriculumBuilder.slideshows.slideshow[i]._label + '
  • ').appendTo('#rightBodyViewList'); + $compile($el)($scope); + } + + } + + $scope.loadSlideShowXmldata = function (e) { + + // alert(e); + $http({ method: 'GET', url: 'content/data/json/cb/SlideShow/AIA_Curriculum_Builder_Guide.sldshw' }).success(function (data) { + + $scope.dataPopup = data; + alert($scope.dataPopup); + }) + .error(function (data, status, headers, config) { + console.log(data); + }); + } +}] + + + ); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js index 9752f2d..ebd1e1b 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js @@ -1,7 +1,7 @@ 'use strict'; -AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants", -function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, AuthenticationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) { +AIA.controller("HomeController", ["$rootScope", "$scope", "Modules", "$log", "$location", "$timeout", "DataService", "AuthenticationService","ConfigurationService", "LoginConstants", "UserModules", "LoginMessageConstants", "AdminService", "$http", "AdminConstants", "UserTypeConstants", "AIAConstants", +function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, AuthenticationService,ConfigurationService, LoginConstants, UserModules, LoginMessageConstants, AdminService, $http, AdminConstants, UserTypeConstants,AIAConstants) { //$scope.pageToOpen = { // name: 'MainMenu' @@ -92,6 +92,18 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A userLicenseId: 0, licenseeAccountNumber: null }; + + $rootScope.siteUrlInfo = { + siteIP: null, + remoteIPAddress:null, + status: null, + accountNumber: null, + edition: null, + urlReferer: null, + calsCreds: null, + userId: null, + password:null + } $rootScope.userData; $rootScope.userModules; $rootScope.passwordMismatchMessage; @@ -121,27 +133,32 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } - + $rootScope.initializeAIA = function () { - - if (navigator.cookieEnabled) { - - $rootScope.isLoading = false; + if (params != null && params != undefined && params!="") { + + $scope.ValidateClientSiteUrl(); + } - var url = $location.url(); + else { + if (navigator.cookieEnabled) { - //unblock user - if (url.indexOf('?unb:') != -1) { + $rootScope.isLoading = false; - $rootScope.isVisibleLogin = true; - $rootScope.UnblockUser(); - } - else if (url.indexOf('?em:') != -1) { + var url = $location.url(); - $rootScope.isVisibleLogin = false; - $rootScope.isVisibleResetPass = true; - } - else { + //unblock user + if (url.indexOf('?unb:') != -1) { + + $rootScope.isVisibleLogin = true; + $rootScope.UnblockUser(); + } + else if (url.indexOf('?em:') != -1) { + + $rootScope.isVisibleLogin = false; + $rootScope.isVisibleResetPass = true; + } + else { $rootScope.isVisibleLogin = true; $rootScope.isVisibleResetPass = false; @@ -152,7 +169,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A AuthenticateAlreadyLoggedInUser(); } var isRememberChecked = $rootScope.getLocalStorageValue('isRememberMeChecked'); - + if ($rootScope.getLocalStorageValue('isRememberMeChecked') != "" && sessionStorage.getItem("loginSession") == null) { sessionStorage.setItem("loginSession", "true"); } @@ -162,21 +179,22 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.userInfo = { username: $rootScope.getLocalStorageValue('RememberMeLoginId'), password: $rootScope.getLocalStorageValue('RememberMePassword'), rememberChk: true }; }, 800); } + } } - } - - else { - - $rootScope.isVisibleLogin = true; - $rootScope.promptUserForCookies(); + else { + + $rootScope.isVisibleLogin = true; + + $rootScope.promptUserForCookies(); + } + + $rootScope.getConfigurationValues(); } - - $rootScope.getConfigurationValues(); } $rootScope.getConfigurationValues = function () { - AuthenticationService.getCofigValue() + ConfigurationService.getCofigValue() .then( function (configresult) { $rootScope.current_year = configresult; @@ -285,7 +303,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A if (isCommingSoonModel == true) { - ShowAssignedModulesPopup(result.Modules); + // ShowAssignedModulesPopup(result.Modules); if (userInfo.rememberChk) { @@ -323,7 +341,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A if (isCommingSoonModel == true) { - ShowAssignedModulesPopup(result.Modules); + // ShowAssignedModulesPopup(result.Modules); } //4. @@ -381,6 +399,271 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A } + + $scope.ValidateClientSiteUrl = function () { + + debugger + var siteInfo = params.split('&'); + + for (var i = 0; i < siteInfo.length; i++) { + debugger; + if (isCalsCredantialForSIte == "True") { + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'calsCredantial') { + + $rootScope.siteUrlInfo.calsCreds = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.calsCreds" + $rootScope.siteUrlInfo.calsCreds); + } + else if (paramInfo[0] == 'username') { + + $rootScope.siteUrlInfo.username = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.username" + $rootScope.siteUrlInfo.username); + } + else if (paramInfo[0] == 'password') { + + $rootScope.siteUrlInfo.password = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.password " + $rootScope.siteUrlInfo.password); + } + + $rootScope.userInfo.username = $rootScope.siteUrlInfo.username; + $rootScope.userInfo.password = $rootScope.siteUrlInfo.password; + console.log("$rootScope.userInfo.username" + $rootScope.userInfo.username + " $rootScope.userInfo.password" + $rootScope.userInfo.password); + + + } + else { + var paramInfo = siteInfo[i].split('='); + if (paramInfo[0] == 'siteIP') { + + $rootScope.siteUrlInfo.siteIP = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'accountNumber') { + + $rootScope.siteUrlInfo.accountNumber = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.accountNumber=" + $rootScope.siteUrlInfo.accountNumber); + } + else if (paramInfo[0] == 'edition') { + + $rootScope.siteUrlInfo.edition = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP=" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'urlReferer') { + + $rootScope.siteUrlInfo.urlReferer = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.siteIP" + $rootScope.siteUrlInfo.siteIP); + } + else if (paramInfo[0] == 'remoteIPAddress') { + + $rootScope.siteUrlInfo.remoteIPAddress = paramInfo[1]; + console.log("$rootScope.siteUrlInfo.remoteIPAddress" + $rootScope.siteUrlInfo.remoteIPAddress); + } + + + } + } + if (isCalsCredantialForSIte == "True") { + $rootScope.AuthenticateUser($rootScope.userInfo); + } + else { + + + console.log($rootScope.siteUrlInfo); + + AuthenticationService.validateClientSite($rootScope.siteUrlInfo) + .then( + + function (result) { + debugger; + console.log(result); + if (result != null) { + + + console.log(result); + if (result == LoginConstants.INVALID_CLIENT) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginConstants.INVALID_CLIENT; + $("#messageModal").modal('show'); + } + else if (result == LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginConstants.MSG_NOT_AUTHORIZE_SITE_USER; + $("#messageModal").modal('show'); + } + + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_ACCOUNT_NUMBER_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_ACCOUNT_NUMBER_NOT_NULL; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_ID_NOT_NULL) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_EDITION_ID_NOT_NULL; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.E_EDITION_NOT_LINKED_WITH_SITE) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.E_EDITION_NOT_LINKED_WITH_SITE; + $("#messageModal").modal('show'); + } + else if (result.LoginFailureCauseId != undefined && result.LoginFailureCauseId.toString() == LoginConstants.LICENSE_INACTIVE) { + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = LoginMessageConstants.LICENSE_INACTIVE_MESSAGE; + $("#messageModal").modal('show'); + } + + + else { + if (typeof result.FirstName != undefined || result.FirstName != "" || result.FirstName != null) { + //code for modesty setting + if (result.LicenseInfo != null) { + if (result.Modesty) { + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + else { + $rootScope.isModestyOn = false; + $rootScope.isModestyOff = true; + localStorage.setItem("globalModesty", "N"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "N" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + } + else { + $rootScope.isModestyOn = true; + $rootScope.isModestyOff = false; + localStorage.setItem("globalModesty", "Y"); + $rootScope.formsetting = { + ethnicity: null, + modesty: "Y" + } + $rootScope.UpdateAndCloseSetting($rootScope.formsetting) + } + //code for modesty setting + + + + + //LicenseId would be zero for admin that is why we set the haveRoleAdmin = true + if (result.LicenseId == 0) { + $rootScope.haveRoleAdmin = true; + + $rootScope.userData = result; + $rootScope.userModules = result.Modules; + + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + } + + if (isCommingSoonModel == true) { + + ShowAssignedModulesPopup(result.Modules); + + //if (userInfo.rememberChk) { + + // $scope.saveRemeberMeDetails(result, userInfo); + //} + + sessionStorage.setItem("loginSession", "true"); + localStorage.setItem('isCommingSoonModel', false); + + $rootScope.isVisibleLogin = false; + } + + + $location.path('/'); + + } + else { + if (result.LicenseInfo != null ) { + //0. + $rootScope.userData = result; + $rootScope.userModules = result.Modules; + + //1. set haveRoleAdmin = false because LicenseInfo is not null + $rootScope.haveRoleAdmin = false; + + //2. + if ($scope.currentUserDetails == null || $scope.currentUserDetails == undefined || $scope.currentUserDetails == "") { + + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + } + + // 3.ShowAssignedModulesPopup + //isCommingSoonModel =true only when user comes first time on application and login + //if (isCommingSoonModel == true) { + + // ShowAssignedModulesPopup(result.Modules); + //} + + //4. + //if ($scope.rememberChk) { + + // $scope.saveRemeberMeDetails(result, userInfo); + //} + + //5. + sessionStorage.setItem("loginSession", "true"); + $rootScope.isVisibleLogin = false; + + //6. reset the isCommingSoonModel to false in local storage so that upcomming module pop up would not show again to the user after firts time + // localStorage.setItem('isCommingSoonModel', false); + + $location.path('/'); + + } + else { + if ($('#dvTerms').length > 0) { + $('#dvTerms').html(result.TermsAndConditionsText); + } + $rootScope.isVisibleLogin = true; + $('#dvTermCondition').fadeIn(); + $rootScope.userData = result; + $rootScope.haveRoleAdmin = false; + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); + $location.path('/'); + } + } + } + + + } + } + + + + }, + + function (error) { + + console.log(' Error in authentication = ' + error.statusText); + // alert(LoginMessageConstants.ERROR_IN_FECTHING_DETAILS); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = error; + $("#messageModal").modal('show'); + + } + ) + + } + //$rootScope.siteUrlInfo.siteIP = siteInfo[0]; + //$rootScope.siteUrlInfo.remoteIPAddress = siteInfo[1]; + //$rootScope.siteUrlInfo.accountNumber = siteInfo[2]; + //$rootScope.siteUrlInfo.edition = siteInfo[3]; + //$rootScope.siteUrlInfo.urlReferer = siteInfo[4]; + + + } + $scope.saveRemeberMeDetails = function (result, userInfo) { localStorage.setItem('RememberMeLoginId', result.LoginId); @@ -448,7 +731,7 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A $rootScope.isVisibleLogin = false; $rootScope.userData = userInfo; $rootScope.userModules = userInfo.Modules; - ShowAssignedModulesPopup(userInfo.Modules);; + // ShowAssignedModulesPopup(userInfo.Modules);; } } } @@ -499,72 +782,33 @@ function ($rootScope, $scope, Modules, $log, $location, $timeout, DataService, A isCommingSoonModel = $rootScope.getLocalStorageValue('isCommingSoonModel'); - try { - var userInfo = JSON.parse($scope.currentUserDetails); - - if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) { - - if (userInfo.UserType == UserTypeConstants.SUPER_ADMIN && userInfo.IsActive) { - - //0 - $rootScope.userData = userInfo; - $rootScope.userModules = userInfo.Modules; + try { + var userInfo = JSON.parse($scope.currentUserDetails); - //1. - userInfo["username"] = userInfo.LoginId; - userInfo["password"] = userInfo.Password; + if (userInfo.LoginId != undefined || userInfo.LoginId != "" || userInfo.LoginId != null) { - //2. - $rootScope.AuthenticateUser(userInfo); + userInfo["username"] = userInfo.LoginId; + userInfo["password"] = userInfo.Password; - $rootScope.haveRoleAdmin = true; - - if ($rootScope.refreshcheck == null) { - - if ($location.path() == "/lab-exercises-detail") { - - $location.url('/'); - } - else { + + $rootScope.AuthenticateUser(userInfo); + + if ($rootScope.refreshcheck == null) { - $location.path('/'); - } - $rootScope.isVisibleLogin = false; - } - - } - - else - { - $rootScope.haveRoleAdmin = false; - - if (userInfo.LicenseInfo.IsTermAccepted) - { - $rootScope.userData = userInfo; - $rootScope.userModules = userInfo.Modules; - $rootScope.isVisibleLogin = false; - - - if ($rootScope.refreshcheck == null) { - $location.path('/'); - } + if ($location.path() == "/lab-exercises-detail") { + $location.url('/'); } else { - if ($('#dvTerms').length > 0) { - $('#dvTerms').html(userInfo.TermsAndConditionsText); - } - $rootScope.isVisibleLogin = true; - $('#dvTermCondition').fadeIn(); - $rootScope.userData = userInfo; - $rootScope.userModules = userInfo.Modules; - //$rootScope.haveRoleAdmin = true; + $location.path('/'); } + $rootScope.isVisibleLogin = false; } } - - } + + + } catch (e) { localStorage.removeItem('loggedInUserDetails'); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js index a229bc2..c3736a0 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/controllers/LabExercController.js @@ -119,7 +119,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, } ) } - + $scope.labExerciseModuleData = []; $scope.GetQuizByTopic = function () { $rootScope.isLoading = true; @@ -140,7 +140,7 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, var keywords = $location.search(); $scope.labExercideIdentifier = (keywords.labexercise.replace('.json', '')).split('dat_')[1]; - + $scope.labExerciseModuleData = result.LabExercise; $.each(result.LabExercise, function (index, value) { $scope.LabExerciseName = result.LabExercise[index].Topic; @@ -425,7 +425,13 @@ function ($scope, $rootScope, pages, log, $http, $timeout, DataService, $filter, $scope.scoreResult = (parseInt($scope.CorrectAnswer) / parseInt($scope.inCorrectAnswer)) * 100; $scope.scoreResult = Math.round($scope.scoreResult); - + $("#resultLabData tr td:nth-child(2)").each(function (key, value) { + if ($(this).text().length == 1) { + var a = parseInt($(this).prev().text()) - 1; + $(this).text($scope.labExerciseModuleData[0].Questions[a].activityTitle); + $(this).next().text("Not Attempted"); + } + }); } diff --git a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js index eac86ac..470aa7c 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/main/AIA.js @@ -361,7 +361,9 @@ AIA.constant("LoginConstants", { "ACCOUNT_NUMBER_NOT_EXIST": "1", "EDITION_NOT_EXIST": "3", "MASTER_SITEIP_NOT_EXIST": "2", - "LICENSE_INACTIVE": "6" + "LICENSE_INACTIVE": "6", + "INVALID_CLIENT": "Clinet is not valid", + "MSG_NOT_AUTHORIZE_SITE_USER": "User is not authorized.", }); AIA.constant("LoginMessageConstants", { @@ -400,6 +402,9 @@ AIA.constant("LoginMessageConstants", { "UNABLE_TO_UNBLOCK": "We are unable to unblock. Please try after sometime.", //"ERROR_IN_FECTHING_DETAILS": "Error in fecthing details.", //"MAIL_NOT_SENT": "Mail not sent." + "E_ACCOUNT_NUMBER_NOT_NULL": "Account number cannot be null", + "E_EDITION_ID_NOT_NULL": "Edition Id cannot be zero.", + "E_EDITION_NOT_LINKED_WITH_SITE": "Your credentials are invalid. Please contact the site administrator of your institution.", }) AIA.constant("AdminConstants", { diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js index 427b498..f827bb4 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/AuthenticationService.js @@ -22,6 +22,29 @@ return deferred.promise; }, + validateClientSite: function (clientInfo) { + var deferred = $q.defer(); + + $http.post('/API/api/Client', JSON.stringify(clientInfo), { + headers: { + 'Content-Type': 'application/json' + } + }) + .success(function (data, status, headers, config) { + console.log('success') + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + $rootScope.isVisibleLogin = true; + $rootScope.errorMessage = data; + $("#messageModal").modal('show'); + + }); + return deferred.promise; + }, + + SendMailToUser: function (userInfo, havePassword) { var deferred = $q.defer(); diff --git a/400-SOURCECODE/AIAHTML5.Web/app/services/ConfigurationService.js b/400-SOURCECODE/AIAHTML5.Web/app/services/ConfigurationService.js new file mode 100644 index 0000000..300e09f --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/app/services/ConfigurationService.js @@ -0,0 +1,20 @@ +AIA.factory('ConfigurationService', function ($http, $q, $rootScope) { + return { + getCofigValue: function () { + var deferred = $q.defer(); + $http({ + method: 'GET', + url: 'API/api/Configuration/GetConfigurationvalues' + }).success(function (data, status, headers, config) { + console.log('success' + data); + deferred.resolve(data); + }).error(function (data, status, headers, config) { + console.log('error') + deferred.reject(data); + + }); + return deferred.promise; + } + + } +}); \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html index 894666f..b0174ba 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/CBuild/CBuild-view.html @@ -1,4 +1,4 @@ -
    + -
    - - + + + +
    \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html index a81ae76..06cfb89 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/views/LabExerc/lab-exercises-detail.html @@ -93,7 +93,7 @@
    {{LabExerciseName}}
    -
    performance Report
    +
    Performance Report
    Score:{{scoreResult}}%
    diff --git a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html index f8f740f..8dadb58 100644 --- a/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html +++ b/400-SOURCECODE/AIAHTML5.Web/app/widget/MainMenu.html @@ -26,7 +26,7 @@ diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx b/400-SOURCECODE/AIAHTML5.Web/index.aspx new file mode 100644 index 0000000..dc56890 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx @@ -0,0 +1,2022 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="ADAM.AIA.index" %> + + + + + + + + + + + + A.D.A.M. Interactive Anatomy + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + +
    +
    +
    + +
    +
    +

    A.D.A.M. Interactive Anatomy

    +

    The most comprehensive online interactive anatomy learning resource

    +
    +
    +
    + +
    +
    +
    + +
    +
    + + + + +
    + + +
    + Forgot User ID? + + +
    +
    + + +
    + + +
    + Forgot Password? +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + + +
    +
    + + + + +
    +
    Copyright © {{current_year}} Ebix Inc. All rights reserved.
    +
    +
    + + + + +
    +
    + + + +
    + + +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + +
    + + + +
    + + + +
    + + + + + +
    + +
    + + + + + + + + + +
    +
    + +
    + + + + + + + + + + +
    AIA
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Reset Password
     
    New Password
    + + The password is required. +

    Password length must be between 8 - 20 characters.

    +

    Password length must be between 8 - 20 characters.

    +
     
    Confirm Password
    + + Confirm password is required. + {{passwordMismatchMessage}} +
     
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs new file mode 100644 index 0000000..4edd84d --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace ADAM.AIA +{ + public partial class index : System.Web.UI.Page + { + public string strIPAddress = ""; + public bool bValidIP = false; + public string strAccountNumber = ""; + public string strEdition = ""; + public string strUrlReferer = ""; + public string strSiteReferer = ""; + public string urlParams = ""; + public string test = ""; + public bool isCalsCredantial = false; + + protected void Page_Load(object sender, EventArgs e) + { + + + if (Request.HttpMethod == "POST") + { + if (Request.Form["calsCredantial"] != null && Request.Form["calsCredantial"].ToString() == "yes") + { + isCalsCredantial = true; + + urlParams = "calsCredantial=" + Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); + //calsCredantialusername&password + // urlParams = Request.Form["calsCredantial"].ToString() + "&username=" + Request.Form["calsUsername"].ToString() + "&password=" + Request.Form["calsPassword"].ToString(); + + } + } + + string c = "nm"; + if (Request.QueryString["account"] != null) + { + // http://stackoverflow.com/questions/9032005/request-servervariableshttp-referer-is-not-working-in-ie + // http://stackoverflow.com/questions/5643773/http-referrer-not-always-being-passed?rq=1 + // + strSiteReferer = Request.ServerVariables["HTTP_REFERER"]; + strAccountNumber = Request.QueryString["account"]; + strEdition = Request.QueryString["edition"]; + string remoteIPAddress = Request.ServerVariables["REMOTE_ADDR"]; + string strHttpReferer = null; + int intSiteId = 0; + + + + + if (Request.Form["referer"] != null) + { + strUrlReferer = Request.Form["referer"]; + } + else if (Request.QueryString["referer"] == null) + { + strUrlReferer = Request.ServerVariables["HTTP_REFERER"]; + } + else if (Request.Params["referer"] != null) + { + strUrlReferer = Request.Params["referer"]; + } + else + { + + strUrlReferer = Request.QueryString["referer"]; + } + + + if (strUrlReferer != "" && strUrlReferer != null) + { + strHttpReferer = strUrlReferer.ToLower().Replace("http://", "").Replace("https://", "").Replace("www.", "").ToString().Split('/')[0].ToString(); + + if (strHttpReferer.IndexOf(":") != -1) + { + char[] delimiters = new char[] { ':' }; + string[] parts = strHttpReferer.Split(delimiters, StringSplitOptions.RemoveEmptyEntries); + strHttpReferer = parts[0]; + } + } + + try + { + + if (strHttpReferer != "" && strHttpReferer != null) + strIPAddress = strHttpReferer; + if (strIPAddress == "" || strIPAddress == null) + strIPAddress = remoteIPAddress; + + + // intSiteId = LicenseHelper.GetInstance().ValidateLicenseSiteIP(strIPAddress, remoteIPAddress, strAccountNumber, Convert.ToByte(strEdition)); + + } + catch (Exception objEx) + { + + } + //urlParams = "?siteIP=" + strIPAddress + "&status=" + intSiteId + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + urlParams = "siteIP=" + strIPAddress + "&accountNumber=" + strAccountNumber + "&edition=" + strEdition + "&urlReferer=" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : "") + "&remoteIPAddress=" + remoteIPAddress; + + //For the ease of splitting desgined urlParms in the pattern of + //urlParams = siteIP&accountNumber&remoteIPAddress&edition&urlReferer; without mentioning the variableName + // urlParams = strIPAddress + "&" + remoteIPAddress+"&"+ strAccountNumber + "&" + strEdition + "&" + (strSiteReferer != "" && strSiteReferer != null ? strSiteReferer : ""); + + + } + } + } +} \ No newline at end of file diff --git a/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs b/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs new file mode 100644 index 0000000..2a5236b --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/index.aspx.designer.cs @@ -0,0 +1,15 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ADAM.AIA { + + + public partial class index { + } +} diff --git a/400-SOURCECODE/AIAHTML5.Web/index.html b/400-SOURCECODE/AIAHTML5.Web/index1.html index f3df5d8..058b6db 100644 --- a/400-SOURCECODE/AIAHTML5.Web/index.html +++ b/400-SOURCECODE/AIAHTML5.Web/index1.html @@ -1422,6 +1422,7 @@ + @@ -1441,6 +1442,7 @@ + diff --git a/400-SOURCECODE/AIAHTML5.Web/libs/crypto-js/3.1.9-1/aes.js b/400-SOURCECODE/AIAHTML5.Web/libs/crypto-js/3.1.9-1/aes.js new file mode 100644 index 0000000..9f0fda4 --- /dev/null +++ b/400-SOURCECODE/AIAHTML5.Web/libs/crypto-js/3.1.9-1/aes.js @@ -0,0 +1,232 @@ +;(function (root, factory, undef) { + if (typeof exports === "object") { + // CommonJS + module.exports = exports = factory(require("./core"), require("./enc-base64"), require("./md5"), require("./evpkdf"), require("./cipher-core")); + } + else if (typeof define === "function" && define.amd) { + // AMD + define(["./core", "./enc-base64", "./md5", "./evpkdf", "./cipher-core"], factory); + } + else { + // Global (browser) + factory(root.CryptoJS); + } +}(this, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + + // Compute lookup tables + (function () { + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } + + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); + + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; + + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; + + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + var t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; + + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + var ksRow = 4; + + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + + keySize: 256/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + C.AES = BlockCipher._createHelper(AES); + }()); + + + return CryptoJS.AES; + +})); \ No newline at end of file