From 9270f86d39e3d5e9922f87a79fe3dbb0928c22b9 Mon Sep 17 00:00:00 2001 From: Madeline Boby Date: Tue, 7 Nov 2023 20:15:55 -0500 Subject: [PATCH 01/11] Add support for bearer tokens (#1) * Add support for bearer tokens * Change authBearerKey to String --- .../java/org/fanout/pubcontrol/PubControl.java | 2 ++ .../org/fanout/pubcontrol/PubControlClient.java | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/fanout/pubcontrol/PubControl.java b/src/main/java/org/fanout/pubcontrol/PubControl.java index 042faf3..a93d386 100644 --- a/src/main/java/org/fanout/pubcontrol/PubControl.java +++ b/src/main/java/org/fanout/pubcontrol/PubControl.java @@ -62,6 +62,8 @@ public void applyConfig(List> config) { Map claims = new HashMap(); claims.put("iss", (String)iss); client.setAuthJwt(claims, (byte[])key); + } else if (key != null) { + client.setAuthBearer(key); } this.clients.add(client); } diff --git a/src/main/java/org/fanout/pubcontrol/PubControlClient.java b/src/main/java/org/fanout/pubcontrol/PubControlClient.java index 053778c..b498591 100644 --- a/src/main/java/org/fanout/pubcontrol/PubControlClient.java +++ b/src/main/java/org/fanout/pubcontrol/PubControlClient.java @@ -37,9 +37,10 @@ public class PubControlClient implements Runnable { private Thread pubWorker; private Deque reqQueue = new LinkedList(); private String authBasicUser; - private String authBasicPass;; + private String authBasicPass; private Map authJwtClaim; private byte[] authJwtKey; + private String authBearerKey; /** * Initialize this class with a URL representing the publishing endpoint. @@ -68,6 +69,15 @@ public void setAuthJwt(Map claims, byte[] key) { this.lock.unlock(); } + /** + * Pass a key to use bearer authentication with the configured endpoint. + */ + public void setAuthBearer(String key) { + this.lock.lock(); + this.authBearerKey = key; + this.lock.unlock(); + } + /** * Publish the item synchronously to the specified channels. */ @@ -176,6 +186,8 @@ else if (this.authJwtClaim != null) { String token = Jwts.builder().setClaims(claims). signWith(SignatureAlgorithm.HS256, decodedKey).compact(); return "Bearer " + token; + } else if (this.authBearerKey != null) { + return "Bearer " + this.authBearerKey; } return null; From 11adb144845f4af00e0c90bd31d6bc8cd8a829e1 Mon Sep 17 00:00:00 2001 From: Madeline Boby Date: Mon, 11 Dec 2023 13:14:07 -0500 Subject: [PATCH 02/11] Add typecast to String --- src/main/java/org/fanout/pubcontrol/PubControl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/fanout/pubcontrol/PubControl.java b/src/main/java/org/fanout/pubcontrol/PubControl.java index a93d386..efb91e7 100644 --- a/src/main/java/org/fanout/pubcontrol/PubControl.java +++ b/src/main/java/org/fanout/pubcontrol/PubControl.java @@ -63,7 +63,7 @@ public void applyConfig(List> config) { claims.put("iss", (String)iss); client.setAuthJwt(claims, (byte[])key); } else if (key != null) { - client.setAuthBearer(key); + client.setAuthBearer((String)key); } this.clients.add(client); } From 1fe8f38fe075296b1460733ce85e9939530fbbf5 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Wed, 24 Jan 2024 00:39:58 +0900 Subject: [PATCH 03/11] Use Base64.getEncoder().encodeToString() instead of DatatypeConverter.printBase64Binary() --- README.md | 3 +-- src/main/java/org/fanout/pubcontrol/PubControlClient.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b01d146..c8e67eb 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,6 @@ Usage ```java import org.fanout.pubcontrol.*; -import javax.xml.bind.DatatypeConverter; import java.util.*; public class PubControlExample { @@ -78,7 +77,7 @@ public class PubControlExample { Map entry = new HashMap(); entry.put("uri", "https://api.fanout.io/realm/"); entry.put("iss", ""); - entry.put("key", DatatypeConverter.parseBase64Binary("")); + entry.put("key", Base64.getDecoder().decode("")); config.add(entry); PubControl pub = new PubControl(config); diff --git a/src/main/java/org/fanout/pubcontrol/PubControlClient.java b/src/main/java/org/fanout/pubcontrol/PubControlClient.java index b498591..04e97ce 100644 --- a/src/main/java/org/fanout/pubcontrol/PubControlClient.java +++ b/src/main/java/org/fanout/pubcontrol/PubControlClient.java @@ -15,7 +15,6 @@ import java.io.*; import java.security.Key; -import javax.xml.bind.DatatypeConverter; import javax.crypto.spec.SecretKeySpec; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.SignatureAlgorithm; @@ -171,7 +170,7 @@ private void queueReq(Object[] req) { private String genAuthHeader() { if (this.authBasicUser != null && this.authBasicPass != null) { try { - return DatatypeConverter.printBase64Binary( + return Base64.getEncoder().encodeToString( (this.authBasicUser + ":" + this.authBasicPass).getBytes("utf-8")); } catch (UnsupportedEncodingException exception) { } From 23bd23d758c44d7e6a9432e15ac87eabb87d83de Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Wed, 24 Jan 2024 00:25:14 +0900 Subject: [PATCH 04/11] v1.0.8 --- CHANGELOG.md | 6 ++ pom.xml | 156 ++++++++++++++++++++++++++++----------------------- 2 files changed, 91 insertions(+), 71 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..67d5923 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +1.0.0 (2015) +- Initial Release +1.0.8 +- add support for bearer tokens diff --git a/pom.xml b/pom.xml index 7836efc..991c764 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.fanout pubcontrol jar - 1.0.7 + 1.0.8 pubcontrol Java EPCP library. https://github.com/fanout/java-pubcontrol @@ -47,30 +47,41 @@ - sonatype-nexus-snapshots - Sonatype Nexus snapshot repository + ossrh https://oss.sonatype.org/content/repositories/snapshots - - sonatype-nexus-staging - Sonatype Nexus release repository - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - org.apache.maven.plugins - maven-release-plugin - 2.2.2 - - -Dgpg.passphrase=${gpg.passphrase} - + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.13 + true + + ossrh + https://oss.sonatype.org/ + true + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 org.apache.maven.plugins maven-enforcer-plugin - 1.4.1 + 3.3.0 enforce-java @@ -87,62 +98,65 @@ + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.1 + + + org.apache.maven.plugins + maven-release-plugin + 3.0.1 + + -Dgpg.keyname=${gpg.keyName} -Dgpg.passphrase=${gpg.passphrase} + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + ${java.home}/bin/javadoc + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + ${gpg.keyName} + ${gpg.passphrase} + + + + sign-artifacts + verify + + sign + + + + - - - release-sign-artifacts - - - performRelease - true - - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - ${gpg.passphrase} - - - - sign-artifacts - verify - - sign - - - - - - - - From 0010f6cab1a9b1d83b0384a9f775c16cabef912c Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Thu, 25 Jan 2024 16:28:03 +0900 Subject: [PATCH 05/11] Document release process --- RELEASING_TO_MAVEN.md | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 RELEASING_TO_MAVEN.md diff --git a/RELEASING_TO_MAVEN.md b/RELEASING_TO_MAVEN.md new file mode 100644 index 0000000..76d5411 --- /dev/null +++ b/RELEASING_TO_MAVEN.md @@ -0,0 +1,89 @@ +## Releasing to Maven Central + +This package is released to Maven Central via +[Sonatype OSSRH](https://central.sonatype.org/publish/publish-guide/) by using Maven with the +`nexus-staging-maven-plugin`. + +This has been tested with OpenJDK 17.0.2 and Maven 3.9.6. + +This is released under the `org.fanout` group ID, which is maintained by Fastly. + +### Credentials + +> NOTE: Sonatype is moving away from Jira soon. + +At the time of this writing, this package is published to Maven Central using +a Sonatype "legacy" Jira account created at https://issues.sonatype.org. +See [Registering Via Legacy](https://central.sonatype.org/register/legacy/) in +The Central Repository docs for details. + +When publishing, OSSRH will share the same email, username, and password as this account. +If you need to update your email, username, or password, [do it in Jira](https://central.sonatype.org/register/legacy/#review-requirements). + +### GPG key + +Publishing requires you to prove your identity using GPG. Create a GPG keypair +for the email associated with your Jira account. See [GPG](https://central.sonatype.org/publish/requirements/gpg/#review-requirements) +in The Central Repository docs for details. + +Once you have published your GPG public key, note its key name and +passphrase. + +### Configure Maven + +> TODO: This currently uses username and password, but in the future +> Sonatype is moving to requiring tokens for publishing. + +You will need to add your credentials to `~/.m2/settings.xml`: +```xml + + + + ossrh + *USERNAME* + *PASSWORD* + + + + + ossrh + + true + + + *KEYNAME* + *PASSPHRASE* + + + + +``` + +Increment the pom.xml tag to the version to release. + +After doing so, you should be able to release to Maven using the commands +```shell script +mvn clean deploy +``` + +If everything succeeds, you'll see a message such as: + +``` +[INFO] Remote staging repositories are being released... + +Waiting for operation to complete... +...... + +[INFO] Remote staging repositories released. +[INFO] ------------------------------------------------------------------------ +[INFO] BUILD SUCCESS +[INFO] ------------------------------------------------------------------------ +[INFO] Total time: 02:41 min +[INFO] Finished at: 2024-01-24T01:47:13+09:00 +[INFO] ------------------------------------------------------------------------ +``` + +### Wrap up + +Commit the pom.xml (with the updated version number), +and then add a tag and push to GitHub. From a283575cff1a0248bc951caaed40ed08f563f593 Mon Sep 17 00:00:00 2001 From: Justin Karneges Date: Tue, 14 Oct 2025 08:11:21 -0700 Subject: [PATCH 06/11] update version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c8e67eb..ab4d020 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Maven: org.fanout pubcontrol - 1.0.7 + 1.0.8 ``` From 17f388a19497177b56b4a4b906781d5f2c4c2590 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Tue, 21 Oct 2025 16:23:19 +0900 Subject: [PATCH 07/11] Update README examples for Fastly Fanout --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ab4d020..c9b477c 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,9 @@ public class PubControlExample { // Initialize PubControl with a single endpoint: List> config = new ArrayList>(); Map entry = new HashMap(); - entry.put("uri", "https://api.fanout.io/realm/"); - entry.put("iss", ""); - entry.put("key", Base64.getDecoder().decode("")); + entry.put("uri", "https://api.fastly.com/service/"); + // The API token needs to have purge permission + entry.put("key", ""); config.add(entry); PubControl pub = new PubControl(config); @@ -95,7 +95,7 @@ public class PubControlExample { pub.removeAllClients(); // Explicitly add an endpoint as a PubControlClient instance: - PubControlClient pubClient = new PubControlClient(""); // Optionally set JWT auth: pubClient.setAuthJwt(, '') // Optionally set basic auth: pubClient.setAuthBasic('', '') pub.addClient(pubClient); From 6e0747fc72c7175d080d990674a4763ed2e25adb Mon Sep 17 00:00:00 2001 From: "Kaushik, Udit" Date: Tue, 16 Dec 2025 19:04:53 -0800 Subject: [PATCH 08/11] fanout byte change --- src/main/java/org/fanout/pubcontrol/PubControlClient.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/fanout/pubcontrol/PubControlClient.java b/src/main/java/org/fanout/pubcontrol/PubControlClient.java index 04e97ce..c8281a9 100644 --- a/src/main/java/org/fanout/pubcontrol/PubControlClient.java +++ b/src/main/java/org/fanout/pubcontrol/PubControlClient.java @@ -7,6 +7,7 @@ package org.fanout.pubcontrol; +import java.nio.charset.StandardCharsets; import java.util.concurrent.locks.*; import java.util.*; import java.io.UnsupportedEncodingException; @@ -251,6 +252,7 @@ private void makeHttpRequest(URL url, String authHeader, URLConnection connection = null; int responseCode = 0; StringBuilder response = new StringBuilder(); + byte[] body = jsonContent.getBytes(StandardCharsets.UTF_8); try { connection = url.openConnection(); if (connection instanceof HttpURLConnection) @@ -262,13 +264,15 @@ private void makeHttpRequest(URL url, String authHeader, connection.setRequestProperty("Content-Type", "application/json"); connection.setRequestProperty("Content-Length", - Integer.toString(jsonContent.getBytes().length)); + Integer.toString(body.length)); connection.setUseCaches(false); connection.setDoOutput(true); + DataOutputStream dataOutputStream = new DataOutputStream ( connection.getOutputStream()); - dataOutputStream.writeBytes(jsonContent); + dataOutputStream.write(body); dataOutputStream.close(); + InputStream inputStream = connection.getInputStream(); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream)); From 5228b42e86b9d5a62f5903e94b47018665b70404 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Fri, 19 Dec 2025 02:03:28 +0900 Subject: [PATCH 09/11] Prepare for Maven Central Repository --- .gitignore | 1 + .mvn/maven.config | 1 + .mvn/settings.example.xml | 24 +++++++++ RELEASING_TO_MAVEN.md | 101 +++++++++++++++++--------------------- pom.xml | 36 ++++---------- 5 files changed, 80 insertions(+), 83 deletions(-) create mode 100644 .mvn/maven.config create mode 100644 .mvn/settings.example.xml diff --git a/.gitignore b/.gitignore index d8b1d16..f86140d 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ release.properties dependency-reduced-pom.xml buildNumber.properties .mvn/timing.properties +.mvn/settings.xml diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..ba42136 --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1 @@ +-s.mvn/settings.xml diff --git a/.mvn/settings.example.xml b/.mvn/settings.example.xml new file mode 100644 index 0000000..747ace6 --- /dev/null +++ b/.mvn/settings.example.xml @@ -0,0 +1,24 @@ + + + + + + central + *** + *** + + + + + central + + true + + + + *** + *** + + + + diff --git a/RELEASING_TO_MAVEN.md b/RELEASING_TO_MAVEN.md index 76d5411..8541bad 100644 --- a/RELEASING_TO_MAVEN.md +++ b/RELEASING_TO_MAVEN.md @@ -1,89 +1,76 @@ -## Releasing to Maven Central +## Releasing to Maven Central Repository -This package is released to Maven Central via -[Sonatype OSSRH](https://central.sonatype.org/publish/publish-guide/) by using Maven with the -`nexus-staging-maven-plugin`. +This package is released to Maven Central Repository by using Maven with the `central-publishing-maven-plugin`. -This has been tested with OpenJDK 17.0.2 and Maven 3.9.6. +This process has been tested with OpenJDK 17.0.17 and Maven 3.9.12. This is released under the `org.fanout` group ID, which is maintained by Fastly. ### Credentials -> NOTE: Sonatype is moving away from Jira soon. - -At the time of this writing, this package is published to Maven Central using -a Sonatype "legacy" Jira account created at https://issues.sonatype.org. -See [Registering Via Legacy](https://central.sonatype.org/register/legacy/) in -The Central Repository docs for details. - -When publishing, OSSRH will share the same email, username, and password as this account. -If you need to update your email, username, or password, [do it in Jira](https://central.sonatype.org/register/legacy/#review-requirements). +This package is published to Maven Central using a User Token under a Maven Central Repository account. ### GPG key -Publishing requires you to prove your identity using GPG. Create a GPG keypair -for the email associated with your Jira account. See [GPG](https://central.sonatype.org/publish/requirements/gpg/#review-requirements) -in The Central Repository docs for details. +Publishing requires you to prove your identity using GPG. Create a GPG keypair for the email associated with your Maven Central Repository account. -Once you have published your GPG public key, note its key name and -passphrase. +Once you have published your GPG public key, note its key name and passphrase. -### Configure Maven +## Configure Maven -> TODO: This currently uses username and password, but in the future -> Sonatype is moving to requiring tokens for publishing. +You will need copy `./.mvn/settings.example.xml` to `./.mvn/settings.xml`, and fill in the following using the User Token credentials and your GPG keyname and passphrase. Do not commit this file to source control. -You will need to add your credentials to `~/.m2/settings.xml`: ```xml - ossrh - *USERNAME* - *PASSWORD* + central + + **USERNAME** + **PASSWORD** - ossrh + central true - *KEYNAME* - *PASSPHRASE* + **KEYNAME** + **PASSPHRASE** ``` -Increment the pom.xml tag to the version to release. - -After doing so, you should be able to release to Maven using the commands -```shell script -mvn clean deploy -``` - -If everything succeeds, you'll see a message such as: - -``` -[INFO] Remote staging repositories are being released... - -Waiting for operation to complete... -...... - -[INFO] Remote staging repositories released. -[INFO] ------------------------------------------------------------------------ -[INFO] BUILD SUCCESS -[INFO] ------------------------------------------------------------------------ -[INFO] Total time: 02:41 min -[INFO] Finished at: 2024-01-24T01:47:13+09:00 -[INFO] ------------------------------------------------------------------------ -``` - -### Wrap up - -Commit the pom.xml (with the updated version number), -and then add a tag and push to GitHub. +## Release + +The following steps should be taken on each release. + +1. Update docs + version + - Update `README.md` / `CHANGELOG.md` + - Bump `` in `pom.xml` + - Commit (replace 1.0.0 below with the version you're releasing) + ```shell + git commit -m "Release 1.0.0" + ``` +2. Tag the release + - Create a tag + ```shell + git tag v1.0.0 + ``` +3. Push commit + tag + ```shell + git push + git push --tags + ``` +4. Validate that tests pass, everything builds, sources/javadoc are valid, and GPG signing works. + ```shell + mvn clean verify + ``` +5. Release to Maven using the commands: + ```shell + mvn clean deploy + ``` diff --git a/pom.xml b/pom.xml index 991c764..4164262 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,10 @@ scm:git:git@github.com:fanout/java-pubcontrol.git git@github.com:fanout/java-pubcontrol.git + + UTF-8 + UTF-8 + Konstantin Bokarius @@ -45,23 +49,15 @@ 2.3.1 - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.13 + org.sonatype.central + central-publishing-maven-plugin + 0.9.0 true - ossrh - https://oss.sonatype.org/ - true + central @@ -91,29 +87,17 @@ - 1.6.0 + [1.8,) - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.1 - - - org.apache.maven.plugins - maven-release-plugin - 3.0.1 - - -Dgpg.keyname=${gpg.keyName} -Dgpg.passphrase=${gpg.passphrase} - - org.apache.maven.plugins maven-source-plugin + 3.4.0 attach-sources From 7a1bd37f92603fbdec20d1bc292dce4b4f2c5a41 Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Fri, 19 Dec 2025 02:03:46 +0900 Subject: [PATCH 10/11] v1.0.9 --- CHANGELOG.md | 2 ++ README.md | 2 +- pom.xml | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67d5923..1c8099f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,5 @@ - Initial Release 1.0.8 - add support for bearer tokens +1.0.9 +- fanout byte change diff --git a/README.md b/README.md index c9b477c..5225e55 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Maven: org.fanout pubcontrol - 1.0.8 + 1.0.9 ``` diff --git a/pom.xml b/pom.xml index 4164262..9bc9d2f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ org.fanout pubcontrol jar - 1.0.8 + 1.0.9 pubcontrol Java EPCP library. https://github.com/fanout/java-pubcontrol From df077fe54aa6c2972b2436c9e43091623df97a6a Mon Sep 17 00:00:00 2001 From: Katsuyuki Omuro Date: Fri, 19 Dec 2025 02:20:42 +0900 Subject: [PATCH 11/11] Additional updates to release process --- RELEASING_TO_MAVEN.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/RELEASING_TO_MAVEN.md b/RELEASING_TO_MAVEN.md index 8541bad..9af6ee7 100644 --- a/RELEASING_TO_MAVEN.md +++ b/RELEASING_TO_MAVEN.md @@ -74,3 +74,8 @@ The following steps should be taken on each release. ```shell mvn clean deploy ``` +6. Complete publishing. + - Visit https://central.sonatype.com/publishing/deployments. You should see: + - Deployment ID, matching the deployment ID in the output above + - Status: Validated + - Click the **Publish** button.