Exemplo n.º 1
0
        private void MoveFromStepProfileTypeSelector()
        {
            Int32 tokenIdType    = View.TokenIdProfileType;
            Int32 idOrganization = View.TokenIdOrganization;

            if (idOrganization == 0)
            {
                idOrganization = View.SelectedOrganizationId;
            }
            MacUrlAuthenticationProvider provider = GetProvider();
            dtoBaseProfile profile = new dtoBaseProfile();

            if (tokenIdType > 0)
            {
                profile.IdProfileType = tokenIdType;
            }
            else if (provider != null)
            {
                profile.IdProfileType = View.SelectedProfileTypeId;
            }

            if (profile.IdProfileType > 0)
            {
                profile = Helper.GetProfileData(provider, provider.GetProfileAttributes(), View.TokenAttributes, idOrganization, profile.IdProfileType);
                View.GotoStepProfileInfo(profile);
                View.DisableInput(provider.GetNotEditableAttributes(View.TokenAttributes));
            }
        }
Exemplo n.º 2
0
        //public Boolean UpdateOrganizationsAssocation(Int32 idUser, UrlMacAuthenticationProvider provider, List<dtoMacUrlUserAttribute> attributes)
        //{
        //    Boolean saved = false;
        //    try
        //    {
        //        Manager.BeginTransaction();
        //        Person person = Manager.GetPerson(idUser);
        //        if (person != null)
        //        {
        //            List<OrganizationAttributeItem> items = provider.GetOrganizationsInfo(attributes);

        //            List<OrganizationAttribute> oAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(OrganizationAttribute)).Select(p => (OrganizationAttribute)p).ToList();
        //            List<String> userCodes = new List<String>();
        //            List<Int32> idOrganizations = new List<Int32>();
        //            foreach (dtoMacUrlUserAttribute uAtt in attributes.Where(a => a.Type == UrlMacAttributeType.organization && !String.IsNullOrEmpty(a.QueryValue)).ToList())
        //            {
        //                OrganizationAttribute oAtt = oAttributes.Where(a => a.Id == uAtt.Id).FirstOrDefault();
        //                if (oAtt != null)
        //                {
        //                    if (oAtt.AllowMultipleValue)
        //                        userCodes.AddRange(uAtt.QueryValue.Split(oAtt.MultipleValueSeparator.ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList());
        //                    else
        //                        userCodes.Add(uAtt.QueryValue);
        //                }
        //                idOrganizations.AddRange(oAtt.Items.Where(i => i.Deleted == BaseStatusDeleted.None && userCodes.Contains(i.RemoteCode)).Select(i => i.IdOrganization).ToList());
        //            }

        //            List<OrganizationProfiles> associations = (from a in Manager.GetIQ<OrganizationProfiles>()
        //                                                        where a.Profile.Id== idUser
        //                                                         select a).ToList();
        //            //foreach (lm.Comol.Core.Catalogues.CataloguePersonAssignment assignment in assignments)
        //            //{
        //            //    if (idCatalogues.Contains(assignment.Id) && !assignment.Allowed)
        //            //    {
        //            //        assignment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
        //            //        if (assignment.Deleted != BaseStatusDeleted.None)
        //            //        {
        //            //            assignment.FromProvider = true;
        //            //            assignment.Deleted = BaseStatusDeleted.None;
        //            //        }
        //            //        assignment.Allowed = true;
        //            //        Manager.SaveOrUpdate(assignment);
        //            //    }
        //            //    else if (!idCatalogues.Contains(assignment.Id) && assignment.Deleted == BaseStatusDeleted.None && assignment.Allowed && assignment.FromProvider)
        //            //    {
        //            //        assignment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
        //            //        assignment.Allowed = false;
        //            //        Manager.SaveOrUpdate(assignment);
        //            //    }
        //            //}
        //            //foreach (long idCatalogue in idCatalogues.Where(i => !assignments.Select(a => a.Id).ToList().Contains(i)).ToList())
        //            //{
        //            //    lm.Comol.Core.Catalogues.CataloguePersonAssignment pAssignment = new Catalogues.CataloguePersonAssignment();
        //            //    pAssignment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
        //            //    pAssignment.FromProvider = true;
        //            //    pAssignment.AssignedTo = person;
        //            //    pAssignment.Allowed = true;
        //            //    Manager.SaveOrUpdate(pAssignment);
        //            //}
        //            saved = true;
        //        }
        //        Manager.Commit();
        //    }

        //    catch (Exception ex)
        //    {
        //        saved = false;
        //        Manager.RollBack();
        //    }

        //    return saved;
        //}

        public dtoExternalCredentials GetCredentials(MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            dtoExternalCredentials credentials = new dtoExternalCredentials();

            if (attributes.Where(a => a.isIdentifier).Any())
            {
                credentials.IdentifierString = attributes.Where(a => a.isIdentifier).FirstOrDefault().QueryValue;
            }
            else
            {
                UserProfileAttribute pAttribute = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(UserProfileAttribute)).Where(p => ((UserProfileAttribute)p).Attribute == ProfileAttributeType.externalId).Select(p => (UserProfileAttribute)p).FirstOrDefault();
                if (pAttribute != null)
                {
                    credentials.IdentifierString = attributes.Where(i => i.Type == UrlMacAttributeType.profile && i.Id == pAttribute.Id).Select(i => i.QueryValue).FirstOrDefault();
                }
                else
                {
                    CompositeProfileAttribute cmpAttribute = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(CompositeProfileAttribute)).Where(p => ((CompositeProfileAttribute)p).Attribute == ProfileAttributeType.externalId).Select(p => (CompositeProfileAttribute)p).FirstOrDefault();
                    if (!cmpAttribute.Items.Where(i => i.Deleted == BaseStatusDeleted.None).Any())
                    {
                        credentials.IdentifierString = "";
                    }
                    else
                    {
                        credentials.IdentifierString = (attributes.Where(i => i.Id == cmpAttribute.Id).Any()) ? attributes.Where(i => i.Id == cmpAttribute.Id).Select(i => i.QueryValue).FirstOrDefault() : "";
                    }
                }
            }
            return(credentials);
        }
Exemplo n.º 3
0
        private Boolean UpdateOrganizationAssociations(Person person, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            Boolean updated = false;
            List <OrganizationAttributeItem> items = provider.GetOrganizationsInfo(attributes);
            List <lm.Comol.Core.BaseModules.ProfileManagement.dtoProfileOrganization> associations = ProfileService.GetProfileOrganizations(person);

            foreach (var item in items.Where(i => !associations.Select(a => a.IdOrganization).ToList().Contains(i.Organization.Id)).ToList())
            {
                Organization organization = CurrentManager.GetOrganization(item.Organization.Id);
                if (organization != null)
                {
                    LazySubscription sub = ServiceCommunity.AddProfileToOrganization(item.Organization.Id, person, false);
                    if (!updated && (sub != null))
                    {
                        updated = true;
                    }
                }
            }
            if (updated)
            {
                View.UpdateLogonXml(person.Id);
            }
            // COSaA FARE SE NON SONO PI§ DI UNA ORGANIZZAZIONE ?? CHIEDERE PRIMA DI ESEGUIRE CODICE
            //foreach (var a in associations.Where(a => !items.Select(i => i.IdOrganization).ToList().Contains(a.IdOrganization)).ToList())
            //{

            //}
            return(updated);
        }
Exemplo n.º 4
0
        public void CreateProfile(dtoBaseProfile profile, Int32 idProfileType, String ProfileName, Int32 idOrganization)
        {
            MacUrlAuthenticationProvider provider = GetProvider();
            List <ProfilerError>         errors   = UrlService.VerifyProfileInfo(profile, View.idProvider, View.ExternalCredentials);

            if (errors.Count == 0)
            {
                ProfileSubscriptionMessage message = View.CreateProfile(profile, idProfileType, ProfileName, idOrganization, AuthenticationProviderType.UrlMacProvider, View.idProvider);
                Int32 idPerson = View.IdProfile;
                if (idPerson > 0)
                {
                    PolicyService.SaveUserSelection(CurrentManager.GetPerson(idPerson), View.GetPolicyInfo);
                }

                if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon && idPerson > 0)
                {
                    Person person = CurrentManager.GetPerson(idPerson);
                    UrlService.UpdateCatalogueAssocation(idPerson, provider, View.TokenAttributes);
                    View.LogonUser(person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(idPerson));
                }
                else
                {
                    if (message == ProfileSubscriptionMessage.CreatedWithAutoLogon)
                    {
                        message = ProfileSubscriptionMessage.Created;
                    }
                    View.LoadRegistrationMessage(message);
                }
            }
            else
            {
                if (errors.Contains(ProfilerError.loginduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.LoginDuplicated);
                }
                else if (errors.Contains(ProfilerError.mailDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MailDuplicated);
                }
                else if (errors.Contains(ProfilerError.taxCodeDuplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.TaxCodeDuplicated);
                }
                else if (errors.Contains(ProfilerError.uniqueIDduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.MatriculaDuplicated);
                }
                else if (errors.Contains(ProfilerError.externalUniqueIDduplicate))
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.externalUniqueIDduplicate);
                }
                else
                {
                    View.LoadRegistrationMessage(ProfileSubscriptionMessage.UnknownError);
                }
            }
        }
Exemplo n.º 5
0
        private MacUrlAuthenticationProvider GetProvider()
        {
            MacUrlAuthenticationProvider provider = UrlService.GetProvider(View.idProvider);

            if (provider != null && provider.Id != View.idProvider)
            {
                View.idProvider = provider.Id;
            }

            return(provider);
        }
Exemplo n.º 6
0
        public Dictionary <ProfileAttributeType, string> GetUserAttributesForAgency(MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            List <UserProfileAttribute> pAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(UserProfileAttribute)).Select(p => (UserProfileAttribute)p).ToList();

            Dictionary <ProfileAttributeType, string> items = new Dictionary <ProfileAttributeType, string>();

            items.Add(ProfileAttributeType.agencyExternalCode, provider.GetAttributeValue(ProfileAttributeType.agencyExternalCode, pAttributes, attributes));
            items.Add(ProfileAttributeType.agencyTaxCode, provider.GetAttributeValue(ProfileAttributeType.agencyTaxCode, pAttributes, attributes));
            items.Add(ProfileAttributeType.agencyNationalCode, provider.GetAttributeValue(ProfileAttributeType.agencyNationalCode, pAttributes, attributes));
            items.Add(ProfileAttributeType.agencyInternalCode, provider.GetAttributeValue(ProfileAttributeType.agencyInternalCode, pAttributes, attributes));

            return(items.Where(i => !String.IsNullOrEmpty(i.Value)).ToDictionary(k => k.Key, k => k.Value));
        }
Exemplo n.º 7
0
        //public override Boolean isUniqueTaxCode(string taxCode, long idProvider)
        //{

        //    List<Int32> users = (from p in Manager.GetIQ<Person>() where (p.TaxCode == taxCode && !string.IsNullOrEmpty(taxCode)) select p.Id).ToList();
        //    if (users == null || users.Count == 0)
        //        return true;
        //    else {
        //        return (from u in Manager.GetIQ<ExternalLoginInfo>()
        //                 where u.Deleted== BaseStatusDeleted.None && users.Contains(u.Person.Id))
        //    }
        //}
        public virtual List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile, long idProvider)
        {
            List <ProfilerError>         result   = new List <ProfilerError>();
            MacUrlAuthenticationProvider provider = Manager.Get <MacUrlAuthenticationProvider>(idProvider);

            if (!isUniqueMail(profile.Mail))
            {
                result.Add(ProfilerError.mailDuplicate);
            }
            if (!String.IsNullOrEmpty(profile.TaxCode) && (provider != null && provider.AllowTaxCodeDuplication) && !isUniqueTaxCode(profile.TaxCode))
            {
                result.Add(ProfilerError.taxCodeDuplicate);
            }

            return(result);
        }
Exemplo n.º 8
0
        private void UpdateProfileByToken(Person person, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            List <UserProfileAttribute> pAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(UserProfileAttribute)).Select(p => (UserProfileAttribute)p).ToList();
            Int32 idDefaultType = 0;
            List <OrganizationAttributeItem> items = provider.GetOrganizationsInfo(attributes);

            UpdateOrganizationAssociations(person, provider, attributes);
            Dictionary <ProfileAttributeType, string> agencyAttributes = Helper.GetUserAttributesForAgency(provider, attributes);

            if (items.Count == 1)
            {
                idDefaultType = items[0].IdDefaultProfile;
                if (idDefaultType != person.TypeID)
                {
                    CurrentManager.Detach(person);
                    EditProfileType(person.Id, idDefaultType, items[0].Organization.Id, provider, pAttributes, attributes);
                }
                else if (agencyAttributes.Count > 0 && person.TypeID == (int)UserTypeStandard.Employee)
                {
                    Employee emp       = (Employee)person;
                    Agency   empAgency = Helper.GetAgencyByAttributes(person.Id, items[0].Organization.Id, provider, attributes);
                    if (emp.CurrentAffiliation == null || (empAgency != null && emp.CurrentAffiliation.Agency.Id != empAgency.Id))
                    {
                        UpdateAgencyAssocation(person.Id, empAgency);
                    }
                }
            }
            else if (items.Count > 0 && agencyAttributes.Count > 0 && person.TypeID != (int)UserTypeStandard.Employee)
            {
                idDefaultType = (int)UserTypeStandard.Employee;
                CurrentManager.Detach(person);
                EditProfileType(person.Id, idDefaultType, items[0].Organization.Id, provider, pAttributes, attributes);
            }
            else if (items.Count > 0 && agencyAttributes.Count > 0 && person.TypeID == (int)UserTypeStandard.Employee)
            {
                Employee emp       = (Employee)person;
                Agency   empAgency = Helper.GetAgencyByAttributes(emp.Id, items[0].Organization.Id, provider, attributes);
                if (emp.CurrentAffiliation == null || (empAgency != null && emp.CurrentAffiliation.Agency.Id != empAgency.Id))
                {
                    UpdateAgencyAssocation(person.Id, empAgency);
                }
            }
            if (provider.HasCatalogues())
            {
                UrlService.UpdateCatalogueAssocation(person.Id, provider, attributes);
            }
        }
Exemplo n.º 9
0
        private List <ProfileWizardStep> GetAvailableSteps(MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            List <ProfileWizardStep>         steps    = Service.GetStandardProfileWizardStep(WizardType.MacUrl);
            List <OrganizationAttributeItem> orgInfos = provider.GetOrganizationsInfo(attributes);

            View.InitializeStep(ProfileWizardStep.OrganizationSelector);

            if (orgInfos != null && orgInfos.Any())
            {
                View.TokenIdOrganization    = orgInfos[0].Organization.Id;
                View.TokenIdProfileType     = orgInfos[0].IdDefaultProfile;
                View.SelectedOrganizationId = orgInfos[0].Organization.Id;
                steps.Remove(ProfileWizardStep.OrganizationSelector);
                steps.Remove(ProfileWizardStep.ProfileTypeSelector);
            }
            return(steps);
        }
Exemplo n.º 10
0
        public override List <ProfilerError> VerifyProfileInfo(dtoBaseProfile profile, long idProvider, dtoExternalCredentials credentials)
        {
            List <ProfilerError>         result   = new List <ProfilerError>();
            MacUrlAuthenticationProvider provider = Manager.Get <MacUrlAuthenticationProvider>(idProvider);

            if (!isUniqueMail(profile.Mail))
            {
                result.Add(ProfilerError.mailDuplicate);
            }
            if (!String.IsNullOrEmpty(profile.TaxCode) && (provider != null && provider.AllowTaxCodeDuplication) && !isUniqueTaxCode(profile.TaxCode))
            {
                result.Add(ProfilerError.taxCodeDuplicate);
            }

            result.AddRange(VerifyProfileInfo(profile, Manager.Get <AuthenticationProvider>(idProvider), credentials));
            return(result);
        }
Exemplo n.º 11
0
        public void InitView(String internalMac, String userIdentifier, long idProvider)
        {
            View.PostInternalMac    = internalMac;
            View.PostUserIdentifier = userIdentifier;
            MacUrlAuthenticationProvider provider = UrlService.GetProvider(idProvider);

            if (View.isSystemOutOfOrder)
            {
                View.DisplaySystemOutOfOrder();
            }
            else if (provider == null)
            {
                View.GotoDefaultPage();
            }
            else
            {
                List <dtoMacUrlUserAttribute> attributes = View.GetTokenAttributes(provider.GetUserAttributes());
                View.TokenAttributes = attributes;
                if (!provider.IsInternalToken(internalMac, attributes) || String.IsNullOrEmpty(internalMac) || String.IsNullOrEmpty(userIdentifier))
                {
                    if (String.IsNullOrEmpty(provider.RemoteLoginUrl))
                    {
                        View.GotoDefaultPage();
                    }
                    else
                    {
                        View.GotoRemoteLogonPage(provider.RemoteLoginUrl);
                    }
                }
                else
                {
                    List <ProfileWizardStep> steps = GetAvailableSteps(provider, attributes);
                    View.idProvider     = View.PreloadedIdProvider;
                    View.AvailableSteps = steps;
                    List <AuthenticationProviderType> providers = new List <AuthenticationProviderType>();
                    providers.Add(AuthenticationProviderType.Internal);
                    providers.Add(AuthenticationProviderType.UrlMacProvider);
                    View.InitializeUnknownProfileStep(AuthenticationProviderType.UrlMacProvider, providers);
                    View.GotoStep(ProfileWizardStep.UnknownProfileDisclaimer);
                }
            }
        }
Exemplo n.º 12
0
        public dtoBaseProfile GetProfileData(dtoBaseProfile previous, MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes, Int32 idOrganization, Int32 idProfileType)
        {
            dtoBaseProfile result = GetProfileData(provider, pAttributes, attributes, idOrganization, idProfileType);

            if (previous != null)
            {
                result.Id      = previous.Id;
                result.Name    = previous.Name;
                result.Surname = previous.Surname;
                if (String.IsNullOrEmpty(provider.GetAttributeValue(ProfileAttributeType.taxCode, pAttributes, attributes)))
                {
                    result.TaxCode = previous.TaxCode;
                }

                if (result.Mail == result.Login + "@invalid.invalid.it" && !previous.Mail.Contains("@invalid.invalid.it"))
                {
                    result.Mail = previous.Mail;
                }
            }
            return(result);
        }
Exemplo n.º 13
0
        private void MoveFromStepInternalCredentials()
        {
            dtoInternalCredentials credentials = View.GetInternalCredentials;
            InternalLoginInfo      info        = InternalService.GetAuthenticatedUser(credentials.Login, credentials.Password);

            if (info == null || info.Person == null)
            {
                View.DisplayInvalidCredentials();
            }
            else
            {
                MacUrlAuthenticationProvider provider = GetProvider();
                if (provider == null)
                {
                    View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.ProviderUnknown);
                }
                else
                {
                    ExternalLoginInfo account = UrlService.AddFromInternalAccount(info, provider, View.PostUserIdentifier);
                    if (account == null)
                    {
                        View.DisplayInternalCredentialsMessage(ProfileSubscriptionMessage.UnableToConnectToInternalProvider);
                    }
                    else if (account != null && account.Person.isDisabled)
                    {
                        View.LoadRegistrationMessage(ProfileSubscriptionMessage.AccountDisabled);
                    }
                    else if (PolicyService.UserHasPolicyToAccept(account.Person))
                    {
                        View.IdProfile = account.Person.Id;
                        InternalService.UpdateUserAccessTime(account.Person);
                        View.DisplayPrivacyPolicy(account.Person.Id, provider.Id, provider.RemoteLoginUrl, false);
                    }
                    else
                    {
                        View.LogonUser(account.Person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(account.Person.Id));
                    }
                }
            }
        }
Exemplo n.º 14
0
        public Agency GetAgencyByAttributes(Int32 idProfile, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            List <UserProfileAttribute> pAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.GetType() == typeof(UserProfileAttribute)).Select(p => (UserProfileAttribute)p).ToList();

            Dictionary <ProfileAttributeType, string> items = GetUserAttributesForAgency(provider, attributes);
            Agency agency = ProfileService.GetAgency(items);

            if (agency == null && provider.AutoAddAgency && items.Values.Where(v => String.IsNullOrEmpty(v)).Any())
            {
                agency = ProfileService.SaveAgency(idProfile, items);
            }
            if (agency == null)
            {
                agency = ProfileService.GetDefaultAgency(idOrganization);
            }

            if (agency == null)
            {
                agency = ProfileService.GetEmptyAgencyForOrganization(idOrganization);
            }
            return(agency);
        }
Exemplo n.º 15
0
        public dtoBaseProfile GetProfileData(MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes, Int32 idOrganization, Int32 idProfileType)
        {
            dtoBaseProfile profile  = new dtoBaseProfile();
            String         pwd      = lm.Comol.Core.DomainModel.Helpers.RandomKeyGenerator.GenerateRandomKey(6, 10, true, true, false);
            Language       language = GetUserLanguage(provider.GetAttributeValue(ProfileAttributeType.language, pAttributes, attributes));

            switch (idProfileType)
            {
            case (int)UserTypeStandard.ExternalUser:
                profile = new dtoExternal();
                break;

            case (int)UserTypeStandard.Company:
                profile = new dtoCompany();
                break;

            case (int)UserTypeStandard.Employee:
                profile = new dtoEmployee();
                break;

            default:
                profile = new dtoBaseProfile();
                break;
            }
            profile.Login = provider.GetAttributeValue(ProfileAttributeType.login, pAttributes, attributes);
            if (String.IsNullOrEmpty(profile.Login))
            {
                profile.Login = provider.GetAttributeValue(ProfileAttributeType.externalId, attributes);
            }

            profile.Name    = provider.GetAttributeValue(ProfileAttributeType.name, pAttributes, attributes);
            profile.Surname = provider.GetAttributeValue(ProfileAttributeType.surname, pAttributes, attributes);
            profile.TaxCode = provider.GetAttributeValue(ProfileAttributeType.taxCode, pAttributes, attributes);
            if (String.IsNullOrEmpty(profile.TaxCode))
            {
                profile.TaxCode = UrlService.GenerateRandomTaxCode();
            }
            profile.Mail = provider.GetAttributeValue(ProfileAttributeType.mail, pAttributes, attributes);
            if (String.IsNullOrEmpty(profile.Mail))
            {
                profile.Mail = profile.Login + "@invalid.invalid.it";
            }
            //if (!String.IsNullOrEmpty(profile.Mail))
            //    profile.Mail = profile.Mail.ToLower();
            profile.Password = pwd;
            profile.ShowMail = false;
            if (!String.IsNullOrEmpty(profile.Surname))
            {
                profile.FirstLetter = profile.Surname[0].ToString().ToLower();
            }
            profile.IdProfileType          = idProfileType;
            profile.AuthenticationProvider = provider.ProviderType;
            profile.IdLanguage             = language.Id;
            profile.LanguageName           = language.Name;


            switch (idProfileType)
            {
            case (int)UserTypeStandard.Company:
                dtoCompany dCompany = (dtoCompany)profile;
                dCompany.Info.Address               = provider.GetAttributeValue(ProfileAttributeType.companyAddress, pAttributes, attributes);
                dCompany.Info.City                  = provider.GetAttributeValue(ProfileAttributeType.companyCity, pAttributes, attributes);
                dCompany.Info.Name                  = provider.GetAttributeValue(ProfileAttributeType.companyName, pAttributes, attributes);
                dCompany.Info.Region                = provider.GetAttributeValue(ProfileAttributeType.companyRegion, pAttributes, attributes);
                dCompany.Info.TaxCode               = provider.GetAttributeValue(ProfileAttributeType.companyTaxCode, pAttributes, attributes);
                dCompany.Info.ReaNumber             = provider.GetAttributeValue(ProfileAttributeType.companyReaNumber, pAttributes, attributes);
                dCompany.Info.AssociationCategories = provider.GetAttributeValue(ProfileAttributeType.companyAssociations, pAttributes, attributes);
                return(dCompany);

            case (int)UserTypeStandard.Employee:
                dtoEmployee dEmployee = (dtoEmployee)profile;
                Person      anonymous = ProfileService.GetAnonymousUser();
                Agency      agency    = null;
                if (anonymous == null)
                {
                    Dictionary <ProfileAttributeType, string> agencyAttributes = GetUserAttributesForAgency(provider, attributes);
                    agency = ProfileService.GetAgency(agencyAttributes);
                    if (agency == null)
                    {
                        agency = ProfileService.GetDefaultAgency(idOrganization);
                    }
                }
                else
                {
                    agency = GetAgencyByAttributes(anonymous.Id, idOrganization, provider, attributes);
                }

                if (agency != null)
                {
                    dEmployee.CurrentAgency = new KeyValuePair <long, string>(agency.Id, agency.Name);
                }
                else
                {
                    dEmployee.CurrentAgency = ProfileService.GetEmptyAgency(idOrganization);
                }

                return(dEmployee);


            case (int)UserTypeStandard.ExternalUser:
                dtoExternal dExternal = (dtoExternal)profile;
                dExternal.ExternalUserInfo = provider.GetAttributeValue(ProfileAttributeType.externalUserInfo, pAttributes, attributes);
                return(dExternal);

            default:
                return(profile);
            }
        }
Exemplo n.º 16
0
 public ExternalLoginInfo AddFromInternalAccount(InternalLoginInfo internalAccount, MacUrlAuthenticationProvider provider, String externalString)
 {
     return(AddUserInfo(internalAccount.Person, internalAccount.Person, provider, externalString));
 }
Exemplo n.º 17
0
        private void ExternalLogonManage(dtoMacUrlToken vToken, ExternalLoginInfo userInfo, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            String wizardUrl  = lm.Comol.Core.BaseModules.ProfileManagement.RootObject.MacUrlProfileWizard(provider.Id, attributes);
            String defaultUrl = provider.RemoteLoginUrl;

            if (userInfo.Person == null)
            {
                View.GoToProfile(vToken, wizardUrl);
            }
            else if (!userInfo.isEnabled || userInfo.Person.isDisabled)
            {
                View.DisplayAccountDisabled(lm.Comol.Core.BaseModules.ProfileManagement.RootObject.DisabledProfile(provider.Id, userInfo.Person.Id));
            }
            else
            {
                UrlService.UpdateUserAccessTime(userInfo.Person);
                if (userInfo.Person.AcceptPolicy || !PolicyService.UserHasPolicyToAccept(userInfo.Person))
                {
                    View.LogonUser(userInfo.Person, provider.Id, defaultUrl, false, CurrentManager.GetUserDefaultIdOrganization(userInfo.Person.Id));
                }
                else
                {
                    View.DisplayPrivacyPolicy(userInfo.Person.Id, provider.Id, defaultUrl, false);
                }
            }
        }
Exemplo n.º 18
0
        private void UrlProviderLogon(dtoMacUrlProviderIdentifier identifier, String fromUrl)
        {
            MacUrlAuthenticationProvider provider = UrlService.GetProvider(identifier.IdProvider);

            if (provider != null)
            {
                List <dtoMacUrlUserAttribute> attributes = View.GetTokenAttributes(provider.GetUserAttributes());

                dtoMacUrlToken vToken = provider.ValidateToken(attributes, fromUrl, UserContext.IpAddress, UserContext.ProxyIpAddress);

                //if (!String.IsNullOrEmpty(provider.RemoteLoginUrl))
                //    View.SetExternalWebLogonUrl(provider.RemoteLoginUrl);
                //else if (!String.IsNullOrEmpty(provider.SenderUrl))
                //    View.SetExternalWebLogonUrl(provider.SenderUrl);
                List <ExternalLoginInfo> users           = UrlService.FindUserByIdentifier(vToken.UniqueIdentifyer, provider);
                List <ExternalLoginInfo> userIdentifiers = null;
                Person logonUser = null;
                if (View.PreloadForDebug)
                {
                    View.DisplayDebugInfo(vToken);
                }
                else
                {
                    // NEL CASO IN CUI UN UTENTE ACCEDA CoN DUE IDENTIFICATIVI DISTINTI MA IL SISTEMA NON CONSENTA DUE TAXCODE identici !
                    if (!String.IsNullOrEmpty(vToken.UniqueIdentifyer) && users.Count == 0 && provider.AllowMultipleInsert && !provider.AllowTaxCodeDuplication)
                    {
                        String        taxCode = provider.GetAttributeValue(ProfileAttributeType.taxCode, attributes);
                        List <Person> pItems  = ProfileService.GetUserByTaxCode(taxCode);
                        if (pItems != null && pItems.Count == 1)
                        {
                            logonUser       = pItems[0];
                            userIdentifiers = UrlService.GetUserIdentifiers(pItems[0], provider);
                        }
                    }
                    switch (vToken.Evaluation.Result)
                    {
                    case UrlProviderResult.ValidToken:
                        if (users.Count == 1)
                        {
                            ExternalLoginInfo loginInfo = users[0];
                            if (loginInfo.Person != null)
                            {
                                UpdateProfileByToken(loginInfo.Person, provider, attributes);
                            }
                            ExternalLogonManage(vToken, loginInfo, provider, attributes);
                        }
                        else if (logonUser != null && !logonUser.isDisabled)
                        {
                            UpdateProfileByToken(logonUser, provider, attributes);
                            ExternalLogonManage(vToken, UrlService.AddUserInfo(logonUser, provider, vToken.UniqueIdentifyer), provider, attributes);
                        }
                        else if (!String.IsNullOrEmpty(vToken.UniqueIdentifyer) && users.Count == 0)
                        {
                            if (provider.AutoEnroll)
                            {
                                UrlProviderResult result               = UrlProviderResult.ValidToken;
                                Int32             idOrganization       = 0;
                                Int32             idProfileType        = 0;
                                Int32             idProfile            = 0;
                                List <OrganizationAttributeItem> items = provider.GetOrganizationsInfo(attributes);
                                if (items == null || items.Count != 1)
                                {
                                    result = UrlProviderResult.InvalidToken;
                                }
                                else
                                {
                                    List <UserProfileAttribute> pAttributes = provider.GetProfileAttributes();

                                    idOrganization = items[0].Organization.Id;
                                    idProfileType  = items[0].IdDefaultProfile;

                                    String taxCode = provider.GetAttributeValue(ProfileAttributeType.taxCode, pAttributes, attributes);
                                    if (!provider.AllowTaxCodeDuplication && !UrlService.isUniqueTaxCode(taxCode))
                                    {
                                        result = UrlProviderResult.InvalidToken;
                                        View.DisplayTaxCodeAlreadyPresent();
                                    }
                                    else
                                    {
                                        idProfile = View.CreateUserProfile(Helper.GetProfileData(provider, pAttributes, attributes, idOrganization, idProfileType), idProfileType, idOrganization, provider, UrlService.GetCredentials(provider, attributes));
                                    }
                                }
                                if (result != UrlProviderResult.ValidToken)
                                {
                                    View.DisplayInvalidMessage(UrlProviderResult.InvalidToken);
                                }
                                else if (idProfile == 0)
                                {
                                    View.DisplayAutoEnrollmentFailed();
                                }
                                else
                                {
                                    if (provider.HasCatalogues())
                                    {
                                        UrlService.UpdateCatalogueAssocation(idProfile, provider, attributes);
                                    }
                                    ExternalLogonManage(vToken, UrlService.GetUserInfo(provider.Id, idProfile, vToken.UniqueIdentifyer), provider, attributes);
                                }
                            }
                            else
                            {
                                View.GoToProfile(vToken, lm.Comol.Core.BaseModules.ProfileManagement.RootObject.MacUrlProfileWizard(provider.Id, attributes));
                            }
                        }
                        break;

                    default:
                        int idPerson = (users.Count == 1 && users[0].Person != null) ? users[0].Person.Id : 0;

                        if (users.Count == 1 && users[0].Person != null)
                        {
                            View.DisplayInvalidMessage(users[0].Person.SurnameAndName, vToken.Evaluation.Result);
                        }
                        else
                        {
                            View.DisplayInvalidMessage(vToken.Evaluation.Result);
                        }

                        if (!String.IsNullOrEmpty(provider.RemoteLoginUrl))
                        {
                            View.SetAutoLogonUrl(provider.RemoteLoginUrl);
                        }
                        else if (!String.IsNullOrEmpty(provider.SenderUrl))
                        {
                            View.SetAutoLogonUrl(provider.SenderUrl);
                        }
                        break;
                    }
                }
            }
            else
            {
                View.DisplayUrlAuthenticationUnavailable();
            }
        }
Exemplo n.º 19
0
        public ExternalLoginInfo AddUserInfo(Person person, MacUrlAuthenticationProvider provider, String externalString)
        {
            Person currentUser = Manager.GetPerson(UC.CurrentUserID);

            return(AddUserInfo(person, (currentUser == null) ? person : currentUser, provider, externalString));
        }
Exemplo n.º 20
0
        private ExternalLoginInfo AddUserInfo(Person person, Person currentUser, MacUrlAuthenticationProvider provider, String externalString)
        {
            ExternalLoginInfo account = null;

            try
            {
                Manager.BeginTransaction();
                //List<String> userIdentifiers = externalString.Split(' ').ToList();
                var query = (from si in Manager.GetIQ <ExternalLoginInfo>() where si.Provider == provider select si);

                List <ExternalLoginInfo> accounts = new List <ExternalLoginInfo>();
                //foreach (String identifier in userIdentifiers.Where(i => !string.IsNullOrEmpty(i)).ToList())
                //{
                //    accounts.AddRange(query.Where(si => si.Provider == provider && si.IdExternalString == identifier).ToList());
                //}
                accounts.AddRange(query.Where(si => si.Provider == provider && si.IdExternalString == externalString).ToList());


                //foreach (String identifier in userIdentifiers.Where(i => !string.IsNullOrEmpty(i)).ToList())
                //{
                if (accounts.Where(a => a.IdExternalString.ToLower() == externalString.ToLower()).Any())
                {
                    account = accounts.Where(a => a.IdExternalString.ToLower() == externalString.ToLower()).FirstOrDefault();
                    if (account != null)
                    {
                        UpdateAccount(account, person, currentUser, provider, externalString);
                    }
                    else
                    {
                        account = CreateAccount(person, currentUser, provider, externalString);
                    }
                }
                else
                {
                    account = CreateAccount(person, currentUser, provider, externalString);
                }
                Manager.SaveOrUpdate(account);
                AddToHistory(account);
                //}
                if (person.IdDefaultProvider == 0 || String.IsNullOrEmpty(person.FirstLetter))
                {
                    //// TEMPORANEO
                    //creator.Login = login;
                    //creator.Password=userInfo.Password;
                    //// TEMPORANEO
                    if (person.IdDefaultProvider == 0 && provider != null)
                    {
                        person.IdDefaultProvider = provider.Id;
                    }
                    if (String.IsNullOrEmpty(person.FirstLetter))
                    {
                        person.FirstLetter = person.Surname[0].ToString().ToLower();
                    }
                    Manager.SaveOrUpdate(person);
                }
                Manager.Commit();
            }
            catch (Exception ex)
            {
                Manager.RollBack();
            }
            return(account);
        }
Exemplo n.º 21
0
        public void InitView(Boolean defaultPageForInternal)
        {
            Person person = CurrentManager.GetPerson(UserContext.CurrentUserID);

            if (person != null && person.TypeID != (int)UserTypeStandard.Guest && person.TypeID != (int)UserTypeStandard.PublicUser)
            {
                List <AuthenticationProvider> providers = ProfileService.GetUserAuthenticationProviders(person);
                if (providers.Count == 0 || person.IdDefaultProvider == 0 || !providers.Where(p => p.Id == person.IdDefaultProvider).Any())
                {
                    //if (IsShibbolethSessionActive())

                    ////if (person.AuthenticationTypeID != 1)
                    ////    View.LoadOldAuthenticationPage(person.AuthenticationTypeID);
                    ////else
                    //    View.GoToDefaultPage();
                    LoadData(LogoutMode.logoutMessage, AuthenticationProviderType.ActiveDirectory, "");
                }
                else
                {
                    lm.Comol.Core.DomainModel.Helpers.dtoLoginCookie userInfo = View.UserAccessInfo;
                    AuthenticationProvider provider = providers.Where(p => p.Id == userInfo.IdProvider).FirstOrDefault();
                    if (provider == null)
                    {
                        provider = providers.Where(p => p.Id == person.IdDefaultProvider).FirstOrDefault();
                    }

                    AuthenticationProviderType providerType = (provider == null) ? AuthenticationProviderType.None : provider.ProviderType;

                    switch (providerType)
                    {
                    case AuthenticationProviderType.Internal:
                        if (defaultPageForInternal || provider.LogoutMode == LogoutMode.portalPage)
                        {
                            LoadData(LogoutMode.portalPage, providerType, "");
                        }
                        else
                        {
                            LoadData(provider.LogoutMode, providerType, "");
                        }
                        break;

                    case AuthenticationProviderType.Url:
                        UrlAuthenticationProvider urlProvider = (UrlAuthenticationProvider)provider;
                        LoadData(provider.LogoutMode, providerType, urlProvider.RemoteLoginUrl);
                        break;

                    case AuthenticationProviderType.UrlMacProvider:
                        MacUrlAuthenticationProvider mProvider = (MacUrlAuthenticationProvider)provider;
                        LoadData(provider.LogoutMode, providerType, mProvider.RemoteLoginUrl);
                        break;

                    default:
                        LoadData(LogoutMode.portalPage, providerType, "");
                        break;
                    }
                }
            }
            else
            {
                View.GoToDefaultPage();
            }
        }
Exemplo n.º 22
0
        public void MoveToNextStep(ProfileWizardStep step)
        {
            switch (step)
            {
            case ProfileWizardStep.UnknownProfileDisclaimer:
                MoveFromStepUnknownProfileDisclaimer();
                break;

            case ProfileWizardStep.InternalCredentials:
                MoveFromStepInternalCredentials();
                break;

            case ProfileWizardStep.OrganizationSelector:
                MoveFromStepOrganizationSelector();
                break;

            case ProfileWizardStep.ProfileTypeSelector:
                MoveFromStepProfileTypeSelector();
                break;

            case ProfileWizardStep.ProfileUserData:
                List <ProfilerError> errors = UrlService.VerifyProfileInfo(View.ProfileInfo, View.idProvider);
                if (errors.Count > 0)
                {
                    View.LoadProfileInfoError(errors);
                }
                else
                {
                    View.UnloadProfileInfoError();
                    if (!View.AvailableSteps.Contains(ProfileWizardStep.Privacy))
                    {
                        UpdateStepsToSkip(ProfileWizardStep.Privacy, true);
                        View.GotoStep(ProfileWizardStep.Summary);
                    }
                    else
                    {
                        if (!View.IsInitialized(ProfileWizardStep.Privacy))
                        {
                            View.InitializeStep(ProfileWizardStep.Privacy);
                        }
                        View.GotoStep(ProfileWizardStep.Privacy);
                    }
                }
                break;

            case ProfileWizardStep.Privacy:
                Boolean UseInternalCredentials = (View.SelectedProvider == AuthenticationProviderType.Internal);
                if (View.AcceptedMandatoryPolicy && UseInternalCredentials && View.IdProfile > 0)
                {
                    Person person = CurrentManager.GetPerson(View.IdProfile);
                    MacUrlAuthenticationProvider provider = GetProvider();
                    View.LogonUser(person, View.idProvider, provider.RemoteLoginUrl, false, CurrentManager.GetUserDefaultIdOrganization(View.IdProfile));
                }
                else if (View.AcceptedMandatoryPolicy && !UseInternalCredentials)
                {
                    View.GotoStep(ProfileWizardStep.Summary);
                }
                break;

            case ProfileWizardStep.Summary:
                break;
            }
        }
Exemplo n.º 23
0
 private Boolean UpdateAgencyAssocation(Int32 idUser, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
 {
     return(UpdateAgencyAssocation(idUser, Helper.GetAgencyByAttributes(idUser, idOrganization, provider, attributes)));
 }
Exemplo n.º 24
0
        private Boolean EditProfileType(Int32 idProfile, Int32 idNewType, Int32 idOrganization, MacUrlAuthenticationProvider provider, List <UserProfileAttribute> pAttributes, List <dtoMacUrlUserAttribute> attributes)
        {
            Boolean            result = false;
            ProfileTypeChanger person = CurrentManager.Get <ProfileTypeChanger>(idProfile);
            Int32 idOldType           = person.TypeID;

            dtoBaseProfile profile = GetCurrentProfileData(idProfile, idOldType, provider.ProviderType);

            if (idProfile > 0 && person != null)
            {
                Person people = CurrentManager.GetPerson(idProfile);
                if (people != null)
                {
                    CurrentManager.Detach(people);
                }
                if (person.TypeID == (int)UserTypeStandard.Company && idNewType != (int)UserTypeStandard.Company)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (idNewType == (int)UserTypeStandard.Company)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (person.TypeID == (int)UserTypeStandard.Employee && idNewType != (int)UserTypeStandard.Employee)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                else if (idNewType == (int)UserTypeStandard.Employee)
                {
                    person = ProfileService.EditProfileType(person, idNewType);
                }
                if (idOldType != idNewType && person != null)
                {
                    if (idNewType == (int)UserTypeStandard.Company)
                    {
                        dtoCompany company = (dtoCompany)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType);
                        if (idOldType == (int)UserTypeStandard.Employee || View.DeletePreviousProfileType(idProfile, idOldType, idNewType))
                        {
                            result = (ProfileService.SaveCompanyUser(company, null) != null);
                        }
                    }
                    else if (idNewType == (int)UserTypeStandard.Employee)
                    {
                        dtoEmployee employee = (dtoEmployee)Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType);
                        if (idOldType == (int)UserTypeStandard.Company || View.DeletePreviousProfileType(idProfile, idOldType, idNewType))
                        {
                            Employee savedEmployee = ProfileService.SaveEmployee(employee, null);
                            if (savedEmployee != null)
                            {
                                //long idAgency = employee.CurrentAgency.Key;
                                //if (idAgency < 1)
                                //    idAgency = ProfileService.GetEmptyAgency(0).Key;
                                //SaveAgencyAffiliation(employee.CurrentAgency.Key, IdProfile);
                                UpdateAgencyAssocation(idProfile, idOrganization, provider, attributes);
                            }
                            result = (savedEmployee != null);
                        }
                    }
                    else
                    {
                        result = View.EditProfileType(idProfile, Helper.GetProfileData(profile, provider, pAttributes, attributes, idOrganization, idNewType), idOldType, idNewType);
                    }
                    if (result && idOldType == (int)UserTypeStandard.Employee)
                    {
                        ProfileService.CloseEmployeeAffiliations(idProfile);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 25
0
        public Boolean UpdateCatalogueAssocation(Int32 idUser, MacUrlAuthenticationProvider provider, List <dtoMacUrlUserAttribute> attributes)
        {
            Boolean saved = false;

            try
            {
                Manager.BeginTransaction();
                Person person = Manager.GetPerson(idUser);
                if (person != null)
                {
                    List <String> userCodes    = new List <String>();
                    List <long>   idCatalogues = new List <long>();

                    if (provider.Attributes.Where(a => a.Type == UrlMacAttributeType.coursecatalogue && a.Deleted == BaseStatusDeleted.None).Any())
                    {
                        List <CatalogueAttribute> cAttributes = provider.Attributes.Where(p => p.Deleted == BaseStatusDeleted.None && p.Type == UrlMacAttributeType.coursecatalogue && p.GetType() == typeof(CatalogueAttribute)).Select(p => (CatalogueAttribute)p).ToList();
                        foreach (dtoMacUrlUserAttribute uAtt in attributes.Where(a => a.Type == UrlMacAttributeType.coursecatalogue && !String.IsNullOrEmpty(a.QueryValue)).ToList())
                        {
                            CatalogueAttribute pAtt = cAttributes.Where(a => a.Id == uAtt.Id).FirstOrDefault();
                            if (pAtt != null)
                            {
                                if (pAtt.AllowMultipleValue)
                                {
                                    userCodes.AddRange(uAtt.QueryValue.Split(pAtt.MultipleValueSeparator.ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList());
                                }
                                else
                                {
                                    userCodes.Add(uAtt.QueryValue);
                                }
                            }
                            idCatalogues.AddRange(pAtt.Items.Where(i => i.Deleted == BaseStatusDeleted.None && userCodes.Contains(i.RemoteCode)).Select(i => i.Catalogue.Id).ToList());
                        }
                        idCatalogues = idCatalogues.Distinct().ToList();
                    }

                    List <lm.Comol.Core.Catalogues.CataloguePersonAssignment> assignments = (from a in Manager.GetIQ <lm.Comol.Core.Catalogues.CataloguePersonAssignment>()
                                                                                             where a.AssignedTo.Id == idUser && a.Catalogue != null
                                                                                             select a).ToList();
                    foreach (lm.Comol.Core.Catalogues.CataloguePersonAssignment assignment in assignments)
                    {
                        if (idCatalogues.Contains(assignment.Catalogue.Id) && !assignment.Allowed)
                        {
                            assignment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
                            if (assignment.Deleted != BaseStatusDeleted.None)
                            {
                                assignment.FromProvider = true;
                                assignment.Deleted      = BaseStatusDeleted.None;
                            }
                            assignment.Allowed = true;
                            Manager.SaveOrUpdate(assignment);
                        }
                        else if (!idCatalogues.Contains(assignment.Catalogue.Id) && assignment.Deleted == BaseStatusDeleted.None && assignment.Allowed && assignment.FromProvider)
                        {
                            assignment.UpdateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
                            assignment.Allowed = false;
                            Manager.SaveOrUpdate(assignment);
                        }
                    }
                    foreach (long idCatalogue in idCatalogues.Where(i => !assignments.Select(a => a.Catalogue.Id).ToList().Contains(i)).ToList())
                    {
                        Catalogues.Catalogue catalogue = Manager.Get <Catalogues.Catalogue>(idCatalogue);
                        if (catalogue != null)
                        {
                            lm.Comol.Core.Catalogues.CataloguePersonAssignment pAssignment = new Catalogues.CataloguePersonAssignment();
                            pAssignment.CreateMetaInfo(person, UC.IpAddress, UC.ProxyIpAddress);
                            pAssignment.FromProvider = true;
                            pAssignment.AssignedTo   = person;
                            pAssignment.Allowed      = true;
                            pAssignment.Catalogue    = catalogue;
                            Manager.SaveOrUpdate(pAssignment);
                        }
                    }
                    saved = true;
                }
                Manager.Commit();
            }

            catch (Exception ex) {
                saved = false;
                Manager.RollBack();
            }

            return(saved);
        }