当前位置: 首页>>代码示例>>C#>>正文


C# Response.setAction方法代码示例

本文整理汇总了C#中Response.setAction方法的典型用法代码示例。如果您正苦于以下问题:C# Response.setAction方法的具体用法?C# Response.setAction怎么用?C# Response.setAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


在下文中一共展示了Response.setAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: findAppropriateResponse

	/**
	 * Find/generate {@link Response} appropriate for specified {@link Attack}.
	 * 
	 * @param attack {@link Attack} that is being analyzed
	 * @return {@link Response} to be executed for given {@link Attack}
	 */
	protected Response findAppropriateResponse(Attack attack) {
		DetectionPoint triggeringDetectionPoint = attack.GetDetectionPoint();
		
		SearchCriteria criteria = new SearchCriteria().
				setUser(attack.GetUser()).
				setDetectionPoint(triggeringDetectionPoint).
                setDetectionSystemIds(appSensorServer.getConfiguration().getRelatedDetectionSystems(attack.GetDetectionSystemId()));
		
		//grab any existing responses
		Collection<Response> existingResponses = appSensorServer.getResponseStore().findResponses(criteria);
		
		string responseAction = null;
		Interval interval = null;

        Collection<Response> possibleResponses = findPossibleResponses(triggeringDetectionPoint);

		//if (existingResponses == null || existingResponses.Size() == 0) {
        if(existingResponses == null || existingResponses.Count == 0) {
			//no responses yet, just grab first configured response from detection point
            // Response response = possibleResponses.iterator().next();
            IEnumerator <Response> enumerator = possibleResponses.GetEnumerator();
            enumerator.MoveNext();
            Response response = enumerator.Current;
			
			responseAction = response.getAction();
			interval = response.getInterval();
		} else {
			foreach (Response configuredResponse in possibleResponses) {
				responseAction = configuredResponse.getAction();
				interval = configuredResponse.getInterval();

				if (! isPreviousResponse(configuredResponse, existingResponses)) {
					//if we find that this response doesn't already exist, use it
					break;
				}
				
				//if we reach here, we will just use the last configured response (repeat last response)
			}
		}
		
		if(responseAction == null) {
            //throw new IllegalArgumentException("No appropriate response was configured for this detection point: " + triggeringDetectionPoint.getId());
            throw new ArgumentException("No appropriate response was configured for this detection point: " + triggeringDetectionPoint.getId());
		}
		
		Response responses = new Response();
		responses.setUser(attack.GetUser());
		responses.setTimestamp(attack.GetTimestamp());
		responses.setAction(responseAction);
		responses.setInterval(interval);
		responses.setDetectionSystemId(attack.GetDetectionSystemId());
		
		return responses;
	}
开发者ID:Borealix,项目名称:AppSensor2.NET,代码行数:60,代码来源:ReferenceAttackAnalysisEngine.cs

示例2: loadMockedDetectionPoints

        //private Collection<DetectionPoint> loadMockedDetectionPoints() {
        private HashSet<DetectionPoint> loadMockedDetectionPoints() {
            //Collection<DetectionPoint> configuredDetectionPoints = new Collection<DetectionPoint>();
            HashSet<DetectionPoint> configuredDetectionPoints = new HashSet<DetectionPoint>();

            Interval minutes5 = new Interval(5, Interval.MINUTES);
            Interval minutes6 = new Interval(6, Interval.MINUTES);
            Interval minutes7 = new Interval(7, Interval.MINUTES);
            Interval minutes8 = new Interval(8, Interval.MINUTES);
            Interval minutes11 = new Interval(11, Interval.MINUTES);
            Interval minutes12 = new Interval(12, Interval.MINUTES);
            Interval minutes13 = new Interval(13, Interval.MINUTES);
            Interval minutes14 = new Interval(14, Interval.MINUTES);
            Interval minutes15 = new Interval(15, Interval.MINUTES);
            Interval minutes31 = new Interval(31, Interval.MINUTES);
            Interval minutes32 = new Interval(32, Interval.MINUTES);
            Interval minutes33 = new Interval(33, Interval.MINUTES);
            Interval minutes34 = new Interval(34, Interval.MINUTES);
            Interval minutes35 = new Interval(35, Interval.MINUTES);

            Threshold events3minutes5 = new Threshold(3, minutes5);
            Threshold events12minutes5 = new Threshold(12, minutes5);
            Threshold events13minutes6 = new Threshold(13, minutes6);
            Threshold events14minutes7 = new Threshold(14, minutes7);
            Threshold events15minutes8 = new Threshold(15, minutes8);

            Response log = new Response();
            log.setAction("log");

            Response logout = new Response();
            logout.setAction("logout");

            Response disableUser = new Response();
            disableUser.setAction("disableUser");

            Response disableComponentForSpecificUser31 = new Response();
            disableComponentForSpecificUser31.setAction("disableComponentForSpecificUser");
            disableComponentForSpecificUser31.setInterval(minutes31);

            Response disableComponentForSpecificUser32 = new Response();
            disableComponentForSpecificUser32.setAction("disableComponentForSpecificUser");
            disableComponentForSpecificUser32.setInterval(minutes32);

            Response disableComponentForSpecificUser33 = new Response();
            disableComponentForSpecificUser33.setAction("disableComponentForSpecificUser");
            disableComponentForSpecificUser33.setInterval(minutes33);

            Response disableComponentForSpecificUser34 = new Response();
            disableComponentForSpecificUser34.setAction("disableComponentForSpecificUser");
            disableComponentForSpecificUser34.setInterval(minutes34);

            Response disableComponentForSpecificUser35 = new Response();
            disableComponentForSpecificUser35.setAction("disableComponentForSpecificUser");
            disableComponentForSpecificUser35.setInterval(minutes35);

            Response disableComponentForAllUsers11 = new Response();
            disableComponentForAllUsers11.setAction("disableComponentForAllUsers");
            disableComponentForAllUsers11.setInterval(minutes11);

            Response disableComponentForAllUsers12 = new Response();
            disableComponentForAllUsers12.setAction("disableComponentForAllUsers");
            disableComponentForAllUsers12.setInterval(minutes12);

            Response disableComponentForAllUsers13 = new Response();
            disableComponentForAllUsers13.setAction("disableComponentForAllUsers");
            disableComponentForAllUsers13.setInterval(minutes13);

            Response disableComponentForAllUsers14 = new Response();
            disableComponentForAllUsers14.setAction("disableComponentForAllUsers");
            disableComponentForAllUsers14.setInterval(minutes14);

            Response disableComponentForAllUsers15 = new Response();
            disableComponentForAllUsers15.setAction("disableComponentForAllUsers");
            disableComponentForAllUsers15.setInterval(minutes15);

            Collection<Response> point1Responses = new Collection<Response>();
            point1Responses.Add(log);
            point1Responses.Add(logout);
            point1Responses.Add(disableUser);
            point1Responses.Add(disableComponentForSpecificUser31);
            point1Responses.Add(disableComponentForAllUsers11);

            DetectionPoint point1 = new DetectionPoint("IE1", events3minutes5, point1Responses);

            Collection<Response> point2Responses = new Collection<Response>();
            point2Responses.Add(log);
            point2Responses.Add(logout);
            point2Responses.Add(disableUser);
            point2Responses.Add(disableComponentForSpecificUser32);
            point2Responses.Add(disableComponentForAllUsers12);

            DetectionPoint point2 = new DetectionPoint("IE2", events12minutes5, point2Responses);

            Collection<Response> point3Responses = new Collection<Response>();
            point3Responses.Add(log);
            point3Responses.Add(logout);
            point3Responses.Add(disableUser);
            point3Responses.Add(disableComponentForSpecificUser33);
            point3Responses.Add(disableComponentForAllUsers13);

//.........这里部分代码省略.........
开发者ID:Borealix,项目名称:AppSensor2.NET,代码行数:101,代码来源:ReferenceStatisticalEventAnalysisEngineTest.cs


注:本文中的Response.setAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。