NetworkRecord.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. package de.tudarmstadt.informatik.hostage.logging;
  2. import java.io.Serializable;
  3. import android.os.Parcel;
  4. import android.os.Parcelable;
  5. /**
  6. * Holds all necessary information about a single network.
  7. */
  8. public class NetworkRecord implements Parcelable, Serializable {
  9. private static final long serialVersionUID = -1586629159904177836L;
  10. private String bssid;
  11. private String ssid;
  12. private long timestampLocation;
  13. private double latitude;
  14. private double longitude;
  15. private float accuracy;
  16. public static final Parcelable.Creator<NetworkRecord> CREATOR = new Parcelable.Creator<NetworkRecord>() {
  17. @Override
  18. public NetworkRecord createFromParcel(Parcel source) {
  19. return new NetworkRecord(source);
  20. }
  21. @Override
  22. public NetworkRecord[] newArray(int size) {
  23. return new NetworkRecord[size];
  24. }
  25. };
  26. public NetworkRecord() {
  27. }
  28. public NetworkRecord(Parcel source) {
  29. super();
  30. this.bssid = source.readString();
  31. this.ssid = source.readString();
  32. this.timestampLocation = source.readLong();
  33. this.latitude = source.readDouble();
  34. this.longitude = source.readDouble();
  35. this.accuracy = source.readFloat();
  36. }
  37. @Override
  38. public int describeContents() {
  39. return 0;
  40. }
  41. @Override
  42. public void writeToParcel(Parcel dest, int flags) {
  43. dest.writeString(bssid);
  44. dest.writeString(ssid);
  45. dest.writeLong(timestampLocation);
  46. dest.writeDouble(latitude);
  47. dest.writeDouble(longitude);
  48. dest.writeFloat(accuracy);
  49. }
  50. /**
  51. * @return the bssid
  52. */
  53. public String getBssid() {
  54. return bssid;
  55. }
  56. /**
  57. * @param bssid
  58. * the bssid to set
  59. */
  60. public void setBssid(String bssid) {
  61. this.bssid = bssid;
  62. }
  63. /**
  64. * @return the ssid
  65. */
  66. public String getSsid() {
  67. return ssid;
  68. }
  69. /**
  70. * @param ssid
  71. * the ssid to set
  72. */
  73. public void setSsid(String ssid) {
  74. this.ssid = ssid;
  75. }
  76. /**
  77. * @return the timestampLocation
  78. */
  79. public long getTimestampLocation() {
  80. return timestampLocation;
  81. }
  82. /**
  83. * @param timestampLocation
  84. * the timestampLocation to set
  85. */
  86. public void setTimestampLocation(long timestampLocation) {
  87. this.timestampLocation = timestampLocation;
  88. }
  89. /**
  90. * @return the latitude
  91. */
  92. public double getLatitude() {
  93. return latitude;
  94. }
  95. /**
  96. * @param latitude
  97. * the latitude to set
  98. */
  99. public void setLatitude(double latitude) {
  100. this.latitude = latitude;
  101. }
  102. /**
  103. * @return the longitude
  104. */
  105. public double getLongitude() {
  106. return longitude;
  107. }
  108. /**
  109. * @param longitude
  110. * the longitude to set
  111. */
  112. public void setLongitude(double longitude) {
  113. this.longitude = longitude;
  114. }
  115. /**
  116. * @return the accuracy
  117. */
  118. public float getAccuracy() {
  119. return accuracy;
  120. }
  121. /**
  122. * @param accuracy
  123. * the accuracy to set
  124. */
  125. public void setAccuracy(float accuracy) {
  126. this.accuracy = accuracy;
  127. }
  128. public String toJSON() {
  129. return String.format("{\"bssid\":\"%s\",\"ssid\":%s,\"latitude\":%s,\"longitude\":%s,\"timestamp\":%s,\"attacks\":%d,\"portscans\":%d}", bssid, ssid,
  130. latitude, longitude, timestampLocation, -1, -1);
  131. }
  132. @Override
  133. public String toString() {
  134. return "NetworkRecord{" +
  135. "bssid='" + bssid + '\'' +
  136. ", ssid='" + ssid + '\'' +
  137. ", timestampLocation=" + timestampLocation +
  138. ", latitude=" + latitude +
  139. ", longitude=" + longitude +
  140. ", accuracy=" + accuracy +
  141. '}';
  142. }
  143. }