コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="uiCode">user language code from browser</param>
        public void InitializeLanguageView(String uiCode)
        {
            String lCode = uiCode;
            List <dtoMacUrlProviderIdentifier> items = UrlService.GetActiveApplicationIdentifiers();
            Language language = CurrentManager.GetLanguage(uiCode);

            if (items != null && items.Any())
            {
                dtoMacUrlProviderIdentifier identifier = View.GetUrlIdentifier(items);
                BaseUrlMacAttribute         lAttribute = UrlService.GetProviderLanguageAttribute((identifier == null) ? 0 : identifier.IdProvider);
                if (lAttribute != null)
                {
                    lCode = View.GetUrlAttributeValue(lAttribute.QueryStringName);
                }
            }
            if (lCode != "" && uiCode.Contains(lCode))
            {
                lCode = uiCode;
            }
            if (language == null || (lCode != uiCode && !String.IsNullOrEmpty(lCode)))
            {
                language = CurrentManager.GetLanguageByCodeOrDefault(lCode);
            }
            View.LoadLanguage(language);
        }
コード例 #2
0
        public void InitView()
        {
            Boolean accessAvailable = !(View.isSystemOutOfOrder && !View.AllowAdminAccess);

            View.AllowSubscription = !View.isSystemOutOfOrder && View.SubscriptionActive;
            if (!accessAvailable)
            {
                View.DisplaySystemOutOfOrder();
            }
            else
            {
                if (View.HasUrlValues)
                {
                    List <dtoMacUrlProviderIdentifier> items = UrlService.GetActiveApplicationIdentifiers();
                    if (items == null || items.Count == 0)
                    {
                        View.DisplayProviderNotFound();
                    }
                    else
                    {
                        dtoMacUrlProviderIdentifier identifier = View.GetUrlIdentifier(items);
                        if (identifier == null)
                        {
                            View.DisplayProviderNotFound();//DisplayInvalidMessage(UrlProviderResult.UnknowToken);
                        }
                        else if (!identifier.isEnabled)
                        {
                            View.DisplayUrlAuthenticationUnavailable();
                        }
                        else
                        {
                            View.FromLogonUrl = View.PreloadFromUrl;
                            UrlProviderLogon(identifier, View.PreloadFromUrl);
                        }
                    }
                }
                else
                {
                    View.DisplayNoToken();
                }
            }
        }
コード例 #3
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();
            }
        }