Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This is a jpa2 implementation of the Implementations of the org.owasp.appsensor.core.listener.ResponseListener interface can register with this class and be notified when new org.owasp.appsensor.core.Responses are added to the data store The implementation stores the org.owasp.appsensor.core.Response in a jpa2 driven DB.

John Melton (
public class Jpa2ResponseStore extends ResponseStore {
	private Logger logger;

maintain a repository to read/write org.owasp.appsensor.core.Events from
	public void addResponse(Response response) {
		.warn("Security response " + response + " triggered for user: " + response.getUser().getUsername());

		if (criteria == null) {
			throw new IllegalArgumentException("criteria must be non-null");
		Collection<Responsematches = new ArrayList<Response>();
		User user = criteria.getUser();
		Collection<StringdetectionSystemIds = criteria.getDetectionSystemIds(); 
		DateTime earliest = DateUtils.fromString(criteria.getEarliest());
		// TODO: instead of findAll every time (inefficient), update this to do actual query
		for (Response response : .findAll()) {
			//check user match if user specified
			boolean userMatch = (user != null) ? user.equals(response.getUser()) : true;
			//check detection system match if detection systems specified
			boolean detectionSystemMatch = (detectionSystemIds != null && detectionSystemIds.size() > 0) ? 
					detectionSystemIds.contains(response.getDetectionSystemId()) : true;
			boolean earliestMatch = (earliest != null) ? earliest.isBefore(DateUtils.fromString(response.getTimestamp())) : true;
			if (userMatch && detectionSystemMatch && earliestMatch) {
		return matches;
New to GrepCode? Check out our FAQ X