1 /*
2  *
3  * Paros and its related class files.
4  *
5  * Paros is an HTTP/HTTPS proxy for assessing web application security.
6  * Copyright (C) 2003-2006 Chinotec Technologies Company
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the Clarified Artistic License
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * Clarified Artistic License for more details.
16  *
17  * You should have received a copy of the Clarified Artistic License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  */
21 // ZAP: 2012/03/15 Changed the RecordHistory constructor to receive a byte[]
22 //      instead of String in the parameters reqBody and resBody.
23 // ZAP: 2013/03/03 Issue 546: Remove all template Javadoc comments
24 // ZAP: 2013/09/26 Issue 716: ZAP flags its own HTTP responses
25 // ZAP: 2013/11/16 Issue 869: Differentiate proxied requests from (ZAP) user requests
26 // ZAP: 2016/01/26 Fixed findbugs warning (tag field no longer used in history table)
27 // ZAP: 2019/06/01 Normalise line endings.
28 // ZAP: 2019/06/05 Normalise format/style.
29 package org.parosproxy.paros.db;
30 
31 import org.parosproxy.paros.model.HistoryReference;
32 import org.parosproxy.paros.network.HttpMalformedHeaderException;
33 import org.parosproxy.paros.network.HttpMessage;
34 
35 public class RecordHistory {
36 
37     private int historyId = 0;
38     private long sessionId = 0;
39     private int historyType = HistoryReference.TYPE_PROXIED;
40     private HttpMessage httpMessage = null;
41 
RecordHistory()42     public RecordHistory() {
43         httpMessage = new HttpMessage();
44     }
45 
46     // ZAP: Added note to RecordHistory constructor
RecordHistory( int historyId, int historyType, long sessionId, long timeSentMillis, int timeElapsedMillis, String reqHeader, byte[] reqBody, String resHeader, byte[] resBody, String tag, String note, boolean responseFromTargetHost)47     public RecordHistory(
48             int historyId,
49             int historyType,
50             long sessionId,
51             long timeSentMillis,
52             int timeElapsedMillis,
53             String reqHeader,
54             byte[] reqBody,
55             String resHeader,
56             byte[] resBody,
57             String tag,
58             String note,
59             boolean responseFromTargetHost)
60             throws HttpMalformedHeaderException {
61         setHistoryId(historyId);
62         setHistoryType(historyType);
63         setSessionId(sessionId);
64         httpMessage = new HttpMessage(reqHeader, reqBody, resHeader, resBody);
65         httpMessage.setTimeSentMillis(timeSentMillis);
66         httpMessage.setTimeElapsedMillis(timeElapsedMillis);
67         httpMessage.setNote(note);
68         httpMessage.setResponseFromTargetHost(responseFromTargetHost);
69     }
70 
71     /** @return Returns the id. */
getHistoryId()72     public int getHistoryId() {
73         return historyId;
74     }
75     /** @return Returns the historyType. */
getHistoryType()76     public int getHistoryType() {
77         return historyType;
78     }
79 
getHttpMessage()80     public HttpMessage getHttpMessage() {
81         return httpMessage;
82     }
83     /** @param historyId The id to set. */
setHistoryId(int historyId)84     public void setHistoryId(int historyId) {
85         this.historyId = historyId;
86     }
87     /** @param historyType The historyType to set. */
setHistoryType(int historyType)88     public void setHistoryType(int historyType) {
89         this.historyType = historyType;
90     }
91 
92     /** @return Returns the sessionId. */
getSessionId()93     public long getSessionId() {
94         return sessionId;
95     }
96 
97     /** @param sessionId The sessionId to set. */
setSessionId(long sessionId)98     public void setSessionId(long sessionId) {
99         this.sessionId = sessionId;
100     }
101 }
102