예제 #1
0
        /// <summary>
        /// Valida o usuário no provedor de identidade
        /// </summary>
        /// <param name="userName">Nome de usuário</param>
        /// <param name="password">Senha</param>
        /// <param name="servicesContext">Nome do contexto de serviços que será usado na autenticação.</param>
        /// <param name="parameters">Demais informações necessárias</param>
        /// <returns></returns>
        public ValidateUserResultWrapper ValidateUser(string userName, string password, string servicesContext, SecurityParameter[] parameters)
        {
            IValidateUserResult result = null;

            try
            {
                result = Membership.ValidateUser(userName, password, parameters);
            }
            catch (Exception ex)
            {
                result = new ValidateUserResult {
                    Message = ex.Message,
                    Status  = AuthenticationStatus.ErrorInValidate
                };
            }
            LogRequest(userName, result.Status);
            Colosoft.Net.ServiceAddress userProviderServiceAddress           = null;
            Colosoft.Net.ServiceAddress profileProviderServiceAddress        = null;
            Colosoft.Net.ServiceAddress serviceAddressProviderServiceAddress = null;
            if (result.Status == AuthenticationStatus.PasswordWarning || result.Status == AuthenticationStatus.Success)
            {
                userProviderServiceAddress           = GetServiceAddress(_configurationSection.UserProviderServiceName, servicesContext);
                profileProviderServiceAddress        = GetServiceAddress(_configurationSection.ProfileProviderServiceName, servicesContext);
                serviceAddressProviderServiceAddress = GetServiceAddress(_configurationSection.ServiceAddressProviderServiceName, servicesContext);
            }
            return(new ValidateUserResultWrapper(result, userProviderServiceAddress, profileProviderServiceAddress, serviceAddressProviderServiceAddress));
        }
예제 #2
0
 /// <summary>
 /// Construtor padrão.
 /// </summary>
 /// <param name="instance">Instancia que será adaptada.</param>
 /// <param name="userProviderServiceAddress">Endereço do serviço do provedor dos usuários.</param>
 /// <param name="profileProviderServiceAddress">Endereço do serviço do provedor dos perfis.</param>
 /// <param name="serviceAddressProviderServiceAddress">Endereço do serviço do provedor dos endereços dos serviços.</param>
 public ValidateUserResultWrapper(IValidateUserResult instance, Colosoft.Net.ServiceAddress userProviderServiceAddress, Colosoft.Net.ServiceAddress profileProviderServiceAddress, Colosoft.Net.ServiceAddress serviceAddressProviderServiceAddress)
 {
     Status     = instance.Status;
     Message    = instance.Message;
     User       = instance.User != null ? new User(instance.User) : null;
     Captcha    = instance.Captcha;
     ExpireDate = instance.ExpireDate;
     Token      = instance.Token;
     UserProviderServiceAddress           = userProviderServiceAddress;
     ProfileProviderServiceAddress        = profileProviderServiceAddress;
     ServiceAddressProviderServiceAddress = serviceAddressProviderServiceAddress;
 }
예제 #3
0
        /// <summary>
        /// Valida os dados do token.
        /// </summary>
        /// <param name="token">Token que será validado.</param>
        /// <param name="servicesContext">Nome do contexto de serviços que será usado na autenticação.</param>
        /// <returns></returns>
        public ValidateUserResultWrapper ValidateToken(string token, string servicesContext)
        {
            var result = Membership.ValidateToken(token);

            Colosoft.Net.ServiceAddress userProviderServiceAddress           = null;
            Colosoft.Net.ServiceAddress profileProviderServiceAddress        = null;
            Colosoft.Net.ServiceAddress serviceAddressProviderServiceAddress = null;
            if (result.Status == AuthenticationStatus.PasswordWarning || result.Status == AuthenticationStatus.Success)
            {
                userProviderServiceAddress           = GetServiceAddress(_configurationSection.UserProviderServiceName, servicesContext);
                profileProviderServiceAddress        = GetServiceAddress(_configurationSection.ProfileProviderServiceName, servicesContext);
                serviceAddressProviderServiceAddress = GetServiceAddress(_configurationSection.ServiceAddressProviderServiceName, servicesContext);
            }
            return(new ValidateUserResultWrapper(result, userProviderServiceAddress, profileProviderServiceAddress, serviceAddressProviderServiceAddress));
        }
예제 #4
0
        public RemoteTokenProvider()
        {
            Net.ServicesConfiguration.Current.Updated += ServicesConfigurationUpdated;
            Net.ServiceClientsManager.Current.Register(_tokenProviderClientUid,
                                                       () =>
            {
                Colosoft.Net.ServiceAddress serviceAddress = null;

                //if (Net.ServicesConfiguration.Current.Contains(TokenProviderServiceClientConfigurationName))
                serviceAddress = Net.ServicesConfiguration.Current[TokenProviderServiceClientConfigurationName];

                /*else
                 *  throw new InvalidOperationException("Not found address for TokenProviderServiceClient");*/

                var client = new TokenProviderServiceReference.TokenProviderServiceClient(serviceAddress.GetBinding(), serviceAddress.GetEndpointAddress());

                if (ConfiguringTokenProviderClient != null)
                {
                    ConfiguringTokenProviderClient(this, new ConfigureRemoteClientEventArgs(client, client.Endpoint));
                }

                return(client);
            });
        }
예제 #5
0
 /// <summary>
 /// Define o endereço do serviço do provedor de perfis.
 /// </summary>
 /// <param name="address"></param>
 public static void SetServiceAddress(Colosoft.Net.ServiceAddress address)
 {
     Net.ServicesConfiguration
     .Current[ProfileProviderServiceClientConfigurationName] = address;
 }
예제 #6
0
 /// <summary>
 /// Define o endereço do serviço de autenticação.
 /// </summary>
 /// <param name="address"></param>
 public static void SetAuthenticationServiceAddress(Colosoft.Net.ServiceAddress address)
 {
     Net.ServicesConfiguration
     .Current[AuthenticationServiceClientConfigurationName] = address;
 }