Ejemplo n.º 1
0
        public ExternalUserAssociationMatchResult ExternalUserAssociationCheck(ExternalAuthenticationResult externalAuthenticationResult, string ip)
        {
            if (externalAuthenticationResult == null)
            {
                throw new ArgumentNullException("externalAuthenticationResult");
            }
            var match = _externalUserAssociationRepository.Get(externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey);

            if (match == null)
            {
                _securityLogService.CreateLogEntry((int?)null, null, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey, externalAuthenticationResult.Name), SecurityLogType.ExternalAssociationCheckFailed);
                return(new ExternalUserAssociationMatchResult {
                    Successful = false
                });
            }
            var user = _userRepository.GetUser(match.UserID);

            if (user == null)
            {
                _securityLogService.CreateLogEntry((int?)null, null, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey, externalAuthenticationResult.Name), SecurityLogType.ExternalAssociationCheckFailed);
                return(new ExternalUserAssociationMatchResult {
                    Successful = false
                });
            }
            var result = new ExternalUserAssociationMatchResult
            {
                Successful = true,
                ExternalUserAssociation = match,
                User = user
            };

            _securityLogService.CreateLogEntry(user, user, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", match.Issuer, match.ProviderKey, match.Name), SecurityLogType.ExternalAssociationCheckSuccessful);
            return(result);
        }
Ejemplo n.º 2
0
		public ExternalUserAssociationMatchResult ExternalUserAssociationCheck(ExternalAuthenticationResult externalAuthenticationResult, string ip)
		{
			if (externalAuthenticationResult == null)
				throw new ArgumentNullException("externalAuthenticationResult");
			var match = _externalUserAssociationRepository.Get(externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey);
			if (match == null)
			{
				_securityLogService.CreateLogEntry((int?)null, null, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey, externalAuthenticationResult.Name), SecurityLogType.ExternalAssociationCheckFailed);
				return new ExternalUserAssociationMatchResult {Successful = false};
			}
			var user = _userRepository.GetUser(match.UserID);
			if (user == null)
			{
				_securityLogService.CreateLogEntry((int?)null, null, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", externalAuthenticationResult.Issuer, externalAuthenticationResult.ProviderKey, externalAuthenticationResult.Name), SecurityLogType.ExternalAssociationCheckFailed);
				return new ExternalUserAssociationMatchResult {Successful = false};
			}
			var result = new ExternalUserAssociationMatchResult
			             {
				             Successful = true,
				             ExternalUserAssociation = match,
				             User = user
			             };
			_securityLogService.CreateLogEntry(user, user, ip, String.Format("Issuer: {0}, Provider: {1}, Name: {2}", match.Issuer, match.ProviderKey, match.Name), SecurityLogType.ExternalAssociationCheckSuccessful);
			return result;
		}
        public async Task <ExternalUserAssociationMatchResult> ExternalUserAssociationCheck(ExternalLoginInfo externalLoginInfo, string ip)
        {
            if (externalLoginInfo == null)
            {
                throw new ArgumentNullException(nameof(externalLoginInfo));
            }
            var match = await _externalUserAssociationRepository.Get(externalLoginInfo.LoginProvider, externalLoginInfo.ProviderKey);

            if (match == null)
            {
                await _securityLogService.CreateLogEntry((int?)null, null, ip, $"Issuer: {externalLoginInfo.LoginProvider}, Provider: {externalLoginInfo.ProviderKey}, Name: {externalLoginInfo.ProviderDisplayName}", SecurityLogType.ExternalAssociationCheckFailed);

                return(new ExternalUserAssociationMatchResult {
                    Successful = false
                });
            }
            var user = await _userRepository.GetUser(match.UserID);

            if (user == null)
            {
                await _securityLogService.CreateLogEntry((int?)null, null, ip, $"Issuer: {externalLoginInfo.LoginProvider}, Provider: {externalLoginInfo.ProviderKey}, Name: {externalLoginInfo.ProviderDisplayName}", SecurityLogType.ExternalAssociationCheckFailed);

                return(new ExternalUserAssociationMatchResult {
                    Successful = false
                });
            }
            var result = new ExternalUserAssociationMatchResult
            {
                Successful = true,
                ExternalUserAssociation = match,
                User = user
            };
            await _securityLogService.CreateLogEntry(user, user, ip, $"Issuer: {match.Issuer}, Provider: {match.ProviderKey}, Name: {match.Name}", SecurityLogType.ExternalAssociationCheckSuccessful);

            return(result);
        }