Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
JLNK.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2012-2019 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.autopsy.coreutils;
20 
21 import java.io.File;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.List;
25 
26 import org.openide.util.NbBundle;
32 
37 public class JLNK {
38 
39  private final int header;
40  private final byte[] linkClassIdentifier;
41  private final List<LinkFlags> linkFlags;
42  private final List<FileAttributesFlags> fileAttributesFlags;
43  private final long crtime;
44  private final long atime;
45  private final long mtime;
46  private final int fileSize;
47  private final int iconIndex;
48  private final int showCommand;
49  private final short hotKey;
50 
51  private final List<String> linkTargetIdList;
52 
54  private final String localBasePath;
55  private final String commonPathSuffix;
56  private final String localBasePathUnicode;
57  private final String commonPathSuffixUnicode;
58 
59  private final String name;
60  private final String relativePath;
61  private final String workingDir;
62  private final String arguments;
63  private final String iconLocation;
64 
65  private final int driveSerialNumber;
66  private final DriveType driveType;
67  private final String volumeLabel;
68 
69  private final List<CommonNetworkRelativeLinkFlags> commonNetworkRelativeListFlags;
71  private final boolean unicodeNetAndDeviceName;
72  private final String netName;
73  private final String netNameUnicode;
74  private final String deviceName;
75  private final String deviceNameUnicode;
76 
77  public JLNK(int header, byte[] linkClassIdentifier, int linkFlags,
78  int fileAttributesFlags, long crtime, long atime,
79  long mtime, int fileSize, int iconIndex, int showCommand, short hotKey,
80  List<String> linkTargetIdList,
81  boolean hasUnicodeLocalBaseAndCommonSuffixOffset,
82  String localBasePath, String commonPathSuffix, String localBasePathUnicode,
83  String commonPathSuffixUnicode, String name, String relativePath,
84  String workingDir, String arguments, String iconLocation, int driveSerialNumber,
85  DriveType driveType, String volumeLabel,
86  int commonNetworkRelativeListFlags,
87  NetworkProviderType networkProviderType, boolean unicodeNetAndDeviceName,
88  String netName, String netNameUnicode, String deviceName,
89  String deviceNameUnicode) {
90  this.header = header;
91  this.linkClassIdentifier = linkClassIdentifier.clone();
92  this.linkFlags = new ArrayList<>();
93  for (LnkEnums.LinkFlags enumVal : LnkEnums.LinkFlags.values()) {
94  if ((linkFlags & enumVal.getFlag()) == enumVal.getFlag()) {
95  this.linkFlags.add(enumVal);
96  }
97  }
98  this.fileAttributesFlags = new ArrayList<>();
99  for (LnkEnums.FileAttributesFlags enumVal : LnkEnums.FileAttributesFlags.values()) {
100  if ((fileAttributesFlags & enumVal.getFlag()) == enumVal.getFlag()) {
101  this.fileAttributesFlags.add(enumVal);
102  }
103  }
104  this.crtime = crtime;
105  this.atime = atime;
106  this.mtime = mtime;
107  this.fileSize = fileSize;
108  this.iconIndex = iconIndex;
109  this.showCommand = showCommand;
110  this.hotKey = hotKey;
111  this.linkTargetIdList = linkTargetIdList;
112  this.hasUnicodeLocalBaseAndCommonSuffixOffset = hasUnicodeLocalBaseAndCommonSuffixOffset;
113  this.localBasePath = localBasePath;
114  this.commonPathSuffix = commonPathSuffix;
115  this.localBasePathUnicode = localBasePathUnicode;
116  this.commonPathSuffixUnicode = commonPathSuffixUnicode;
117  this.name = name;
118  this.relativePath = relativePath;
119  this.workingDir = workingDir;
120  this.arguments = arguments;
121  this.iconLocation = iconLocation;
122  this.driveSerialNumber = driveSerialNumber;
123  this.driveType = driveType;
124  this.volumeLabel = volumeLabel;
125  this.commonNetworkRelativeListFlags = new ArrayList<>();
126  for (LnkEnums.CommonNetworkRelativeLinkFlags enumVal : LnkEnums.CommonNetworkRelativeLinkFlags.values()) {
127  if ((commonNetworkRelativeListFlags & enumVal.getFlag()) == enumVal.getFlag()) {
128  this.commonNetworkRelativeListFlags.add(enumVal);
129  }
130  }
131  this.networkProviderType = networkProviderType;
132  this.unicodeNetAndDeviceName = unicodeNetAndDeviceName;
133  this.netName = netName;
134  this.netNameUnicode = netNameUnicode;
135  this.deviceName = deviceName;
136  this.deviceNameUnicode = deviceNameUnicode;
137  }
138 
139  public String getArguments() {
140  return arguments;
141  }
142 
143  public List<CommonNetworkRelativeLinkFlags> getCommonNetworkRelativeListFlags() {
144  return Collections.unmodifiableList(commonNetworkRelativeListFlags);
145  }
146 
147  public String getCommonPathSuffix() {
148  return commonPathSuffix;
149  }
150 
151  public String getCommonPathSuffixUnicode() {
153  }
154 
155  public long getCrtime() {
156  return crtime;
157  }
158 
159  public long getCtime() {
160  return atime;
161  }
162 
163  public String getDeviceName() {
164  return deviceName;
165  }
166 
167  public String getDeviceNameUnicode() {
168  return deviceNameUnicode;
169  }
170 
171  public int getDriveSerialNumber() {
172  return driveSerialNumber;
173  }
174 
176  return driveType;
177  }
178 
179  public List<FileAttributesFlags> getFileAttributesFlags() {
180  return Collections.unmodifiableList(fileAttributesFlags);
181  }
182 
183  public int getFileSize() {
184  return fileSize;
185  }
186 
189  }
190 
191  public int getHeader() {
192  return header;
193  }
194 
195  public short getHotKey() {
196  return hotKey;
197  }
198 
199  public List<String> getLinkTargetIdList() {
200  return Collections.unmodifiableList(linkTargetIdList);
201  }
202 
203  public int getIconIndex() {
204  return iconIndex;
205  }
206 
207  public String getIconLocation() {
208  return iconLocation;
209  }
210 
211  public byte[] getLinkClassIdentifier() {
212  return linkClassIdentifier.clone();
213  }
214 
215  public List<LinkFlags> getLinkFlags() {
216  return Collections.unmodifiableList(linkFlags);
217  }
218 
219  public String getLocalBasePath() {
220  return localBasePath;
221  }
222 
223  public String getLocalBasePathUnicode() {
224  return localBasePathUnicode;
225  }
226 
227  public long getMtime() {
228  return mtime;
229  }
230 
231  public String getName() {
232  return name;
233  }
234 
235  public String getNetName() {
236  return netName;
237  }
238 
239  public String getNetNameUnicode() {
240  return netNameUnicode;
241  }
242 
244  return networkProviderType;
245  }
246 
247  public String getRelativePath() {
248  return relativePath;
249  }
250 
251  public int getShowCommand() {
252  return showCommand;
253  }
254 
255  public boolean isUnicodeNetAndDeviceName() {
257  }
258 
259  public String getVolumeLabel() {
260  return volumeLabel;
261  }
262 
263  public String getWorkingDir() {
264  return workingDir;
265  }
266 
267  public String getBestPath() {
268  if (localBasePathUnicode != null && !localBasePathUnicode.isEmpty()) {
269  if (commonPathSuffixUnicode != null) {
270  return localBasePathUnicode + commonPathSuffixUnicode;
271  } else if (commonPathSuffix != null) {
272  return localBasePathUnicode + commonPathSuffix;
273  }
274  } else if (localBasePath != null && !localBasePath.isEmpty()) {
275  if (commonPathSuffixUnicode != null) {
276  return localBasePath + commonPathSuffixUnicode;
277  } else if (commonPathSuffix != null) {
278  return localBasePath + commonPathSuffix;
279  }
280  } else if (netNameUnicode != null && !netNameUnicode.isEmpty()) {
281  if (commonPathSuffixUnicode != null && !commonPathSuffixUnicode.isEmpty()) {
282  return netNameUnicode + "\\" + commonPathSuffixUnicode;
283  } else if (commonPathSuffix != null && !commonPathSuffix.isEmpty()) {
284  return netNameUnicode + "\\" + commonPathSuffix;
285  }
286  } else if (netName != null && !netName.isEmpty()) {
287  if (commonPathSuffixUnicode != null && !commonPathSuffixUnicode.isEmpty()) {
288  return netName + "\\" + commonPathSuffixUnicode;
289  } else if (commonPathSuffix != null && !commonPathSuffix.isEmpty()) {
290  return netName + "\\" + commonPathSuffix;
291  }
292  } else if (linkTargetIdList != null && !linkTargetIdList.isEmpty()) {
293  String ret = "";
294  for (String s : linkTargetIdList) {
295  if (s.endsWith("\\")) {
296  ret += s;
297  } else {
298  if (ret.endsWith("\\")) {
299  ret +=s;
300  } else {
301  ret += "\\";
302  ret += s;
303  }
304  }
305  }
306  return ret;
307  }
308  return NbBundle.getMessage(this.getClass(), "JLNK.noPrefPath.text");
309  }
310 
311  public String getBestName() {
312  return new File(getBestPath()).getName(); // not very cross platform :(
313  }
314 
315 }
final String commonPathSuffixUnicode
Definition: JLNK.java:57
boolean isHasUnicodeLocalBaseAndCommonSuffixOffset()
Definition: JLNK.java:187
NetworkProviderType getNetworkProviderType()
Definition: JLNK.java:243
List< String > getLinkTargetIdList()
Definition: JLNK.java:199
JLNK(int header, byte[] linkClassIdentifier, int linkFlags, int fileAttributesFlags, long crtime, long atime, long mtime, int fileSize, int iconIndex, int showCommand, short hotKey, List< String > linkTargetIdList, boolean hasUnicodeLocalBaseAndCommonSuffixOffset, String localBasePath, String commonPathSuffix, String localBasePathUnicode, String commonPathSuffixUnicode, String name, String relativePath, String workingDir, String arguments, String iconLocation, int driveSerialNumber, DriveType driveType, String volumeLabel, int commonNetworkRelativeListFlags, NetworkProviderType networkProviderType, boolean unicodeNetAndDeviceName, String netName, String netNameUnicode, String deviceName, String deviceNameUnicode)
Definition: JLNK.java:77
final List< String > linkTargetIdList
Definition: JLNK.java:51
List< LinkFlags > getLinkFlags()
Definition: JLNK.java:215
List< CommonNetworkRelativeLinkFlags > getCommonNetworkRelativeListFlags()
Definition: JLNK.java:143
final List< CommonNetworkRelativeLinkFlags > commonNetworkRelativeListFlags
Definition: JLNK.java:69
final List< LinkFlags > linkFlags
Definition: JLNK.java:41
final boolean unicodeNetAndDeviceName
Definition: JLNK.java:71
final boolean hasUnicodeLocalBaseAndCommonSuffixOffset
Definition: JLNK.java:53
final NetworkProviderType networkProviderType
Definition: JLNK.java:70
final List< FileAttributesFlags > fileAttributesFlags
Definition: JLNK.java:42
List< FileAttributesFlags > getFileAttributesFlags()
Definition: JLNK.java:179

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.