public BVSDAdmin ExtractExternalUser(string externalToken) { BVSDAdmin user = new BVSDAdmin(); if (!string.IsNullOrWhiteSpace(externalToken)) { if (!string.IsNullOrWhiteSpace(_clearAuthenticationPrefix) && (externalToken.IndexOf(_clearAuthenticationPrefix) == 0)) { //split clear-text token try { string[] tokenParts = externalToken.Split(':')[1].Split(';'); user.ID = int.Parse(tokenParts[0]); user.UserID = int.Parse(tokenParts[1]); user.CalendarID = int.Parse(tokenParts[2]); } catch { } } else { try { lock (_icCipherService) { //decode/decrypt token //TODO: use Convert.ToBase64String() instead of Web.HttpUtility.. System.Collections.Specialized.NameValueCollection tokenParts = System.Web.HttpUtility.ParseQueryString( _icCipherService.Decrypt_ECB(System.Web.HttpUtility.UrlDecode(externalToken))); user.ID = int.Parse(tokenParts[icTokenKeyPersonID]); user.UserID = int.Parse(tokenParts[icTokenKeyUserID]); user.CalendarID = int.Parse(tokenParts[icTokenKeyCalendarID]); } } catch (Exception ex) { //TODO: log exception ; } } if ((user.ID != 0) && (user.UserID != 0)) { //call DB to flesh out user details ValidateAdmin(user); } } return(user); }