/// <summary>
        /// Authorizatizes the specified user via ERMS authentication.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="domainName">Name of the domain.</param>
        /// <param name="environmentName">Name of the environment.</param>
        /// <param name="applicationName">Name of the applicaiton.</param>
        /// <returns>User Identity</returns>
        public UserIdentity GetUserIdentity(string userName, string domainName, string environmentName, string applicationName)
        {
            IList <Permission> permissions;

            ApplicationGroup currentAppGroup;
            string           appName = ConfigurationManager.AppSettings.Get("AppName");

            if (!String.IsNullOrEmpty(appName))
            {
                if (appName.ToLower() == "erms" || appName.ToLower() == "grs")
                {
                    currentAppGroup = ApplicationGroup.GRS;
                }
                else
                {
                    currentAppGroup = ApplicationGroup.Pricing;
                }
            }
            else
            {
                currentAppGroup = ApplicationGroup.Pricing;
            }

            if (currentAppGroup == ApplicationGroup.GRS)
            {
                permissions = AllPermissionDescriptionsGRS.Select(permission => new Permission()
                {
                    FactDescription = permission
                }).ToList();
            }
            else
            {
                permissions = AllPermissionDescriptions.Select(permission => new Permission()
                {
                    FactDescription = permission
                }).ToList();
            }

            try
            {
                EnterpriseIdentity enterpriseIdentity = AuthenticationService.Authenticate(new EnterpriseIdentity()
                {
                    ApplicationName   = applicationName,
                    Username          = userName,
                    DomainName        = domainName,
                    EnvironmentName   = environmentName,
                    ErmsPermissionSet = new PermissionSet(permissions, null)
                });

                return(Transform(enterpriseIdentity));
            }
            catch (Exception ex)
            {
                throw new UnauthorizedAPIException(ex.Message);
            }
        }
Esempio n. 2
0
        public AuthenticateResult Authenticate(UserCredentials userCredential)
        {
            Credentials credentials = new Credentials
            {
                UserName = userCredential.UserName,
                Password = userCredential.Password
            };
            AuthenticationServiceClient authenticateService = new AuthenticationServiceClient();

            return(Mapper.Map <AuthenticateResult>(authenticateService.Authenticate(credentials)));
        }
Esempio n. 3
0
        public bool Authenticate(string username, string password)
        {
            var middlewareService = new AuthenticationServiceClient();

            middlewareService.ClientCredentials.Windows.ClientCredential.UserName = "******";
            middlewareService.ClientCredentials.Windows.ClientCredential.Password = "******";
            if (middlewareService.CheckExistence(username))
            {
                return(middlewareService.Authenticate(username, password));
            }

            return(false);
        }