Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ This project is in the public domain. This means:
We recognize this can create uncertainty for some corporate legal departments accustomed to standard licenses like MIT or Apache 2.0.
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.

# Signing keys used in releases

The signing keys can be found in [SECURITY.md](https://github.com/stleary/JSON-java/blob/master/docs/SECURITY.md)

# If you would like to contribute to this project

Expand Down
60 changes: 0 additions & 60 deletions SECURITY.md

This file was deleted.

55 changes: 55 additions & 0 deletions docs/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,58 @@
## Reporting a Vulnerability

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.

## Verifying Release Signatures

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.

### Signing Key

| | |
| --- | --- |
| **Fingerprint** | `FB35 C8D0 2B47 24DA DA23 DE0A FD11 6C19 69FC CFF3` |
| **Long key ID** | `FD116C1969FCCFF3` |
| **Keyserver** | `hkps://keyserver.ubuntu.com` |

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.

### Importing the Key

```bash
gpg --keyserver hkps://keyserver.ubuntu.com \
--recv-keys FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3
```

After importing, confirm the fingerprint matches what's published here:

```bash
gpg --fingerprint FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3
```

### Verifying an Artifact

Download both the artifact and its detached signature from Maven Central. For example, for version `20251224`:

```bash
curl -O https://repo1.maven.org/maven2/org/json/json/20251224/json-20251224.jar
curl -O https://repo1.maven.org/maven2/org/json/json/20251224/json-20251224.jar.asc
gpg --verify json-20251224.jar.asc json-20251224.jar
```

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.

The same procedure applies to the `.pom` and any other signed sidecars in the release directory; substitute the filename you want to verify.

### Gradle Dependency Verification

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`:

```xml
<trusted-key id="FB35C8D02B4724DADA23DE0AFD116C1969FCCFF3" group="org.json" name="json"/>
```

Gradle also accepts the long key ID (`FD116C1969FCCFF3`), but pinning the full fingerprint is recommended.

### Key Rotation

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.
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,15 @@
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
</plugin>
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.9.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>central</publishingServerId>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/org/json/JSONObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3333,6 +3333,7 @@ private Type[] getMapTypes(Type type) {
* no-argument constructor, and the field names in the class must match the keys
* in the JSON string.
*
* @param <T> the type of the object to return
* @param jsonString json in string format
* @param clazz the class of the object to be returned
* @return an instance of Object T with fields populated from the JSON string
Expand Down Expand Up @@ -3474,7 +3475,12 @@ else if (!rawType.isPrimitive() && !rawType.isEnum() && value instanceof JSONObj

/**
* Converts a String to an Enum value.
* The unchecked warning is suppressed when casting valueOf() to E
* @param enumClass enum class
* @param value value of enum
* @param <E> type of enum
*/
@SuppressWarnings("unchecked")
private <E> E stringToEnum(Class<?> enumClass, String value) throws JSONException {
try {
@SuppressWarnings("unchecked")
Expand Down
Loading