All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ironcorelabs.sdk.DeviceContext Maven / Gradle / Ivy

There is a newer version: 0.16.0
Show newest version
// Automatically generated by rust_swig
package com.ironcorelabs.sdk;

/**
 * Account's device context. Needed to initialize the Sdk with a set of device keys. See `Sdk.initialize()`
 */
public final class DeviceContext {

    public DeviceContext(UserId accountId, long segmentId, PrivateKey devicePrivateKey, DeviceSigningKeyPair signingPrivateKey) {
        long a0 = accountId.mNativeObj;        long a2 = devicePrivateKey.mNativeObj;        long a3 = signingPrivateKey.mNativeObj;
        mNativeObj = init(a0, segmentId, a2, a3);
        JNIReachabilityFence.reachabilityFence3(accountId, devicePrivateKey, signingPrivateKey);
    }
    private static native long init(long accountId, long segmentId, long devicePrivateKey, long signingPrivateKey);

    public DeviceContext(DeviceAddResult dar) {
        long a0 = dar.mNativeObj;
        mNativeObj = init(a0);
        JNIReachabilityFence.reachabilityFence1(dar);
    }
    private static native long init(long dar);

    public final UserId getAccountId() {
        long ret = do_getAccountId(mNativeObj);
        UserId convRet = new UserId(InternalPointerMarker.RAW_PTR, ret);

        return convRet;
    }
    private static native long do_getAccountId(long self);

    public final long getSegmentId() {
        long ret = do_getSegmentId(mNativeObj);

        return ret;
    }
    private static native long do_getSegmentId(long self);

    public final PrivateKey getDevicePrivateKey() {
        long ret = do_getDevicePrivateKey(mNativeObj);
        PrivateKey convRet = new PrivateKey(InternalPointerMarker.RAW_PTR, ret);

        return convRet;
    }
    private static native long do_getDevicePrivateKey(long self);

    public final DeviceSigningKeyPair getSigningPrivateKey() {
        long ret = do_getSigningPrivateKey(mNativeObj);
        DeviceSigningKeyPair convRet = new DeviceSigningKeyPair(InternalPointerMarker.RAW_PTR, ret);

        return convRet;
    }
    private static native long do_getSigningPrivateKey(long self);

    public final String toJsonString() {
        String ret = do_toJsonString(mNativeObj);

        return ret;
    }
    private static native String do_toJsonString(long self);

    public static DeviceContext fromJsonString(String jsonString) throws Exception {
        long ret = do_fromJsonString(jsonString);
        DeviceContext convRet = new DeviceContext(InternalPointerMarker.RAW_PTR, ret);

        return convRet;
    }
    private static native long do_fromJsonString(String jsonString) throws Exception;

    public synchronized void delete() {
        if (mNativeObj != 0) {
            do_delete(mNativeObj);
            mNativeObj = 0;
       }
    }
    @Override
    protected void finalize() throws Throwable {
        try {
            delete();
        }
        finally {
             super.finalize();
        }
    }
    private static native void do_delete(long me);
    /*package*/ DeviceContext(InternalPointerMarker marker, long ptr) {
        assert marker == InternalPointerMarker.RAW_PTR;
        this.mNativeObj = ptr;
    }
    /*package*/ long mNativeObj;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy