-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
183 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,8 @@ | ||
# IronCore Labs IronOxide Bindings | ||
# IronOxide Swig Bindings | ||
|
||
[](https://javadoc.io/doc/com.ironcorelabs/ironoxide-java) | ||
|
||
This library is a thin Rust shim that wraps the [Rust SDK](https://github.com/IronCoreLabs/ironoxide) and uses the [Rust Swig](https://github.com/Dushistov/rust_swig) toolset to generate bindings. It currently contains SDKs for Java and Android. | ||
|
||
# IronOxide-Java | ||
|
||
## Installation | ||
|
||
### Library | ||
|
||
Download the appropriate binary for your operating system on the [releases](https://github.com/IronCoreLabs/ironoxide-java/releases) page: | ||
|
||
- `.so` for (default or Debian-based) Linux | ||
- `.dylib` for OSX | ||
|
||
(Optional) Verify the PGP signature by running `gpg --verify ${file}.asc`. Our fingerprint is `83F9 49C6 E7E2 F0A2 9564 2DEE 62F5 7B1B 8792 8CAC`. | ||
|
||
> If you encounter issues related to linked libraries, you may be able to get a working library built for your system by [building from source](#build-from-source). | ||
This binary should be placed in your Java library path, | ||
either by adding it to your `LD_LIBRARY_PATH` or the `-Djava.library.path` JVM option, | ||
and can then be loaded by calling: | ||
|
||
```java | ||
java.lang.System.loadLibrary("ironoxide_java") | ||
``` | ||
|
||
### Java SDK | ||
|
||
The SDK is [published to Maven](https://search.maven.org/artifact/com.ironcorelabs/ironoxide-java). | ||
|
||
## Usage | ||
|
||
All the SDK classes can be imported from the `com.ironcorelabs.sdk` namespace. | ||
|
||
## Documentation | ||
|
||
Further documentation is available on [our docs site](https://docs.ironcorelabs.com/ironoxide-java-sdk/). | ||
|
||
## Build from Source | ||
|
||
### Prerequisites | ||
|
||
- [Rust toolchain](https://www.rust-lang.org/tools/install) installed | ||
- `JAVA_HOME` environment variable set | ||
- `clang` installed | ||
|
||
### Building | ||
|
||
From the root of this repository run `cargo build -p ironoxide-java`. The resulting `target/debug/build/ironoxide-java-*/out/java` directory will have the JNI binding code for the Java side and `target/debug` will have the dynamic library file you need to pull into your Java code. It will be named `libironoxide_java.so` or `libironoxide_java.dylib` depending on your environment. This library will only work on the architecture from which it was built. | ||
|
||
# IronOxide-Android | ||
|
||
## Using IronOxide-Android | ||
|
||
In order to make calls to the IronCore service, you must add a dependency for ironoxide-android, load the library, and provide authentication. | ||
|
||
### Adding a dependency | ||
|
||
IronOxide-Android is published to a custom maven repository. To pull from this repository, add the following to your project's "build.gradle": | ||
|
||
```java | ||
allprojects { | ||
repositories { | ||
maven { | ||
url "https://oss.sonatype.org/content/repositories/snapshots" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Then add the following to your module's "build.gradle": | ||
|
||
```java | ||
dependencies { | ||
implementation 'com.ironcorelabs:ironoxide-android:<VERSION>@aar' | ||
} | ||
``` | ||
|
||
### Loading the library | ||
|
||
To load the `ironoxide-android` library in Java, use the following: | ||
|
||
```java | ||
java.lang.System.loadLibrary("ironoxide_android"); | ||
``` | ||
|
||
### Authenticating | ||
|
||
To make calls, you must create a project and segment in the IronCore Admin Console. Once created, you can use a tool such as [ironoxide-cli](https://github.com/IronCoreLabs/ironoxide-cli) to create users and devices. You can then read in a device with the `DeviceContext.fromJsonString()` function and use it to initialize an IronOxide instance. An example of this is available in the [Example Application](/android/examples/Example_Application/) in "MainActivity.java". | ||
|
||
## Build from Source | ||
|
||
### Prerequisites | ||
|
||
- Install [Rust toolchain](https://www.rust-lang.org/tools/install). | ||
- Install [cross](https://github.com/rust-embedded/cross). | ||
- Install Android SDK 29. You can get the command line SDK [here](https://developer.android.com/studio) (scroll down to "Command line tools only"). | ||
- Note: **The extracted `tools` folder must follow a specific folder hierarchy. We recommend `AndroidCLI/cmdline-tools/tools`**. | ||
- Install Android 29 build and platform tools. This can be done with `sdkmanager` (found in `tools/bin`): | ||
|
||
```bash | ||
./sdkmanager "build-tools;29.0.3" "platform-tools" "platforms;android-29" | ||
``` | ||
|
||
- Create the file `$HOME/.gradle/gradle.properties` and add the line `sdk.dir=PATH_TO_ANDROID_CLI_FOLDER`. | ||
|
||
### Building | ||
|
||
From the repository root, run `android/build.sh`. This will put the compiled library and generated Java files into `android/ironoxide-android/src/main`. | ||
|
||
## Testing | ||
|
||
### Prerequisites | ||
|
||
- Successfully run `build.sh` by following the steps in [Build from Source](#build-from-source-1). | ||
- This will create the java files and the `.so` files required for the `x86`, `x86_64`, and `arm64-v8a` architectures. If testing on a different architecture, you can find the Rust target to compile to [here](https://forge.rust-lang.org/release/platform-support.html). | ||
- An Android emulator running, or a compatible Android phone connected. | ||
- To start an emulator using the command line tools, follow these steps from the folder `AndroidCLI/cmdline-tools/tools/bin`: | ||
1. `./sdkmanager "emulator" "system-images;android-29;google_apis;x86_64"` | ||
2. `./avdmanager create avd -n pixel_3 -k "system-images;android-29;google_apis;x86_64" -d pixel_3` | ||
3. `../../../emulator/emulator -avd pixel_3 -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim` | ||
- The emulator may take some time to boot, but the output will include `emulator: INFO: boot completed` when it has completed. You will need to use a different terminal to run the tests. | ||
|
||
### Running the Connected Android Tests | ||
|
||
Run the tests from the `android` folder with: | ||
|
||
```bash | ||
./gradlew connectedAndroidTest | ||
``` | ||
This library is a thin Rust shim that wraps the [IronOxide Rust SDK](https://github.com/IronCoreLabs/ironoxide) and uses the [Rust Swig](https://github.com/Dushistov/rust_swig) toolset to generate bindings. It currently contains SDKs for [C++](cpp/README.md), [Java](java/README.md), and [Android](android/README.md). | ||
|
||
# License | ||
|
||
Copyright (c) 2020 IronCore Labs, Inc. | ||
All rights reserved. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# IronOxide-Android | ||
|
||
[](https://javadoc.io/doc/com.ironcorelabs/ironoxide-java) | ||
|
||
## Using IronOxide-Android | ||
|
||
In order to make calls to the IronCore service, you must add a dependency for ironoxide-android, load the library, and provide authentication. | ||
|
||
### Adding a dependency | ||
|
||
Add the following to your module's "build.gradle": | ||
|
||
```java | ||
dependencies { | ||
implementation 'com.ironcorelabs:ironoxide-android:<VERSION>@aar' | ||
} | ||
``` | ||
|
||
### Loading the library | ||
|
||
To load the `ironoxide-android` library in Java, use the following: | ||
|
||
```java | ||
java.lang.System.loadLibrary("ironoxide_android"); | ||
``` | ||
|
||
### Authenticating | ||
|
||
To make calls, you must create a project and segment in the IronCore [Admin Console](https://admin.ironcorelabs.com). These are necessary to create an IronCore JWT that can be used to create users and generate devices. | ||
The JWT must use either the ES256 or RS256 algorithm and have a payload similar to IronOxide's [JwtClaims](https://docs.rs/ironoxide/0.23.0/ironoxide/user/struct.JwtClaims.html). | ||
|
||
Alternatively, once you have created a project and a segment, you can use a tool such as [ironoxide-cli](https://github.com/IronCoreLabs/ironoxide-cli) to create users and devices directly. | ||
You can then read in a device with the `DeviceContext.fromJsonString()` function and use it to initialize an `IronOxide` instance. An example of this is available in the | ||
[Example Application](/android/examples/Example_Application/) in "MainActivity.java". | ||
|
||
## Build from Source | ||
|
||
### Prerequisites | ||
|
||
- Install [Rust toolchain](https://www.rust-lang.org/tools/install). | ||
- Install [cross](https://github.com/rust-embedded/cross). | ||
- Install Android SDK 29. You can get the command line SDK [here](https://developer.android.com/studio) (scroll down to "Command line tools only"). | ||
- Note: **The extracted `tools` folder must follow a specific folder hierarchy. We recommend `AndroidCLI/cmdline-tools/tools`**. | ||
- Install Android 29 build and platform tools. This can be done with `sdkmanager` (found in `tools/bin`): | ||
|
||
```bash | ||
./sdkmanager "build-tools;29.0.3" "platform-tools" "platforms;android-29" | ||
``` | ||
|
||
- Create the file `$HOME/.gradle/gradle.properties` and add the line `sdk.dir=PATH_TO_ANDROID_CLI_FOLDER`. | ||
|
||
### Building | ||
|
||
From the repository root, run `android/build.sh`. | ||
|
||
This will compile IronOxide-Android for `x86_64` Android phones. If building for a different architecture, you can find the Rust target to compile to | ||
[here](https://forge.rust-lang.org/release/platform-support.html) and modify the `cross build` command in `build.sh`. The compiled library and generated Java files will be put into `android/ironoxide-android/src/main`. | ||
|
||
## Testing | ||
|
||
### Prerequisites | ||
|
||
- Successfully run `build.sh` by following the steps in [Build from Source](#build-from-source-1). | ||
- An Android emulator running, or a compatible Android phone connected. | ||
- To start an emulator using the command line tools, follow these steps from the folder `AndroidCLI/cmdline-tools/tools/bin`: | ||
1. `./sdkmanager "emulator" "system-images;android-29;google_apis;x86_64"` | ||
2. `./avdmanager create avd -n pixel_3 -k "system-images;android-29;google_apis;x86_64" -d pixel_3` | ||
3. `../../../emulator/emulator -avd pixel_3 -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim` | ||
- The emulator may take some time to boot, but the output will include `emulator: INFO: boot completed` when it has completed. You will need to use a different terminal to run the tests. | ||
|
||
### Running the Connected Android Tests | ||
|
||
Run the tests from the `android` folder with: | ||
|
||
```bash | ||
./gradlew connectedAndroidTest | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
android/examples/Example_Application/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Tue Apr 07 13:29:29 MDT 2020 | ||
#Wed Jun 24 10:48:40 MDT 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Fri Mar 20 15:26:09 MDT 2020 | ||
#Wed Jun 24 10:49:48 MDT 2020 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip | ||
distributionPath=wrapper/dists | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# IronOxide-Cpp | ||
|
||
## Build from Source | ||
|
||
### Prerequisites | ||
|
||
- C++ 17 or greater installed. Most modern gcc or clang compilers should do. | ||
- CMake >= 3.9. | ||
- Make | ||
|
||
### Building | ||
|
||
From the `cpp` directory, run: | ||
|
||
``` | ||
cmake . | ||
make | ||
``` | ||
|
||
This will output all of the header files to `ironoxide-swig-bindings/cpp/generated/sdk` and the dynamic library `libironoxide` to `ironoxide-swig-bindings/target/release`. | ||
The file extension of the dynamic library will depend on your operating system (`.so` for Linux, `.dylib` for OSX, etc.). | ||
|
||
## Testing | ||
|
||
After running the steps in [Building](#building), the C++ tests can be run from the `cpp` directory with `./cpp-tests`. |
Oops, something went wrong.