package de.tudarmstadt.informatik.hostage.logging; import android.os.Parcel; import android.os.Parcelable; import de.tudarmstadt.informatik.hostage.logging.formatter.Formatter; /** * This class defines the attributes of a record.
* A Record is a single message exchanged between the application and an * attacker.
* The class has no own functionality except for getter and setter methods. To * change the logging mechanism you have to to change the logger in * {@link de.tudarmstadt.informatik.hostage.HoneyService HoneyService} and * {@link de.tudarmstadt.informatik.hostage.ui.ViewLog ViewLog} * * @author Mihai Plasoianu * @author Lars Pandikow */ public class Record implements Parcelable { public static enum TYPE { SEND, RECEIVE }; // attack private int id; private long attack_id; private long timestamp; private String protocol; private TYPE type; private String packet; // network private String localIP; private String localHost; private int localPort; private String remoteIP; private String remoteHost; private int remotePort; private String externalIP; private String bssid; private String ssid; // location private long timestampLocation; private double latitude; private double longitude; private float accuracy; public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { @Override public Record createFromParcel(Parcel source) { return new Record(source); } @Override public Record[] newArray(int size) { return new Record[size]; } }; public Record() { } public Record(Parcel source) { // attack this.id = source.readInt(); this.attack_id = source.readLong(); this.timestamp = source.readLong(); this.protocol = source.readString(); this.type = TYPE.valueOf(source.readString()); this.packet = source.readString(); // network this.localIP = source.readString(); this.localHost = source.readString(); this.localPort = source.readInt(); this.remoteIP = source.readString(); this.remoteHost = source.readString(); this.remotePort = source.readInt(); this.externalIP = source.readString(); this.bssid = source.readString(); this.ssid = source.readString(); // location this.timestampLocation = source.readLong(); this.latitude = source.readDouble(); this.longitude = source.readDouble(); this.accuracy = source.readFloat(); } @Override public int describeContents() { return 0; } public float getAccuracy() { return accuracy; } public long getAttack_id() { return attack_id; } public String getBssid() { return bssid; } public String getExternalIP() { return externalIP; } public int getId() { return id; } public double getLatitude() { return latitude; } public String getLocalHost() { return localHost; } public String getLocalIP() { return localIP; } public int getLocalPort() { return localPort; } public double getLongitude() { return longitude; } public String getPacket() { return packet; } public String getProtocol() { return protocol; } public String getRemoteHost() { return remoteHost; } public String getRemoteIP() { return remoteIP; } public int getRemotePort() { return remotePort; } public String getSsid() { return ssid; } public long getTimestamp() { return timestamp; } public long getTimestampLocation() { return timestampLocation; } public TYPE getType() { return type; } public void setAccuracy(float accuracy) { this.accuracy = accuracy; } public void setAttack_id(long attack_id) { this.attack_id = attack_id; } public void setBssid(String bssid) { this.bssid = bssid; } public void setExternalIP(String externalIP) { this.externalIP = externalIP; } public void setId(int id) { this.id = id; } public void setLatitude(double latitude) { this.latitude = latitude; } public void setLocalHost(String localHost) { this.localHost = localHost; } public void setLocalIP(String localIP) { this.localIP = localIP; } public void setLocalPort(int localPort) { this.localPort = localPort; } public void setLongitude(double longitude) { this.longitude = longitude; } public void setPacket(String packet) { this.packet = packet; } public void setProtocol(String protocol) { this.protocol = protocol; } public void setRemoteHost(String remoteHost) { this.remoteHost = remoteHost; } public void setRemoteIP(String remoteIP) { this.remoteIP = remoteIP; } public void setRemotePort(int remotePort) { this.remotePort = remotePort; } public void setSsid(String ssid) { this.ssid = ssid; } public void setTimestamp(long timestamp) { this.timestamp = timestamp; } public void setTimestampLocation(long timestampLocation) { this.timestampLocation = timestampLocation; } public void setType(TYPE type) { this.type = type; } @Override public String toString() { return toString(null); } public String toString(Formatter formatter) { if (null == formatter) { return Formatter.getDefault().format(this); } return formatter.format(this); } @Override public void writeToParcel(Parcel dest, int flags) { // attack dest.writeInt(id); dest.writeLong(attack_id); dest.writeLong(timestamp); dest.writeString(protocol); dest.writeString(type.name()); dest.writeString(packet); // network dest.writeString(localIP); dest.writeString(localHost); dest.writeInt(localPort); dest.writeString(remoteIP); dest.writeString(remoteHost); dest.writeInt(remotePort); dest.writeString(externalIP); dest.writeString(bssid); dest.writeString(ssid); // location dest.writeLong(timestampLocation); dest.writeDouble(latitude); dest.writeDouble(longitude); dest.writeFloat(accuracy); } }