Update Tink examples to use the newest primitive creation APIs.

PiperOrigin-RevId: 683226204
Change-Id: I186d76bf74ade3406c2793bab03d681e23114042
diff --git a/examples/jwt/BUILD.bazel b/examples/jwt/BUILD.bazel
index fe06f8e..0bcfc20 100644
--- a/examples/jwt/BUILD.bazel
+++ b/examples/jwt/BUILD.bazel
@@ -13,6 +13,7 @@
     deps = [
         "@tink_java//src/main/java/com/google/crypto/tink:insecure_secret_key_access",
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
         "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
         "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_public_key_sign",
         "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_signature_config",
@@ -39,6 +40,7 @@
     main_class = "jwt.JwtVerify",
     deps = [
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
         "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwk_set_converter",
         "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_public_key_verify",
         "@tink_java//src/main/java/com/google/crypto/tink/jwt:jwt_signature_config",
diff --git a/examples/jwt/JwtSign.java b/examples/jwt/JwtSign.java
index 6183c5a..4153cbe 100644
--- a/examples/jwt/JwtSign.java
+++ b/examples/jwt/JwtSign.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.InsecureSecretKeyAccess;
 import com.google.crypto.tink.KeysetHandle;
+import com.google.crypto.tink.RegistryConfiguration;
 import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
 import com.google.crypto.tink.jwt.JwtPublicKeySign;
 import com.google.crypto.tink.jwt.JwtSignatureConfig;
@@ -43,8 +44,7 @@
   public static void main(String[] args) throws Exception {
     if (args.length != 3) {
       System.err.printf("Expected 3 parameters, got %d\n", args.length);
-      System.err.println(
-          "Usage: java JwtSign private-keyset-file audience token-file");
+      System.err.println("Usage: java JwtSign private-keyset-file audience token-file");
       System.exit(1);
     }
 
@@ -62,7 +62,8 @@
             InsecureSecretKeyAccess.get());
 
     // Get the primitive.
-    JwtPublicKeySign signer = privateKeysetHandle.getPrimitive(JwtPublicKeySign.class);
+    JwtPublicKeySign signer =
+        privateKeysetHandle.getPrimitive(RegistryConfiguration.get(), JwtPublicKeySign.class);
 
     // Use the primitive to sign a token that expires in 100 seconds.
     RawJwt rawJwt =
diff --git a/examples/jwt/JwtVerify.java b/examples/jwt/JwtVerify.java
index 4c8d790..d4f9414 100644
--- a/examples/jwt/JwtVerify.java
+++ b/examples/jwt/JwtVerify.java
@@ -17,6 +17,7 @@
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 import com.google.crypto.tink.KeysetHandle;
+import com.google.crypto.tink.RegistryConfiguration;
 import com.google.crypto.tink.jwt.JwkSetConverter;
 import com.google.crypto.tink.jwt.JwtPublicKeyVerify;
 import com.google.crypto.tink.jwt.JwtSignatureConfig;
@@ -68,7 +69,8 @@
     String signedToken = lines.get(0).trim();
 
     // Get the primitive.
-    JwtPublicKeyVerify verifier = publicKeysetHandle.getPrimitive(JwtPublicKeyVerify.class);
+    JwtPublicKeyVerify verifier =
+        publicKeysetHandle.getPrimitive(RegistryConfiguration.get(), JwtPublicKeyVerify.class);
 
     // Use the primitive to verify a token.
     JwtValidator validator = JwtValidator.newBuilder().expectAudience(audience).build();
diff --git a/examples/mac/BUILD.bazel b/examples/mac/BUILD.bazel
index 7d0b60a..68013b4 100644
--- a/examples/mac/BUILD.bazel
+++ b/examples/mac/BUILD.bazel
@@ -13,6 +13,7 @@
         "@tink_java//src/main/java/com/google/crypto/tink:insecure_secret_key_access",
         "@tink_java//src/main/java/com/google/crypto/tink:mac",
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
         "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
         "@tink_java//src/main/java/com/google/crypto/tink/mac:mac_config",
     ],
diff --git a/examples/mac/MacExample.java b/examples/mac/MacExample.java
index 6ab407c..5218107 100644
--- a/examples/mac/MacExample.java
+++ b/examples/mac/MacExample.java
@@ -19,6 +19,7 @@
 import com.google.crypto.tink.InsecureSecretKeyAccess;
 import com.google.crypto.tink.KeysetHandle;
 import com.google.crypto.tink.Mac;
+import com.google.crypto.tink.RegistryConfiguration;
 import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
 import com.google.crypto.tink.mac.MacConfig;
 import java.nio.file.Files;
@@ -63,7 +64,7 @@
             new String(Files.readAllBytes(keyFile), UTF_8), InsecureSecretKeyAccess.get());
 
     // Get the primitive.
-    Mac macPrimitive = handle.getPrimitive(Mac.class);
+    Mac macPrimitive = handle.getPrimitive(RegistryConfiguration.get(), Mac.class);
 
     if (mode.equals("compute")) {
       byte[] macTag = macPrimitive.computeMac(msg);
diff --git a/examples/signature/BUILD.bazel b/examples/signature/BUILD.bazel
index 7e03f04..f69dd02 100644
--- a/examples/signature/BUILD.bazel
+++ b/examples/signature/BUILD.bazel
@@ -16,6 +16,7 @@
         "@tink_java//src/main/java/com/google/crypto/tink:public_key_sign",
         "@tink_java//src/main/java/com/google/crypto/tink:public_key_verify",
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
         "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
         "@tink_java//src/main/java/com/google/crypto/tink/signature:signature_config",
     ],
diff --git a/examples/signature/SignatureExample.java b/examples/signature/SignatureExample.java
index a0937ea..b9668b9 100644
--- a/examples/signature/SignatureExample.java
+++ b/examples/signature/SignatureExample.java
@@ -20,6 +20,7 @@
 import com.google.crypto.tink.KeysetHandle;
 import com.google.crypto.tink.PublicKeySign;
 import com.google.crypto.tink.PublicKeyVerify;
+import com.google.crypto.tink.RegistryConfiguration;
 import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
 import com.google.crypto.tink.signature.SignatureConfig;
 import java.nio.file.Files;
@@ -67,7 +68,7 @@
 
     if (mode.equals("sign")) {
       // Get the primitive.
-      PublicKeySign signer = handle.getPrimitive(PublicKeySign.class);
+      PublicKeySign signer = handle.getPrimitive(RegistryConfiguration.get(), PublicKeySign.class);
 
       // Use the primitive to sign data.
       byte[] signature = signer.sign(msg);
@@ -76,7 +77,8 @@
       byte[] signature = Files.readAllBytes(signatureFile);
 
       // Get the primitive.
-      PublicKeyVerify verifier = handle.getPrimitive(PublicKeyVerify.class);
+      PublicKeyVerify verifier =
+          handle.getPrimitive(RegistryConfiguration.get(), PublicKeyVerify.class);
 
       verifier.verify(signature, msg);
     }
diff --git a/examples/streamingaead/BUILD.bazel b/examples/streamingaead/BUILD.bazel
index 78a2bad..2c9afb6 100644
--- a/examples/streamingaead/BUILD.bazel
+++ b/examples/streamingaead/BUILD.bazel
@@ -13,6 +13,7 @@
     deps = [
         "@tink_java//src/main/java/com/google/crypto/tink:insecure_secret_key_access",
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
         "@tink_java//src/main/java/com/google/crypto/tink:streaming_aead",
         "@tink_java//src/main/java/com/google/crypto/tink:tink_json_proto_keyset_format",
         "@tink_java//src/main/java/com/google/crypto/tink/streamingaead:streaming_aead_config",
diff --git a/examples/streamingaead/StreamingAeadExample.java b/examples/streamingaead/StreamingAeadExample.java
index ac2d32d..a20a4f4 100644
--- a/examples/streamingaead/StreamingAeadExample.java
+++ b/examples/streamingaead/StreamingAeadExample.java
@@ -18,6 +18,7 @@
 
 import com.google.crypto.tink.InsecureSecretKeyAccess;
 import com.google.crypto.tink.KeysetHandle;
+import com.google.crypto.tink.RegistryConfiguration;
 import com.google.crypto.tink.StreamingAead;
 import com.google.crypto.tink.TinkJsonProtoKeysetFormat;
 import com.google.crypto.tink.streamingaead.StreamingAeadConfig;
@@ -77,7 +78,8 @@
             new String(Files.readAllBytes(keyFile), UTF_8), InsecureSecretKeyAccess.get());
 
     // Get the primitive
-    StreamingAead streamingAead = handle.getPrimitive(StreamingAead.class);
+    StreamingAead streamingAead =
+        handle.getPrimitive(RegistryConfiguration.get(), StreamingAead.class);
 
     // Use the primitive to encrypt/decrypt files
     if (MODE_ENCRYPT.equals(mode)) {
diff --git a/examples/walkthrough/src/main/java/walkthrough/BUILD.bazel b/examples/walkthrough/src/main/java/walkthrough/BUILD.bazel
index 48f1f71..d65d516 100644
--- a/examples/walkthrough/src/main/java/walkthrough/BUILD.bazel
+++ b/examples/walkthrough/src/main/java/walkthrough/BUILD.bazel
@@ -18,6 +18,7 @@
     deps = [
         "@tink_java//src/main/java/com/google/crypto/tink:aead",
         "@tink_java//src/main/java/com/google/crypto/tink:registry_cluster",
+        "@tink_java//src/main/java/com/google/crypto/tink:registry_configuration",
     ],
 )
 
diff --git a/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java b/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java
index 4084d1d..64fe038 100644
--- a/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java
+++ b/examples/walkthrough/src/main/java/walkthrough/ObtainAndUseAeadPrimitiveExample.java
@@ -16,6 +16,7 @@
 // [START tink_walkthrough_obtain_and_use_aead_primitive]
 import com.google.crypto.tink.Aead;
 import com.google.crypto.tink.KeysetHandle;
+import com.google.crypto.tink.RegistryConfiguration;
 import java.security.GeneralSecurityException;
 
 // [START_EXCLUDE]
@@ -41,7 +42,7 @@
   static byte[] aeadEncryptDecrypt(
       KeysetHandle keysetHandle, byte[] plaintext, byte[] associatedData)
       throws GeneralSecurityException {
-    Aead aead = keysetHandle.getPrimitive(Aead.class);
+    Aead aead = keysetHandle.getPrimitive(RegistryConfiguration.get(), Aead.class);
     byte[] ciphertext = aead.encrypt(plaintext, associatedData);
     return aead.decrypt(ciphertext, associatedData);
   }