Пример #1
0
        public SiteMember GetMember(object membershipId)
        {
            const string logMethodName = ".GetMember(object membershipId)";

            _log.Debug(logMethodName + " - Begin Method");
            IMemberAccountData accountData = null;
            IMemberProfileData profileData = null;

            try
            {
                _log.Debug(logMethodName + " - Calling ISecurityAdapter.GetMember(membershipId)");

                accountData = _adapter.GetMember(membershipId);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Error retrieving member accound data from Security Adapter " + _adapter.GetType().FullName);

                throw new WtfException(logMethodName + " - Error retrieving member accound data from Security Adapter" + _adapter.GetType().FullName, ex);
            }

            try
            {
                _log.Debug(logMethodName + " - Calling IContextDataAdapter.GetMemberProfile(membershipId)");

                profileData = _provider.GetMemberProfile(accountData.MemberId);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Error retrieving member accound data from Data Provider" + _provider.GetType().FullName, ex);

                throw new WtfException(logMethodName + " - Error retrieving member accound data from Data Provider " + _provider.GetType().FullName, ex);
            }

            SiteMember siteMember = null;

            try
            {
                siteMember = new SiteMember(accountData, profileData);
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Unable to create SiteMember(MemberAccountData, MemberProfileData) instance", ex);

                throw new WtfException(logMethodName + " - Unable to create SiteMember(MemberAccountData, MemberProfileData) instance", ex);
            }

            _log.Debug(logMethodName + " - End Method");
            return(siteMember);
        }
Пример #2
0
        /// <summary>
        /// Gets Currenty logged in user. For user's not logged in a populate object with anonymous data and tracking ID's is returned.
        /// </summary>
        /// <returns>SiteMember instance for the user currently logged in.</returns>
        public SiteMember GetMember()
        {
            const string logMethodName = ". GetMember()";

            _log.Debug(logMethodName + " - Begin Method");
            SiteMember currentMember;

            try
            {
                currentMember = new SiteMember();
            }
            catch (Exception ex)
            {
                _log.Error(logMethodName + " - Unable to create SiteMember() instance", ex);

                throw new WtfException(logMethodName + " - Unable to create SiteMember() instance", ex);
            }

            _log.Debug(logMethodName + " - End Method");
            return(currentMember);
        }
Пример #3
0
        public SiteMember CreateMember(MemberAuthInfo authInfo, MemberProfileData profile, out MemberCreationStatus status, IList <IContextActionValidationRequest <IContextActionValidator> > validationRequests = null)
        {
            const string logMethodName = ".CreateMember(MemberAuthInfo, MemberProfileData, out MemberCreationStatus, IList<IContextActionValidationRequest<IContextActionValidator>>)";
            const string logEndMessage = logMethodName + " - End Method";

            _log.Info(logMethodName + " - Creating new SiteMember");
            _log.Debug(logMethodName + " - Begin Method");
            SiteMember newMember = null;

            status = MemberCreationStatus.Error;

            IMemberAccountData accountData = null;
            int timesToTry = 2;

            //SWD-7461 - adding retry logic.
            for (int i = 0; i < timesToTry; i++)
            {
                try
                {
                    _log.Debug(logMethodName + " - Calling ISecurityAdapter.CreateMember(MemberAuthInfo authInfo, MemberProfileData data, out MemberCreationStatus status)");
                    status      = MemberCreationStatus.Error;
                    accountData = _adapter.CreateMember(authInfo, profile, out status);
                    break;
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new member account using the ISecurityAdapter.CreateMember will retry again", ex);
                    System.Threading.Thread.Sleep(1000);
                    accountData = null;
                }
            }

            if (status == MemberCreationStatus.Success)
            {
                _log.Info(logMethodName + " - MemberAccount created successfully by ISecurityAdapter.CreateMember - Creating MemberProfile");

                var memberProfile = new MemberProfileData(profile)
                {
                    MemberId       = accountData.MemberId,
                    LastModified   = DateTime.Now,
                    LastModifiedBy = accountData.MemberId
                };
                if (memberProfile.ProviderKeys == null)
                {
                    memberProfile.ProviderKeys = new Dictionary <string, object>();
                }
                memberProfile.ProviderKeys.Add("ActiveDirectoryKey", accountData.MemberId); // We prob dont need this, code using the ADKey lower in the framework will be ignored

                try
                {
                    IMemberProfileData data;
                    _log.Debug(logMethodName + " - Calling IContextDataProvider.CreateMemberProfile(MemberProfileData data, ProviderKeys keys)");
                    //TODO verify and remove provider key integration at this layer. - May need pin based lookup for pre-registered accounts to call update.
                    data          = _provider.CreateMemberProfile(memberProfile, memberProfile.ProviderKeys);
                    memberProfile = new MemberProfileData(data);
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new member profile using the IContextDataProvider - Rolling back new account", ex);
                    _log.Info(logMethodName + " - Rolling back - STEP 1. DELETE MEMBER ACCOUNT");
                    _log.Debug(logMethodName + " - Calling ISecurityAdapter.DeleteMember(Object memberId)");

                    _adapter.DeleteMember(accountData.Username);
                    status = MemberCreationStatus.AdapterError;

                    _log.Debug(logEndMessage);
                    accountData = null;
                }

                try
                {
                    newMember = new SiteMember(accountData, memberProfile);
                }
                catch (Exception ex)
                {
                    _log.Error(logMethodName + " - Error Creating new sitemember instance", ex);
                    _log.Debug(logEndMessage);
                    newMember = null;
                }
            }
            else
            {
                // SWD-5616
                _log.Warn(logMethodName + " - Member Creation Unsuccessful.  Status: " + status);
            }

            _log.Debug(logEndMessage);
            return(newMember);
        }
Пример #4
0
 private void createCredentials()
 {
     _siteMember = IntegrationLoader.LoadDependency <ISiteMembership>("siteMembership").GetMember();
 }