Skip to content

Commit 33a4698

Browse files
authored
Merge pull request stleary#1058 from stleary/docs-and-warnings-cleanup
docs-and-warnings-cleanup
2 parents 968a592 + d84fa1a commit 33a4698

5 files changed

Lines changed: 73 additions & 60 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ This project is in the public domain. This means:
4141
We recognize this can create uncertainty for some corporate legal departments accustomed to standard licenses like MIT or Apache 2.0.
4242
If your organization requires a named license for compliance purposes, public domain is functionally equivalent to the Unlicense or CC0 1.0, both of which have been reviewed and accepted by organizations including the Open Source Initiative and Creative Commons. You may reference either when explaining this project's terms to your legal team.
4343

44+
# Signing keys used in releases
45+
46+
The signing keys can be found in [SECURITY.md](https://github.com/stleary/JSON-java/blob/master/docs/SECURITY.md)
4447

4548
# If you would like to contribute to this project
4649

SECURITY.md

Lines changed: 0 additions & 60 deletions
This file was deleted.

docs/SECURITY.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,58 @@
33
## Reporting a Vulnerability
44

55
Please follow the instructions in the ["How are vulnerabilities and exploits handled?"](https://github.com/stleary/JSON-java/wiki/FAQ#how-are-vulnerabilities-and-exploits-handled) section in the FAQ.
6+
7+
## Verifying Release Signatures
8+
9+
All releases of `org.json:json` published to Maven Central are signed with PGP. The fingerprint, keyserver location, and verification procedure below let you confirm that the artifacts you've downloaded were produced by this project and have not been modified in transit.
10+
11+
### Signing Key
12+
13+
| | |
14+
| --- | --- |
15+
| **Fingerprint** | `FB35 C8D0 2B47 24DA DA23 DE0A FD11 6C19 69FC CFF3` |
16+
| **Long key ID** | `FD116C1969FCCFF3` |
17+
| **Keyserver** | `hkps://keyserver.ubuntu.com` |
18+
19+
The full 40-character fingerprint above is the canonical identifier for the key. Always pin or compare against the full fingerprint rather than the long or short key ID.
20+
21+
### Importing the Key
22+
23+
```bash
24+
gpg --keyserver hkps://keyserver.ubuntu.com \
25+
--recv-keys FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3
26+
```
27+
28+
After importing, confirm the fingerprint matches what's published here:
29+
30+
```bash
31+
gpg --fingerprint FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3
32+
```
33+
34+
### Verifying an Artifact
35+
36+
Download both the artifact and its detached signature from Maven Central. For example, for version `20251224`:
37+
38+
```bash
39+
curl -O https://repo1.maven.org/maven2/org/json/json/20251224/json-20251224.jar
40+
curl -O https://repo1.maven.org/maven2/org/json/json/20251224/json-20251224.jar.asc
41+
gpg --verify json-20251224.jar.asc json-20251224.jar
42+
```
43+
44+
A successful verification will report `Good signature from ...` and display the same fingerprint shown above. If GPG reports `BAD signature`, a mismatched fingerprint, or `No public key`, do not use the artifact and please open an issue.
45+
46+
The same procedure applies to the `.pom` and any other signed sidecars in the release directory; substitute the filename you want to verify.
47+
48+
### Gradle Dependency Verification
49+
50+
If you are using Gradle's [dependency verification](https://docs.gradle.org/current/userguide/dependency_verification.html) feature, add an entry like the following to `gradle/verification-metadata.xml`:
51+
52+
```xml
53+
<trusted-key id="FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3" group="org.json" name="json"/>
54+
```
55+
56+
Gradle also accepts the long key ID (`FD116C1969FCCFF3`), but pinning the full fingerprint is recommended.
57+
58+
### Key Rotation
59+
60+
If the signing key is ever rotated or revoked, this document will be updated in the `master` branch with the new fingerprint, and the change will be visible in the file's commit history. Always check this file directly in the repository for the current authoritative value before trusting any third-party copy of the fingerprint.

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,15 @@
198198
<artifactId>maven-jar-plugin</artifactId>
199199
<version>3.3.0</version>
200200
</plugin>
201+
<plugin>
202+
<groupId>org.sonatype.central</groupId>
203+
<artifactId>central-publishing-maven-plugin</artifactId>
204+
<version>0.9.0</version>
205+
<extensions>true</extensions>
206+
<configuration>
207+
<publishingServerId>central</publishingServerId>
208+
</configuration>
209+
</plugin>
201210
</plugins>
202211
</build>
203212
<profiles>

src/main/java/org/json/JSONObject.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,7 @@ private Type[] getMapTypes(Type type) {
33333333
* no-argument constructor, and the field names in the class must match the keys
33343334
* in the JSON string.
33353335
*
3336+
* @param <T> the type of the object to return
33363337
* @param jsonString json in string format
33373338
* @param clazz the class of the object to be returned
33383339
* @return an instance of Object T with fields populated from the JSON string
@@ -3474,7 +3475,12 @@ else if (!rawType.isPrimitive() && !rawType.isEnum() && value instanceof JSONObj
34743475

34753476
/**
34763477
* Converts a String to an Enum value.
3478+
* The unchecked warning is suppressed when casting valueOf() to E
3479+
* @param enumClass enum class
3480+
* @param value value of enum
3481+
* @param <E> type of enum
34773482
*/
3483+
@SuppressWarnings("unchecked")
34783484
private <E> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
34793485
try {
34803486
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)