コード例 #1
0
	/**
	 * {@inheritDoc}
	 */
	public override Collection<Attack> findAttacks(SearchCriteria criteria) {
		if (criteria == null) {
			throw new ArgumentException("criteria must be non-null");
		}
		
		Collection<Attack> matches = new Collection<Attack>();
		
		User user = criteria.GetUser();
		DetectionPoint detectionPoint = criteria.GetDetectionPoint();
		//Collection<string> detectionSystemIds = criteria.getDetectionSystemIds(); 
        HashSet<string> detectionSystemIds = criteria.getDetectionSystemIds(); 
		DateTime? earliest = DateUtils.fromString(criteria.getEarliest());
		
		foreach (Attack attack in attacks) {
			//check user match if user specified
			bool userMatch = (user != null) ? user.Equals(attack.GetUser()) : true;
			
			//check detection system match if detection systems specified
			bool detectionSystemMatch = (detectionSystemIds != null && detectionSystemIds.Count > 0) ? 
					detectionSystemIds.Contains(attack.GetDetectionSystemId()) : true;
			
			//check detection point match if detection point specified
			bool detectionPointMatch = (detectionPoint != null) ? 
					detectionPoint.getId().Equals(attack.GetDetectionPoint().getId()) : true;
			
			bool earliestMatch = (earliest != null) ? earliest < DateUtils.fromString(attack.GetTimestamp()) : true;
					
					
			if (userMatch && detectionSystemMatch && detectionPointMatch && earliestMatch) {
				matches.Add(attack);
			}
		}
		
		return matches;
	}
コード例 #2
0
        /**
         * {@inheritDoc}
         */
        public override Collection<Response> findResponses(SearchCriteria criteria) {
            if(criteria == null) {
                throw new ArgumentException("criteria must be non-null");
            }

            Collection<Response> matches = new Collection<Response>();

            User user = criteria.GetUser();
            //Collection<string> detectionSystemIds = criteria.getDetectionSystemIds();
            HashSet<string> detectionSystemIds = criteria.getDetectionSystemIds();
            DateTime? earliest = DateUtils.fromString(criteria.getEarliest());

            Collection<Response> responses = loadResponses();

            foreach(Response response in responses) {
                //check user match if user specified
                bool userMatch = (user != null) ? user.Equals(response.GetUser()) : true;

                //check detection system match if detection systems specified
                bool detectionSystemMatch = (detectionSystemIds != null && detectionSystemIds.Count > 0) ?
                        detectionSystemIds.Contains(response.GetDetectionSystemId()) : true;

                bool earliestMatch = (earliest != null) ? earliest < DateUtils.fromString(response.GetTimestamp()) : true;

                if(userMatch && detectionSystemMatch && earliestMatch) {
                    matches.Add(response);
                }
            }

            return matches;
        }