コード例 #1
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (WayPointVisibilityID?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Waypoint?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (From?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (To?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ConveyanceId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ConveyanceRef?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (ShippingAgent?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalConsignments?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DirectConsignments?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TransshipmentConsignments?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalCargos?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (FullCargos?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (EmptyCargos?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalRiskDetected?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Consignment?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CargoId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RiskType?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RiskScore?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Severity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Details?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Suggestions?.GetHashCode() ?? 0);
            return(hashCode);
        }
        static Dictionary <string, RiskScore> BuildRiskyData(RiskyList list)
        {
            Dictionary <string, RiskScore> riskyUserData = new Dictionary <string, RiskScore>();

            foreach (Dictionary <string, string> user in list.Value)
            {
                RiskScore level = RiskScore.NotEvaluated;
                if (user.ContainsKey("userPrincipalName") && !String.IsNullOrEmpty(user["userPrincipalName"]))
                {
                    if (!String.IsNullOrEmpty(user["riskLevel"]))

                    {
                        if (String.Compare(user["riskLevel"], "high", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            level = RiskScore.High;
                        }
                        else if (String.Compare(user["riskLevel"], "low", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            level = RiskScore.Low;
                        }
                        else if (String.Compare(user["riskLevel"], "medium", StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            level = RiskScore.Medium;
                        }
                        riskyUserData.Add(user["userPrincipalName"], level);
                    }
                }
            }

            return(riskyUserData);
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the ITransactionStatus class.
 /// </summary>
 /// <param name="chainalysisRiskScore">Possible values include: 'Red',
 /// 'Amber', 'Green'</param>
 public ITransactionStatus(int outputNumber, double transactionAmount, RiskScore chainalysisRiskScore, string clientId = default(string), string transactionHash = default(string), string chainalysisName = default(string), string chainalysisCategory = default(string), string walletAddress = default(string))
 {
     ClientId             = clientId;
     TransactionHash      = transactionHash;
     OutputNumber         = outputNumber;
     TransactionAmount    = transactionAmount;
     ChainalysisName      = chainalysisName;
     ChainalysisRiskScore = chainalysisRiskScore;
     ChainalysisCategory  = chainalysisCategory;
     WalletAddress        = walletAddress;
     CustomInit();
 }
コード例 #4
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (WaypointriskID?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Consignment?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CargoId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RiskTypeId?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (RiskScore?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Severity?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Details?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Suggestions?.GetHashCode() ?? 0);
            return(hashCode);
        }
コード例 #5
0
        internal static string ToSerializedValue(this RiskScore value)
        {
            switch (value)
            {
            case RiskScore.Red:
                return("Red");

            case RiskScore.Amber:
                return("Amber");

            case RiskScore.Green:
                return("Green");
            }
            return(null);
        }
        /// <summary>
        /// Gets the risk of a user by lookoing at the IP data from AAD
        /// </summary>
        /// <param name="upn">UPN of the user</param>
        /// <returns></returns>
        public static RiskScore GetRiskScore(string upn)
        {
            Dictionary <string, string> accessTokenResponse = GetAccessToken();
            RiskyList list = GetRiskyUsers(accessTokenResponse["token_type"], accessTokenResponse["access_token"]);
            Dictionary <string, RiskScore> riskyUsers = BuildRiskyData(list);
            RiskScore level = RiskScore.NotEvaluated;

            if (null != riskyUsers)
            {
                if (riskyUsers.ContainsKey(upn))
                {
                    level = riskyUsers[upn];
                }
            }
            return(level);
        }
        public Task <ThrottleStatus> EvaluatePreAuthentication(ThreatDetectionLogger logger, RequestContext requestContext, SecurityContext securityContext, ProtocolContext protocolContext, IList <Claim> additionalClams)
        {
            try
            {
                RiskScore isRisky = RiskyUserHelper.GetRiskScore(securityContext.UserIdentifier);

                if (isRisky == RiskScore.High)
                {
                    logger?.WriteAdminLogErrorMessage($"EvaluatePreAuthentication: Blocked request for user {securityContext.UserIdentifier}");
                    return(Task.FromResult <ThrottleStatus>(ThrottleStatus.Block));
                }
                logger?.WriteDebugMessage($"EvaluatePreAuthentication: Allowed request for user {securityContext.UserIdentifier}");
                return(Task.FromResult <ThrottleStatus>(ThrottleStatus.Allow));
            }
            catch (Exception ex)
            {
                logger.WriteAdminLogErrorMessage(ex.ToString());
                throw;
            }

            throw new NotImplementedException();
        }
        Task <RiskScore> IPostAuthenticationThreatDetectionModule.EvaluatePostAuthentication(ThreatDetectionLogger logger, RequestContext requestContext, SecurityContext securityContext, ProtocolContext protocolContext, AuthenticationResult authenticationResult, IList <Claim> additionalClams)
        {
            try
            {
                RiskScore isRisky = RiskyUserHelper.GetRiskScore(securityContext.UserIdentifier);

                if (isRisky == RiskScore.High || isRisky == RiskScore.Medium)
                {
                    logger?.WriteAdminLogErrorMessage($"EvaluatePostAuthentication: Risk Score {isRisky}  returned for user {securityContext.UserIdentifier}");
                }
                else
                {
                    logger?.WriteDebugMessage($"EvaluatePostAuthentication: Risk Score {isRisky} returned for user {securityContext.UserIdentifier}");
                }
                return(Task.FromResult <RiskScore>(isRisky));
            }
            catch (Exception ex)
            {
                logger.WriteAdminLogErrorMessage(ex.ToString());
                throw;
            }

            throw new NotImplementedException();
        }
コード例 #9
0
        public async Task <RiskScore> Post([FromBody] RiskScore request)
        {
            RiskScore objRiskSCoreResponse = new RiskScore();
            var       json          = JsonConvert.SerializeObject(request);
            var       stringcontent = new StringContent(json, UnicodeEncoding.UTF8, "application/json");

            try
            {
                using (var httpClient = new HttpClient())
                {
                    using (var response = await httpClient.PostAsync("https://svcsexplorers.azurewebsites.net/model/riskscore", stringcontent))
                    {
                        string apiResponse = await response.Content.ReadAsStringAsync();

                        objRiskSCoreResponse = JsonConvert.DeserializeObject <Response>(apiResponse).responseObject;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            return(objRiskSCoreResponse);
        }