Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
52052c7
Update CONTRIBUTING.md
siri-varma Apr 29, 2025
8bdb4c2
Bump codecov/codecov-action from 5.4.0 to 5.4.2 (#1318)
dependabot[bot] Apr 22, 2025
0f810e3
Fix URL building logic (#1320)
artur-ciocanu Apr 29, 2025
a551aad
Generate updated javadocs for 1.14.1
dapr-bot Apr 30, 2025
f6660fc
Add Conversation AI to Java SDK (#1235)
siri-varma May 1, 2025
ba9ace6
Add docs for usage of Jobs SDK (#1323)
siri-varma May 6, 2025
1f01d3b
Use dapr/durabletask-java (#1336)
cicoyle May 8, 2025
db54630
Update master version to 1.16.0-SNAPSHOT
dapr-bot May 8, 2025
ec7e09b
Renaming and exposing connection details (#1341)
artur-ciocanu May 13, 2025
1a5af3b
[Master] Fix Vulnerabilities (#1354)
cicoyle May 13, 2025
b9499cc
Feat Add TLS & mTLS support for gRPC with root CA and insecure mode (…
cicoyle May 14, 2025
027ad0a
Fix the issue with retries not happening correctly for Activities and…
siri-varma May 15, 2025
7b7fcf7
1.5.4 (#1375)
cicoyle May 16, 2025
67b15c2
Bump codecov/codecov-action from 5.4.2 to 5.4.3 (#1379)
dependabot[bot] May 19, 2025
bab7d4e
Bump fossas/fossa-action from 1.6.0 to 1.7.0 (#1380)
dependabot[bot] May 19, 2025
58adad1
Fix component spec parsing (#1370)
iddeepak May 19, 2025
80b2a4c
chore: Add grpc keepalives (#1382)
javier-aliaga May 21, 2025
ff42fae
Fix : Typo in code comments (#1381)
iddeepak May 21, 2025
a4519dc
Spring boot workflow patterns examples with mechanical markdown and t…
salaboy May 21, 2025
529300e
System Properties + Env Var Docs (#1384)
cicoyle May 21, 2025
1341785
Updating docs to have spring boot 3.x banner and not hardcoded deps (…
salaboy May 22, 2025
af4c9d1
Cleaup Test Dependencies (#1332)
siri-varma May 23, 2025
8b1b481
chore: New task execution task id test (#1352)
javier-aliaga May 28, 2025
f724e48
Revert "chore: New task execution task id test (#1352)" (#1389)
javier-aliaga May 28, 2025
ea062de
1.5.5 (#1390)
cicoyle May 28, 2025
6902999
Add Documentation for Conversation AI SDK (#1387)
siri-varma May 29, 2025
27dabfc
Cleanup Spring Dependencies (#1334)
siri-varma May 29, 2025
57cd7a2
Bump org.springframework:spring-context in /dapr-spring (#1394)
dependabot[bot] May 29, 2025
3799379
Compensation example for Workflows (#1333)
cicoyle May 29, 2025
9085024
Adding remote endpoint request from inside activity with retry (#1388)
salaboy May 31, 2025
c2e5865
Bump org.springframework:spring-context in /dapr-spring (#1398)
dependabot[bot] Jun 3, 2025
cf08cef
Grouping IT tests per API surface (#1401)
artur-ciocanu Jun 5, 2025
462546f
Ensure OTEL version from examples aligns with SDK and ITs (#1403)
artur-ciocanu Jun 5, 2025
7f550ad
chore: Support configuration for max grpc inbound message (#1411)
javier-aliaga Jun 10, 2025
940e0de
Adding Support for Suspend / Resume Workflows (#1405)
salaboy Jun 11, 2025
3b2aa3a
Add retry handler support (#1412)
TheForbiddenAi Jun 11, 2025
fd3ab78
Pull out createTimer logic (#1419)
cicoyle Jun 11, 2025
cc7c03d
Make sure there no multiple empty lines and every file ends with a ne…
siri-varma Jun 12, 2025
13d49ae
Automated Header Checks (#1416)
siri-varma Jun 12, 2025
5e6624f
Bump org.springframework:spring-web in /dapr-spring (#1424)
dependabot[bot] Jun 16, 2025
f61eb5a
Aligning Spring Boot and SpringFramework versions (#1427)
salaboy Jun 26, 2025
f15e41b
Update pom.xml to have testcontainers 1.21.3 (#1436)
salaboy Jun 30, 2025
03792c5
Adding examples to Spring Boot (duration, zoneddatetime and suspend/r…
salaboy Jul 14, 2025
d51cc71
Bump org.apache.commons:commons-lang3 from 3.9 to 3.18.0 (#1446)
dependabot[bot] Jul 14, 2025
b2c4ddd
Update dapr docs for Hugo upgrade (#1443)
marcduiker Jul 14, 2025
12087e0
Adds note about workflow start time (#1444)
JoshVanL Jul 14, 2025
2412682
Migrate PubSub removing flaky test (#1407)
mcruzdev Jul 14, 2025
e873326
supporting spring boot property for API TOKEN on workflow interceptor…
salaboy Jul 15, 2025
c40b0f8
Supporting placement and scheduler custom images (#1450)
salaboy Jul 15, 2025
081a1b2
chore: Replace ossrh url (#1454)
javier-aliaga Jul 16, 2025
ebc3d1e
Upgrading to 1.15.7 (#1458)
salaboy Jul 18, 2025
0eeba83
updating sched api on DaprContainer (#1462)
salaboy Jul 22, 2025
7e6cfd4
Adding app health check parameters (#1465)
salaboy Jul 23, 2025
0f70a92
Add note about the dapr.client.* properties (#1467)
mcruzdev Jul 23, 2025
ceae87e
docs: Add gRPC response settings to properties documentation (#1482)
MyMirelHub Aug 4, 2025
1d3453a
Generate updated javadocs for 1.14.2
dapr-bot Aug 4, 2025
3a0885e
chore: Use 1.16.0 rc 2 (#1463)
javier-aliaga Aug 4, 2025
f58c779
Add Failure Policy for Jobs SDK (#1448)
siri-varma Aug 5, 2025
1206446
Use 1.16 rc.3 (#1488)
javier-aliaga Aug 11, 2025
d893e52
[master] Unblock Release (#1500)
cicoyle Aug 14, 2025
f553855
Generate updated javadocs for 1.15.0 (#1501)
cicoyle Aug 14, 2025
532adc0
process deps too for dapr-spring (#1503)
cicoyle Aug 15, 2025
3875652
Use camelCase on properties (#1470)
mcruzdev Aug 16, 2025
cd4dada
Update master version to 1.17.0-SNAPSHOT
dapr-bot Aug 18, 2025
5aad35d
fix script (#1506)
cicoyle Aug 18, 2025
487a7e4
add support for custom status (#1505)
salaboy Aug 20, 2025
51a876b
try 1.5.7 (#1487)
cicoyle Aug 21, 2025
1c1149d
rm protoc cmd from pom.xml (#1498)
cicoyle Aug 22, 2025
0e0f442
Generate updated javadocs for 1.15.1
dapr-bot Aug 26, 2025
1a21742
feat: Support registering activities with custom name (#1431)
javier-aliaga Aug 26, 2025
e6f1d79
Bump codecov/codecov-action from 5.4.3 to 5.5.0 (#1513)
dependabot[bot] Aug 26, 2025
876cc5d
commit: Fix validate job (#1524)
javier-aliaga Aug 27, 2025
5636caa
chore: New task execution task id test (#1352) (#1526)
javier-aliaga Aug 28, 2025
ed39c18
Bump actions/checkout from 4 to 5 (#1504)
dependabot[bot] Aug 28, 2025
5959753
Improve CI runs (#1527)
javier-aliaga Aug 28, 2025
81e8ac7
Fix CVEs (#1529)
javier-aliaga Aug 29, 2025
3c211ac
fix: Use correct snapshot url (#1530)
javier-aliaga Aug 29, 2025
2d1be18
Move alpha to stable (#1531)
javier-aliaga Aug 29, 2025
1b55485
Bump actions/setup-java from 4 to 5 (#1512)
dependabot[bot] Aug 30, 2025
6bf940f
chore: Bump dapr version (#1539)
javier-aliaga Sep 1, 2025
43f117b
Adding logger to WorkflowActivityContext (#1534)
artur-ciocanu Sep 1, 2025
0bf99a4
Use notimestamp in Javadoc Plugin to disable timestamps in Javadocs (…
artur-ciocanu Sep 1, 2025
3e11784
Feat Cross App CallActivity (#1468)
cicoyle Sep 2, 2025
a0a818d
Use xolstice protobuf Maven plugin (#1536)
artur-ciocanu Sep 2, 2025
e08f163
chore: Use implementation class for logger from context (#1542)
javier-aliaga Sep 4, 2025
5b55e1e
Add Tool Calling to Java SDK (#1481)
siri-varma Sep 11, 2025
7b60b1b
rename cross app -> multi app (#1555)
cicoyle Sep 11, 2025
270d8fa
Bump codecov/codecov-action from 5.5.0 to 5.5.1 (#1546)
dependabot[bot] Sep 13, 2025
ffcb2fe
Adding remote activities example with Spring Boot (#1550)
salaboy Sep 15, 2025
c87c85a
Bump actions/github-script from 7 to 8 (#1544)
dependabot[bot] Sep 15, 2025
1c3c5ed
Bump actions/setup-go from 5 to 6 (#1545)
dependabot[bot] Sep 15, 2025
44dbe49
Generate updated javadocs for 1.16.0
dapr-bot Sep 16, 2025
d453d61
Check the Dapr runtime containers before starting another one (#1562)
mcruzdev Sep 23, 2025
57e9c0a
Replace grpc-netty-shaded to grpc-netty (#1543)
mcruzdev Sep 26, 2025
04768bb
Update Spring Boot Matrix 3.5.x and 3.4.x (#1558)
salaboy Sep 26, 2025
521df27
Add crypto
siri-varma Dec 1, 2025
202ee5c
Add tests
siri-varma Dec 1, 2025
590ace2
Centralize Maven dependency version management (#1564)
artur-ciocanu Oct 2, 2025
78f2377
Replace openjdk:17-jdk-slim to eclipse-temurin:17-jdk-jammy (#1574)
mcruzdev Oct 20, 2025
fa35c47
Align Java API with other languages (#1560)
mcruzdev Oct 20, 2025
12bb511
Fix dependencies multi app build and add proper test deps (#1572)
artur-ciocanu Oct 21, 2025
a24bebe
docs: add architecture diagram to README (#1549)
RaymundoZa Oct 21, 2025
09bd72d
Add statestore example with Outbox pattern (#1582)
mcruzdev Oct 24, 2025
49a4d73
adding new method signature plus test (#1570)
salaboy Oct 24, 2025
7685641
Bump actions/upload-artifact from 4 to 5 (#1587)
dependabot[bot] Oct 27, 2025
592042c
Add gRPC support to Dapr testcontainer (#1586)
wlfgang Oct 27, 2025
17e78cf
Use dependencies BOM and remove duplicates. (#1588)
artur-ciocanu Nov 2, 2025
cda3fca
Examples + Docs for App API Token authentication for gRPC and HTTP (#…
cicoyle Nov 6, 2025
213240d
Another set of Maven version, properties and plugin improvements (#1596)
artur-ciocanu Nov 28, 2025
b468d45
Merge branch 'master' into users/svegiraju/add-cryptography
siri-varma Dec 1, 2025
3fc9d63
fix things
siri-varma Dec 2, 2025
a4b9e26
Merge branch 'users/svegiraju/add-cryptography' of https://github.com…
siri-varma Dec 2, 2025
d1b67de
Add crypto exaple
siri-varma Dec 2, 2025
bb17072
Fix formatting of DecryptRequestOptions builder
siri-varma Dec 2, 2025
db655b3
add component
siri-varma Dec 3, 2025
d1ccc17
Merge branch 'users/svegiraju/add-cryptography' of https://github.com…
siri-varma Dec 3, 2025
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
6 changes: 6 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ jobs:
run: sleep 30 && docker logs dapr_scheduler && nc -vz localhost 50006
- name: Install jars
run: ./mvnw clean install -DskipTests -q
- name: Validate crypto example
working-directory: ./examples
run: |
mm.py ./src/main/java/io/dapr/examples/crypto/README.md
- name: Validate workflows example
working-directory: ./examples
run: |
Expand Down Expand Up @@ -186,3 +190,5 @@ jobs:
run: |
mm.py ./src/main/java/io/dapr/examples/pubsub/stream/README.md



12 changes: 12 additions & 0 deletions examples/components/crypto/localstorage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: localstoragecrypto
spec:
type: crypto.dapr.localstorage
version: v1
metadata:
# Path to the directory containing keys (PEM files)
# This should point to a directory containing your key files
- name: path
value: "./keys"
173 changes: 173 additions & 0 deletions examples/src/main/java/io/dapr/examples/crypto/CryptoExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* Copyright 2021 The Dapr Authors
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
limitations under the License.
*/

package io.dapr.examples.crypto;

import io.dapr.client.DaprClientBuilder;
import io.dapr.client.DaprPreviewClient;
import io.dapr.client.domain.DecryptRequestAlpha1;
import io.dapr.client.domain.EncryptRequestAlpha1;
import io.dapr.config.Properties;
import io.dapr.config.Property;
import reactor.core.publisher.Flux;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.Map;

/**
* CryptoExample demonstrates using the Dapr Cryptography building block
* to encrypt and decrypt data using a cryptography component.
*
* <p>This example shows:
* <ul>
* <li>Encrypting plaintext data with a specified key and algorithm</li>
* <li>Decrypting ciphertext data back to plaintext</li>
* <li>Automatic key generation if keys don't exist</li>
* </ul>
*
* <p>Prerequisites:
* <ul>
* <li>Dapr installed and initialized</li>
* <li>A cryptography component configured (e.g., local storage crypto)</li>
* </ul>
*/
public class CryptoExample {

private static final String CRYPTO_COMPONENT_NAME = "localstoragecrypto";
private static final String KEY_NAME = "rsa-private-key";
private static final String KEY_WRAP_ALGORITHM = "RSA";
private static final String KEYS_DIR = "components/crypto/keys";

/**
* The main method demonstrating encryption and decryption with Dapr.
*
* @param args Command line arguments (unused).
*/
public static void main(String[] args) throws Exception {
// Generate keys if they don't exist
generateKeysIfNeeded();

Map<Property<?>, String> overrides = Map.of(
Properties.HTTP_PORT, "3500",
Properties.GRPC_PORT, "50001"
);

try (DaprPreviewClient client = new DaprClientBuilder().withPropertyOverrides(overrides).buildPreviewClient()) {

String originalMessage = "This is a secret message";
byte[] plainText = originalMessage.getBytes(StandardCharsets.UTF_8);

System.out.println("=== Dapr Cryptography Example ===");
System.out.println("Original message: " + originalMessage);
System.out.println();

// Encrypt the message
System.out.println("Encrypting message...");
EncryptRequestAlpha1 encryptRequest = new EncryptRequestAlpha1(
CRYPTO_COMPONENT_NAME,
Flux.just(plainText),
KEY_NAME,
KEY_WRAP_ALGORITHM
);

byte[] encryptedData = client.encrypt(encryptRequest)
.collectList()
.map(CryptoExample::combineChunks)
.block();

System.out.println("Encryption successful!");
System.out.println("Encrypted data length: " + encryptedData.length + " bytes");
System.out.println();

// Decrypt the message
System.out.println("Decrypting message...");
DecryptRequestAlpha1 decryptRequest = new DecryptRequestAlpha1(
CRYPTO_COMPONENT_NAME,
Flux.just(encryptedData)
);

byte[] decryptedData = client.decrypt(decryptRequest)
.collectList()
.map(CryptoExample::combineChunks)
.block();

String decryptedMessage = new String(decryptedData, StandardCharsets.UTF_8);
System.out.println("Decryption successful!");
System.out.println("Decrypted message: " + decryptedMessage);
System.out.println();

if (originalMessage.equals(decryptedMessage)) {
System.out.println("SUCCESS: The decrypted message matches the original.");
} else {
System.out.println("ERROR: The decrypted message does not match the original.");
}

} catch (Exception e) {
System.err.println("Error during crypto operations: " + e.getMessage());
throw new RuntimeException(e);
}
}

/**
* Generates RSA key pair if the key file doesn't exist.
*/
private static void generateKeysIfNeeded() throws NoSuchAlgorithmException, IOException {
Path keysDir = Paths.get(KEYS_DIR);
Path keyFile = keysDir.resolve(KEY_NAME + ".pem");

if (Files.exists(keyFile)) {
System.out.println("Using existing key: " + keyFile.toAbsolutePath());
return;
}

System.out.println("Generating RSA key pair...");
Files.createDirectories(keysDir);

KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(4096);
KeyPair keyPair = keyGen.generateKeyPair();

String privateKeyPem = "-----BEGIN PRIVATE KEY-----\n"
+ Base64.getMimeEncoder(64, "\n".getBytes()).encodeToString(keyPair.getPrivate().getEncoded())
+ "\n-----END PRIVATE KEY-----\n";

String publicKeyPem = "-----BEGIN PUBLIC KEY-----\n"
+ Base64.getMimeEncoder(64, "\n".getBytes()).encodeToString(keyPair.getPublic().getEncoded())
+ "\n-----END PUBLIC KEY-----\n";

Files.writeString(keyFile, privateKeyPem + publicKeyPem);
System.out.println("Key generated: " + keyFile.toAbsolutePath());
}

/**
* Combines byte array chunks into a single byte array.
*/
private static byte[] combineChunks(java.util.List<byte[]> chunks) {
int totalSize = chunks.stream().mapToInt(chunk -> chunk.length).sum();
byte[] result = new byte[totalSize];
int pos = 0;
for (byte[] chunk : chunks) {
System.arraycopy(chunk, 0, result, pos, chunk.length);
pos += chunk.length;
}
return result;
}
}
164 changes: 164 additions & 0 deletions examples/src/main/java/io/dapr/examples/crypto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
## Dapr Cryptography API Examples

This example provides the different capabilities provided by Dapr Java SDK for Cryptography. For further information about Cryptography APIs please refer to [this link](https://docs.dapr.io/developing-applications/building-blocks/cryptography/cryptography-overview/)

### Using the Cryptography API

The Java SDK exposes several methods for this -
* `client.encrypt(...)` for encrypting data using a cryptography component.
* `client.decrypt(...)` for decrypting data using a cryptography component.

## Pre-requisites

* [Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/).
* Java JDK 11 (or greater):
* [Microsoft JDK 11](https://docs.microsoft.com/en-us/java/openjdk/download#openjdk-11)
* [Oracle JDK 11](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11)
* [OpenJDK 11](https://jdk.java.net/11/)
* [Apache Maven](https://maven.apache.org/install.html) version 3.x.

### Checking out the code

Clone this repository:

```sh
git clone https://github.com/dapr/java-sdk.git
cd java-sdk
```

Then build the Maven project:

```sh
# make sure you are in the `java-sdk` directory.
mvn install
```

Then get into the examples directory:

```sh
cd examples
```

### Initialize Dapr

Run `dapr init` to initialize Dapr in Self-Hosted Mode if it's not already initialized.

### Running the Example

This example uses the Java SDK Dapr client to **Encrypt and Decrypt** data. The example automatically generates RSA keys if they don't exist.

#### Example 1: Basic Crypto Example

`CryptoExample.java` demonstrates basic encryption and decryption of a simple message.

```java
public class CryptoExample {
private static final String CRYPTO_COMPONENT_NAME = "localstoragecrypto";
private static final String KEY_NAME = "rsa-private-key";
private static final String KEY_WRAP_ALGORITHM = "RSA";

public static void main(String[] args) {
try (DaprPreviewClient client = new DaprClientBuilder().buildPreviewClient()) {

String originalMessage = "This is a secret message";
byte[] plainText = originalMessage.getBytes(StandardCharsets.UTF_8);

// Encrypt the message
EncryptRequestAlpha1 encryptRequest = new EncryptRequestAlpha1(
CRYPTO_COMPONENT_NAME,
Flux.just(plainText),
KEY_NAME,
KEY_WRAP_ALGORITHM
);

byte[] encryptedData = client.encrypt(encryptRequest)
.collectList()
.map(chunks -> /* combine chunks */)
.block();

// Decrypt the message
DecryptRequestAlpha1 decryptRequest = new DecryptRequestAlpha1(
CRYPTO_COMPONENT_NAME,
Flux.just(encryptedData)
);

byte[] decryptedData = client.decrypt(decryptRequest)
.collectList()
.map(chunks -> /* combine chunks */)
.block();
}
}
}
```

Use the following command to run this example:

<!-- STEP
name: Run Crypto Example
expected_stdout_lines:
- "== APP == SUCCESS: The decrypted message matches the original."
background: true
output_match_mode: substring
sleep: 10
-->

```bash
dapr run --resources-path ./components/crypto --app-id crypto-app --dapr-http-port 3500 --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.crypto.CryptoExample
```

<!-- END_STEP -->

#### Example 2: Streaming Crypto Example

`StreamingCryptoExample.java` demonstrates advanced scenarios including:
- Multi-chunk data encryption
- Large data encryption (100KB+)
- Custom encryption ciphers

```bash
dapr run --resources-path ./components/crypto --app-id crypto-app --dapr-http-port 3500 --dapr-grpc-port 50001 -- java -jar target/dapr-java-sdk-examples-exec.jar io.dapr.examples.crypto.StreamingCryptoExample
```

### Sample Output

```
=== Dapr Cryptography Example ===
Original message: This is a secret message

Encrypting message...
Encryption successful!
Encrypted data length: 512 bytes

Decrypting message...
Decryption successful!
Decrypted message: This is a secret message

SUCCESS: The decrypted message matches the original.
```

### Supported Key Wrap Algorithms

The following key wrap algorithms are supported:
- `A256KW` (alias: `AES`) - AES key wrap
- `A128CBC`, `A192CBC`, `A256CBC` - AES CBC modes
- `RSA-OAEP-256` (alias: `RSA`) - RSA OAEP with SHA-256

### Supported Data Encryption Ciphers

Optional data encryption ciphers:
- `aes-gcm` (default) - AES in GCM mode
- `chacha20-poly1305` - ChaCha20-Poly1305 cipher

### Cleanup

To stop the app, run (or press CTRL+C):

<!-- STEP
name: Cleanup
-->

```bash
dapr stop --app-id crypto-app
```

<!-- END_STEP -->
Loading
Loading