Sleuth Kit Java Bindings (JNI)  4.11.0
Java bindings for using The Sleuth Kit
HostAddress.java
Go to the documentation of this file.
1 /*
2  * Sleuth Kit Data Model
3  *
4  * Copyright 2021 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.datamodel;
20 
21 import java.util.Objects;
22 
27 public final class HostAddress extends AbstractContent {
28 
29  private final SleuthkitCase sleuthkitCase;
30  private final long id;
31  private final HostAddressType addressType;
32  private final String address;
33 
42  HostAddress(SleuthkitCase skCase, long id, HostAddressType type, String address) {
43  super(skCase, id, address + "(" + type.getName() + ")");
44  this.sleuthkitCase = skCase;
45  this.id = id;
46  this.addressType = type;
47  this.address = address;
48  }
49 
50  @Override
51  public long getId() {
52  return id;
53  }
54 
56  return addressType;
57  }
58 
59  public String getAddress() {
60  return address;
61  }
62 
63  @Override
64  public int hashCode() {
65  int hash = 7;
66  hash = 53 * hash + (int) (this.id ^ (this.id >>> 32));
67  hash = 53 * hash + Objects.hashCode(this.addressType);
68  hash = 53 * hash + Objects.hashCode(this.address);
69  return hash;
70  }
71 
72  @Override
73  public boolean equals(Object obj) {
74  if (this == obj) {
75  return true;
76  }
77  if (obj == null) {
78  return false;
79  }
80  if (getClass() != obj.getClass()) {
81  return false;
82  }
83  final HostAddress other = (HostAddress) obj;
84  if (this.id != other.id) {
85  return false;
86  }
87 
88  if (this.addressType != other.addressType) {
89  return false;
90  }
91 
92  if ((this.address == null) ? (other.address != null) : !this.address.equals(other.address)) {
93  return false;
94  }
95 
96  return true;
97  }
98 
104  @Override
106  return sleuthkitCase;
107  }
108 
109  @Override
110  public int read(byte[] buf, long offset, long len) throws TskCoreException {
111  // No data to read.
112  return 0;
113  }
114 
115  @Override
116  public void close() {
117  // Nothing to close
118  }
119 
120  @Override
121  public long getSize() {
122  return 0;
123  }
124 
125  @Override
126  public <T> T accept(ContentVisitor<T> v) {
127  // TODO
128  throw new UnsupportedOperationException("Not supported yet.");
129  }
130 
131  @Override
132  public <T> T accept(SleuthkitItemVisitor<T> v) {
133  // TODO
134  throw new UnsupportedOperationException("Not supported yet.");
135  }
136 
140  public enum HostAddressType {
141  DNS_AUTO(0, "DNS Auto Detection"), // Used to auto-select the DNS type from HOSTNAME, IPV4, and IPV6 when creating HostAddresses
142  HOSTNAME(1, "Host Name"),
143  IPV4(2, "IPv4"),
144  IPV6(3, "IPv6"),
145  ETHERNET_MAC(4, "Ethernet MAC"),
146  WIFI_MAC(5, "WiFi MAC"),
147  BLUETOOTH_MAC(6, "BlueTooth MAC");
148 
149  private final int id;
150  private final String name;
151 
152  HostAddressType(int id, String name) {
153  this.id = id;
154  this.name = name;
155  }
156 
157  public int getId() {
158  return id;
159  }
160 
161  String getName() {
162  return name;
163  }
164 
165  public static HostAddressType fromID(int typeId) {
166  for (HostAddressType type : HostAddressType.values()) {
167  if (type.ordinal() == typeId) {
168  return type;
169  }
170  }
171  return null;
172  }
173  }
174 }
static HostAddressType fromID(int typeId)
int read(byte[] buf, long offset, long len)

Copyright © 2011-2021 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.