Anthropic SDK for Java 2.59.0
Last reviewed Sep 24, 2026
Prompt Details
Prompt Composition
2prompts
- Java 25113 lines · 2.8K tokens
- Anthropic SDK for Java 2.59.073 lines · 3.7K tokens
Total186 lines · 6.5K tokens
CWE Coverage
- 20
- 22
- 59
- 78
- 79
- 88
- 89
- 95
- 117
- 190
- 201
- 208
- 209
- 214
- 294
- 295
- 297
- 323
- 327
- 338
- 347
- 362
- 367
- 378
- 427
- 470
- 471
- 494
- 502
- 532
- 611
- 639
- 653
- 681
- 732
- 770
- 772
- 776
- 789
- 807
- 829
- 841
- 862
- 863
- 915
- 916
- 918
- 922
- 942
- 1333
- 1426
- 1427
Prompt Preview
Apply the Java 25 baseline first. The SDK supports Java 8 and later; use these rules for Java 25 applications using Anthropic SDK for Java 2.59.0. Apply the optional tool, Managed Agents, and webhook rules when those surfaces are enabled.
Clients and credentials
- Construct
AnthropicOkHttpClientorAnthropicOkHttpClientAsyncin trusted server code with service credentials scoped to the intended workspace; never put API keys or bearer tokens in Messages, tool arguments, or distributed client applications. - Treat
fromEnv()as credential discovery, not just an API-key lookup: controlanthropic.apiKey,anthropic.authToken, andanthropic.baseUrlsystem properties as well as theirANTHROPIC_*environment counterparts; system properties win. ProtectANTHROPIC_PROFILE,ANTHROPIC_CONFIG_DIR, profile/cache files, and federation token sources because discovery can select credentials from disk or workload identity. - Fix
baseUrl,backend,proxy, and custom transport configuration in deployment policy; allow only approved HTTPS origins, including any changes throughwithOptions(). Do not let request data or model output choose credential destinations or weakensslSocketFactory,trustManager, orhostnameVerifierverification. - Enforce the same destination policy on every redirect through a transport that disables redirects or validates each hop before sending credentials, backed by egress restrictions. The SDK retains OkHttp's redirect defaults; do not assume its handling of
Authorizationprotectsx-api-keyor other custom secret headers.