Return a File object representing the pathname to our session persistence file, if any. @param id The ID of the Session to be retrieved. This is used in the file naming.
(String id)
| 339 | * @param id The ID of the Session to be retrieved. This is used in the file naming. |
| 340 | */ |
| 341 | private File file(String id) throws IOException { |
| 342 | File storageDir = directory(); |
| 343 | if (storageDir == null) { |
| 344 | return null; |
| 345 | } |
| 346 | |
| 347 | String filename = id + FILE_EXT; |
| 348 | File file = new File(storageDir, filename); |
| 349 | File canonicalFile = file.getCanonicalFile(); |
| 350 | |
| 351 | // Check the file is within the storage directory |
| 352 | if (!canonicalFile.toPath().startsWith(storageDir.getCanonicalFile().toPath())) { |
| 353 | log.warn(sm.getString("fileStore.invalid", file.getPath(), id)); |
| 354 | return null; |
| 355 | } |
| 356 | |
| 357 | return canonicalFile; |
| 358 | } |
| 359 | } |