11## AWS IoT SDK for Java v2
22
3+
34Next generation AWS IoT Client SDK for Java using the AWS Common Runtime
45
56This project is in ** GENERAL AVAILABILITY** . If you have any issues or feature
@@ -18,13 +19,20 @@ to Java by the [aws-crt-java](https://github.com/awslabs/aws-crt-java) package.
1819
1920Integration with AWS IoT Services such as
2021[ Device Shadow] ( https://docs.aws.amazon.com/iot/latest/developerguide/iot-device-shadows.html )
21- and [ Jobs] ( https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html )
22+ [ Jobs] ( https://docs.aws.amazon.com/iot/latest/developerguide/iot-jobs.html )
23+ [ Fleet Provisioning] ( https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html )
2224is provided by code that been generated from a model of the service.
2325
2426# Installation
2527## Minimum Requirements
2628* Java 8 or above
27- * Maven
29+
30+ ** Set JAVA_HOME first
31+
32+ * Install Maven
33+
34+ brew install maven
35+
2836## Requirements to build the AWS CRT locally
2937* CMake 3.1+
3038* Clang 3.9+ or GCC 4.4+ or MSVC 2015+
@@ -34,18 +42,20 @@ is provided by code that been generated from a model of the service.
3442git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git
3543# update the version of the CRT being used
3644mvn versions:use-latest-versions -Dincludes="software.amazon.awssdk.crt*"
37- mvn install
45+ mvn clean install
3846```
3947
4048## Build CRT from source
4149``` sh
4250# NOTE: use the latest version of the CRT here
43- git clone --branch v0.5.4 https://github.com/awslabs/aws-crt-java.git
51+
52+ git clone --branch v0.4.20 https://github.com/awslabs/aws-crt-java.git
53+
4454git clone https://github.com/awslabs/aws-iot-device-sdk-java-v2.git
4555cd aws-crt-java
4656mvn install -Dmaven.test.skip=true
4757cd ../aws-iot-device-sdk-java-v2
48- mvn install
58+ mvn clean install
4959```
5060
5161### Android
@@ -237,6 +247,80 @@ and receive.
237247</pre >
238248</details >
239249
250+ ## fleet provisioning
251+
252+ This sample uses the AWS IoT
253+ [ Fleet provisioning] ( https://docs.aws.amazon.com/iot/latest/developerguide/provision-wo-cert.html )
254+ to provision devices using either a CSR or KeysAndcertificate and subsequently calls RegisterThing.
255+
256+ On startup, the script subscribes to topics based on the request type of either CSR or Keys topics,
257+ publishes the request to corresponding topic and calls RegisterThing.
258+
259+ Source: ` samples/Identity `
260+
261+ cd ~ /samples/Identity
262+
263+ Run the sample using CreateKeysAndCertificate:
264+
265+ ```
266+ mvn exec:java -Dexec.mainClass="identity.FleetProvisioningSample" -Dexec.args="--endpoint <endpoint> --rootca <root ca path>
267+ --cert <cert path> --key <private key path> --templateName <templatename> --templateParameters <templateParams>"
268+ ```
269+
270+ Run the sample using CreateCertificateFromCsr:
271+
272+ ```
273+ mvn exec:java -Dexec.mainClass="identity.FleetProvisioningSample" -Dexec.args="--endpoint <endpoint> --rootca <root ca path>
274+ --cert <cert path> --key <private key path> --templateName <templatename> --templateParameters <templateParams> --csr <csr path>"
275+ ```
276+
277+ Your Thing's
278+ [ Policy] ( https://docs.aws.amazon.com/iot/latest/developerguide/iot-policies.html )
279+ must provide privileges for this sample to connect, subscribe, publish,
280+ and receive.
281+
282+ <details >
283+ <summary >(see sample policy)</summary >
284+ <pre >
285+ {
286+ "Version": "2012-10-17",
287+ "Statement": [
288+ {
289+ "Effect": "Allow",
290+ "Action": [
291+ "iot:Publish"
292+ ],
293+ "Resource": [
294+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create/json",
295+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create-from-csr/json",
296+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/provisioning-templates/<b >templatename<b >/provision/json"
297+ ]
298+ },
299+ {
300+ "Effect": "Allow",
301+ "Action": [
302+ "iot:Receive",
303+ "iot:Subscribe"
304+ ],
305+ "Resource": [
306+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create/json/accepted",
307+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create/json/rejected",
308+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create-from-csr/json/accepted",
309+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/certificates/create-from-csr/json/rejected",
310+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/provisioning-templates/<b >templatename<b >/provision/json/accepted",
311+ "arn:aws:iot:<b >region</b >:<b >account</b >:topic/$aws/provisioning-templates/<b >templatename<b >/provision/json/rejected"
312+ ]
313+ },
314+ {
315+ "Effect": "Allow",
316+ "Action": "iot:Connect",
317+ "Resource": "arn:aws:iot:<b >region</b >:<b >account</b >:client/samples-client-id"
318+ }
319+ ]
320+ }
321+ </pre >
322+ </details >
323+
240324# License
241325
242326This library is licensed under the Apache 2.0 License.
0 commit comments