Skip to content

Bring SafeguardJava up to date with the modern Java ecosystem, improve testing, and add missing functionality found in SafeguardDotNet.#140

Open
petrsnd wants to merge 22 commits intoOneIdentity:masterfrom
petrsnd:feature/petrsnd/update-to-current
Open

Bring SafeguardJava up to date with the modern Java ecosystem, improve testing, and add missing functionality found in SafeguardDotNet.#140
petrsnd wants to merge 22 commits intoOneIdentity:masterfrom
petrsnd:feature/petrsnd/update-to-current

Conversation

@petrsnd
Copy link
Copy Markdown
Member

@petrsnd petrsnd commented Mar 29, 2026

Highlights

  • Dependency updates — Migrated from Apache HttpClient 4 to HttpClient 5, updated SignalR, Jackson, Gson, and all other dependencies to current versions
  • PKCE authentication — Added PKCE support to PasswordAuthenticator for environments where Resource Owner Grant is disabled
  • SLF4J logging — Replaced java.util.logging with SLF4J facade across all SDK sources
  • SpotBugs static analysis — Added SpotBugs to the build and fixed all 48 findings (resource leaks, unsafe random, dead code, dispose pattern)
  • REST client bug fix — Fixed URI encoding for query parameters with spaces/quotes (e.g. OData filter expressions)
  • Streaming support — Fixed streaming upload/download and added progress callback support
  • Request timeouts — Added configurable request timeout with sensible defaults
  • Code quality — Added .editorconfig with LF enforcement, normalized line endings, trimmed trailing whitespace
  • Build system — Updated Maven plugins, added editorconfig-maven-plugin, configured for Maven Central publishing via Sonatype
  • Integration test framework — PowerShell-based test runner with 9 suites and 51 tests covering auth, API invocation, token management, streaming, SPS, and negative cases
  • SDK samples — Four standalone example projects (password, certificate, A2A, event listener)
  • AGENTS.md — Enable AI to work better in this repo

petrsnd and others added 22 commits March 17, 2026 12:41
Add .editorconfig enforcing UTF-8, LF line endings, 4-space indentation,
trim trailing whitespace, and final newline. Add editorconfig-maven-plugin
0.2.0 to verify phase to enforce these rules during builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add .gitattributes to enforce LF line endings in the repository.
Normalize all existing files: CRLF to LF, trim trailing whitespace,
ensure final newline. This is a formatting-only change with no
functional modifications.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement OAuth2 PKCE (Proof Key for Code Exchange) authentication flow
to achieve feature parity with SafeguardDotNet. This enables authentication
against Safeguard appliances where the resource owner password grant type
has been disabled.

SDK changes:
- Add PkceAuthenticator implementing the 6-step rSTS LoginController flow
  (init, primary auth, secondary auth/MFA, generate claims, extract code,
  exchange token)
- Add AgentBasedLoginUtils with PKCE helpers (code verifier, code challenge,
  CSRF token generation, authorization code exchange, login response)
- Add Safeguard.connectPkce() factory methods (3 overloads supporting
  ignoreSsl, HostnameVerifier callback, and optional MFA password)

Test tool changes:
- Add --pkce flag for PKCE authentication in the CLI test tool
- Add -R/--resource-owner flag to enable/disable the `Allowed OAuth2 Grant
  Types` setting via PKCE, matching SafeguardDotNet's pattern
- Fix test tool dependency version (7.5.0 -> 8.2.0)

Test framework changes:
- Add preflight check that detects whether resource owner password grant is
  enabled, enables it via PKCE if needed, and restores the original setting
  after all tests complete
- Add Suite-PkceAuth with 5 tests exercising PKCE authentication in
  isolation (Me endpoint, token lifetime, token retrieval, token reuse,
  Settings read)
- Add optional -Pkce switch to Invoke-SgJSafeguardApi and
  Invoke-SgJTokenCommand for explicit PKCE usage in individual tests

All 19 tests pass (5 suites) against a Safeguard appliance with resource
owner password grant disabled by default.
Migrate 16 files from JUL to SLF4J. Level mapping: FINEST->trace,
FINE->debug, INFO->info, WARNING->warn, SEVERE->error. Fix incorrect
class references in several logger calls. Consumers can now choose
their preferred logging backend via standard SLF4J bindings.
@petrsnd
Copy link
Copy Markdown
Member Author

petrsnd commented Mar 29, 2026

These changes include a fix for #139

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.

1 participant