Skip to content

IPED BFAC#2836

Open
fmpfeifer wants to merge 32 commits into
sepinf-inc:masterfrom
fmpfeifer:iped-bfac
Open

IPED BFAC#2836
fmpfeifer wants to merge 32 commits into
sepinf-inc:masterfrom
fmpfeifer:iped-bfac

Conversation

@fmpfeifer
Copy link
Copy Markdown
Member

This PR integrates the iped-bfac module into IPED, enabling BFAC submission workflows directly from the application.

At a high level, it adds support for:

  • creating new BFAC submissions from IPED
  • adding files to existing submissions
  • sending file hashes to the backend
  • uploading files to the backend

fmpfeifer and others added 30 commits December 26, 2025 11:28
…file upload

- Create new iped-bfac subproject with Maven configuration
- Implement BfacDialog for user authentication and submission management
- Add BfacApiClient for REST API communication with BFAC backend
  - Login/logout with token management
  - Session validation and renewal
  - Batch hash submission (MD5, SHA-1, SHA-256, ED2K)
  - Segmented file upload with resume support
- Implement SubmissionWorker for background processing
  - Efficient bookmark-based item collection using IPEDSearcher
  - Progress tracking for both hash and file upload phases
- Add BfacConfig for credential storage
- Integrate BFAC menu option in iped-app MenuClass/MenuListener
- Add localization strings for all supported languages
…pload interruption

- Convert BfacDialog to singleton with getInstance() method
- Change dialog from modal to non-modal for better user experience
- Add window closing handler with confirmation when upload is in progress
- Implement showDialog() method to restore and focus existing instance
- Add static confirmApplicationClose() method for application-level checks
- Integrate upload progress check in App.windowClosing() event
…arate files

- Move LoginResult, ValidationResult, SendHashResult, SubmissionResult, and FileUploadStatus from BfacApiClient inner classes to standalone classes in iped.bfac.api package
- Update imports in BfacDialog and SubmissionWorker to reference new class locations
- Improve code organization and maintainability by separating API result types
…ad operations

- Add TOKEN_RENEWAL_INTERVAL_MS constant (12 hours) for periodic token refresh
- Implement renewTokenIfNeeded() method with force parameter for token validation
- Track last token renewal time with lastTokenRenewalTime field
- Force token renewal before starting file upload phase
- Add periodic token renewal check during file segment uploads
- Import LoginResult class for token renewal response handling
…d of dialog itself

- Change showDialog() to restore parent frame state when iconified
…ication exit

- Change setDefaultCloseOperation to DO_NOTHING_ON_CLOSE to ensure window closing handler is always invoked
- Allows proper cleanup and confirmation dialogs (e.g., BFAC upload progress check) before application exit
…ion expiration recovery

- Add onAuthenticationError() callback method to SubmissionCallback interface for handling 401 errors
- Implement authentication error detection in SubmissionWorker with authenticationError flag
- Add HTTP status code tracking to API result classes (SendHashResult, SubmissionResult, FileUploadStatus)
- Add isUnauthorized() helper methods to check for 401 status codes
- Implement session expiration dialog
… naming convention

- Change Maven name from "IPED BFAC Integration" to "iped-bfac" to align with other IPED subprojects
- Add ActionListener to passwordField to trigger login on ENTER key press
- Change uploadFilesCheckBox constructor to initialize with checked state (true)
- Add BFACConfig.txt configuration file with baseUrl property
- Load base URL from config file in BfacConfig class
- Search for config in conf/, ../conf/, and classpath
- Update BfacApiClient to use configured URL from BfacConfig
- Fall back to default localhost:8000 if config not found
- Add USER_AGENT constant with IPED version and extension info
- Create newRequestBuilder() helper for common headers
- Create newAuthenticatedRequestBuilder() for authenticated requests
- Replace all HttpRequest.newBuilder() calls with helper methods
- Ensures consistent User-Agent across all API endpoints
- Change serverUrlField from JTextField to JLabel
- Display configured URL from BfacConfig instead of editable field
- Remove server URL modification logic from onLogin()
- Remove serverUrlField enable/disable calls during login
- Style URL label with monospaced font and dark gray color
- Reorder imports for consistency
- Update default baseUrl from http://10.61.86.217:8000/ to https://10.61.86.217:443/
- Add createHttpClient() method to configure SSL context that trusts all certificates
- Import SSL-related classes (SSLContext, TrustManager, X509TrustManager)
- Add exception handling for SSL configuration failures with fallback to default client
- Replace direct HttpClient.newBuilder() calls with createHttpClient() helper
- Add enableBFACClient property to IPEDConfig.txt with default false
- Create BFACClientConfig class to read enableBFACClient and baseUrl properties
- Move baseUrl configuration from BFACConfig.txt to BFACConfig.txt in conf/
- Update BfacApiClient to read baseUrl from BFACClientConfig instead of BfacConfig
- Remove baseUrl loading logic from BfacConfig class
- Add BFACClientConfig to Configuration manager
- Conditionally show
- Add static block to set jdk.internal.httpclient.disableHostnameVerification property
- Property must be set before HttpClient class is loaded
- Allows connections to HTTPS servers with mismatched hostnames
…C client

- Add maxConcurrentUploads property to BFACConfig.txt with default value of 5
- Create FileUploadResult class to communicate upload task results
- Create FileUploadTask as Callable for parallel file uploads in thread pool
- Refactor SubmissionWorker to use ExecutorService for concurrent uploads
- Add shared atomic counters and flags for progress tracking across threads
- Implement thread-safe callbacks for logging and token
- Add progressCallback parameter to FileUploadTask constructor
- Call progressCallback after uploading each segment in upload loop
- Call progressCallback when skipping already-uploaded files
- Call progressCallback when resuming uploads from startOffset
- Move progress calculation from SubmissionWorker result processing to callback
- Create progressCallback lambda in SubmissionWorker that updates progress bar
- Pass progressCallback to FileUploadTask instances
…cessing

- Replace List<Future<FileUploadResult>> with ExecutorCompletionService
- Submit tasks via completionService.submit() instead of collecting futures
- Track submittedCount to know how many results to collect
- Use completionService.take() to get results in completion order
- Process results as they complete instead of in submission order
Implement batch upload functionality to group multiple small files into a single HTTP request, reducing overhead and improving upload performance. Add getUploadStatusBatch() to query status for multiple files at once and uploadFileSegmentsBatch() to upload segments for multiple files in one multipart request. Modify SubmissionWorker to group eligible small files based on upload status and size limits before submitting individual upload
Add syncCategoryWithSelectedSubmission() to automatically update the category dropdown when selecting an existing submission. This ensures the category matches the selected submission's category when switching between submissions or loading existing submissions. Add action listener to existingSubmissionComboBox to trigger sync on selection changes.
…itialization

Relocate the addActionListener() call for existingSubmissionComboBox to immediately after setting its enabled state. This ensures the listener is attached after all component properties are configured, preventing potential issues with event handling during initialization.
Pass the FileUploadStatus obtained from batch queries directly to FileUploadTask instead of making individual getUploadStatus() calls. Change filesToUpload map to LinkedHashMap to preserve insertion order for consistent batch processing. Add initialStatus parameter to FileUploadTask constructor to accept pre-fetched status, falling back to individual API call only when batch status is unavailable.
Add validation to skip FileHashInfo entries with empty names or non-positive file sizes before processing. Track and report the count of skipped invalid entries to inform users about items excluded from hash submission due to missing or invalid metadata.
@lfcnassif
Copy link
Copy Markdown
Member

Thank you very much @fmpfeifer!

@wladimirleite, since this is related to a task you have been done for more than one decade, when you have available time, could you help reviewing this?

@wladimirleite wladimirleite self-requested a review April 10, 2026 13:21
@wladimirleite
Copy link
Copy Markdown
Member

wladimirleite commented Apr 22, 2026

I used the BFAC client interface to upload two sets of files successfully.
A few minor observations:

  1. The GUI strings are hard coded in english. It is a lot of work, but to keep consistency with the rest of the project, we should use localized strings. As this is an internal feature, not sure if it would make sense to have localized string for all languages...
  2. The refresh button uses an Unicode character. My environment does not use UTF-8 for source code files, so the character was messed up. Maybe using something like "\u27F3" // Refresh character would be better.
  3. Although the current interface to select bookmarks works perfectly, wouldn't it make more sense to use the same one already used in report creation dialog? (use checkboxes instead of selection, and use colored bookmarks icons).
  4. The BFAC client is enabled in IPEDConfig.txt, which is practical, but is mainly used for processing tasks. Not sure if there would be a better place to put this entry.

@wladimirleite
Copy link
Copy Markdown
Member

I am uploading 3 more submissions, each with multiple files.
@fmpfeifer, when you get a chance, can you check if all files were received successfully on the backend?

Another question: what is the expected way to report misclassified files (a.k.a. false positives)?
Would simply submitting them as "Non ASI" be enough?

@wladimirleite
Copy link
Copy Markdown
Member

A few minor suggestions (during the upload):

  • Show time stamps in each log line.
  • Show total elapsed time.
  • Show current bytes uploaded and the to be uploaded.

@fmpfeifer
Copy link
Copy Markdown
Member Author

Thank you for the review, @wladimirleite.
I’ll work on addressing the suggestions this week.

Regarding the false positives, the current approach is to submit the hashes as "Non-ASI". This isn’t ideal, and I agree we should look into a better solution.
Regarding the submissions you sent, I'll check and report back soon. I'm currently out of the office .

Thanks again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants