Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Automatically generated by rust_swig
package com.ironcorelabs.sdk;
/**
* Struct that is used to make authenticated requests to the IronCore API. Instantiated with the details
* of an accounts various ids, device, and signing keys. Once instantiated all operations will be
* performed in the context of the account provided.
*/
public final class IronSdk {
private IronSdk() {}
/**
* Verify a user given a JWT for their user record.
*
* @param jwt valid IronCore JWT
* @return option of whether the user's account record exists in the IronCore system or not. Error if the request couldn't be made.
*/
public static java.util.Optional userVerify(String jwt) throws Exception {
long ret = do_userVerify(jwt);
java.util.Optional convRet;
if (ret != 0) {
convRet = java.util.Optional.of(new UserResult(InternalPointerMarker.RAW_PTR, ret));
} else {
convRet = java.util.Optional.empty();
}
return convRet;
}
private static native long do_userVerify(String jwt) throws Exception;
/**
* Create a new user within the IronCore system.
*
* @param jwt valid IronCore or Auth0 JWT
* @param password password used to encrypt and escrow the user's private master key
* @param options see {@link UserCreateOpts}. Use `new UserCreateOpts()` for defaults
* @return see {@link UserCreateResult}. For most use cases, the public key can be discarded as IronCore escrows your user's keys.
* The escrowed keys are unlocked by the provided password.
*/
public static UserCreateResult userCreate(String jwt, String password, UserCreateOpts options) throws Exception {
long a2 = options.mNativeObj;
long ret = do_userCreate(jwt, password, a2);
UserCreateResult convRet = new UserCreateResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(options);
return convRet;
}
private static native long do_userCreate(String jwt, String password, long options) throws Exception;
/**
* Initialize IronSdk with a device. Verifies that the provided user/segment exists and the provided device
* keys are valid and exist for the provided account.
*
* @param init device context used to initialize the IronSdk with a set of device keys
* @throws java.lang.Exception if the provided `DeviceContext` is invalid
* @return an instance of the IronSdk
*/
public static IronSdk initialize(DeviceContext init) throws Exception {
long a0 = init.mNativeObj;
long ret = do_initialize(a0);
IronSdk convRet = new IronSdk(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(init);
return convRet;
}
private static native long do_initialize(long init) throws Exception;
/**
* Initialize IronSdk with a device. Verifies that the provided user/segment exists and the provided device
* keys are valid and exist for the provided account.
* After initialization, checks whether the calling user's private key needs rotation and rotates it
* if necessary, then does the same for each group the user is an admin of.
*
* @param init device context used to initialize the IronSdk with a set of device keys
* @param password password used to encrypt and escrow the user's private master key
* @return an instance of the IronSdk
*/
public static IronSdk initializeAndRotate(DeviceContext init, String password) throws Exception {
long a0 = init.mNativeObj;
long ret = do_initializeAndRotate(a0, password);
IronSdk convRet = new IronSdk(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(init);
return convRet;
}
private static native long do_initializeAndRotate(long init, String password) throws Exception;
/**
* Generates a new device for the user specified in the signed JWT.
*
* This will result in a new transform key (from the user's master private key to the new device's public key)
* being generated and stored with the IronCore Service.
*
* @param jwt valid IronCore JWT
* @param password password used to encrypt and escrow the user's private key
* @param deviceCreateOptions optional values, like device name
*
* @return details about the newly created device
*/
public static DeviceAddResult generateNewDevice(String jwt, String password, DeviceCreateOpts deviceCreateOptions) throws Exception {
long a2 = deviceCreateOptions.mNativeObj;
long ret = do_generateNewDevice(jwt, password, a2);
DeviceAddResult convRet = new DeviceAddResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(deviceCreateOptions);
return convRet;
}
private static native long do_generateNewDevice(String jwt, String password, long deviceCreateOptions) throws Exception;
/**
* Get all the devices for the current user
*
* @return all devices for the current user, sorted by the device id
*/
public final UserDeviceListResult userListDevices() throws Exception {
long ret = do_userListDevices(mNativeObj);
UserDeviceListResult convRet = new UserDeviceListResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_userListDevices(long self) throws Exception;
/**
* Get a list of user public keys given their IDs. Allows discovery of which user IDs have keys in the
* IronCore system to determine of they can be added to groups or have documents shared with them.AsMut
*
* @param users list of user IDs to check
*
* @return map from user ID to users public key. Only users who have public keys will be returned in the map
*/
public final UserWithKey [] userGetPublicKey(UserId [] users) throws Exception {
UserWithKey [] ret = do_userGetPublicKey(mNativeObj, users);
return ret;
}
private static native UserWithKey [] do_userGetPublicKey(long self, UserId [] users) throws Exception;
/**
* Delete a user device.
*
* If deleting the currently signed in device (None for `deviceId`), the sdk will need to be
* reinitialized with `IronSdk.initialize()` before further use.
*
* @param deviceId id of the device to delete. If `null`, delete the currently signed in device {@link #userListDevices()} to get ids
*
* @return id of deleted device or IronSdkErr
*/
public final DeviceId userDeleteDevice(DeviceId deviceId) throws Exception {
long a0 = 0;//TODO: use ptr::null() for corresponding constant
if (deviceId != null) {
a0 = deviceId.mNativeObj;
deviceId.mNativeObj = 0;
}
long ret = do_userDeleteDevice(mNativeObj, a0);
DeviceId convRet = new DeviceId(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(deviceId);
return convRet;
}
private static native long do_userDeleteDevice(long self, long deviceId) throws Exception;
/**
* Rotate the current user's private key, but leave the public key the same.
* There's no black magic here! This is accomplished via multi-party computation with the
* IronCore webservice.
*
* @param password password to unlock the current user's master private key
*
* @return The (encrypted) updated private key and associated metadata
*/
public final UserUpdatePrivateKeyResult userRotatePrivateKey(String password) throws Exception {
long ret = do_userRotatePrivateKey(mNativeObj, password);
UserUpdatePrivateKeyResult convRet = new UserUpdatePrivateKeyResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_userRotatePrivateKey(long self, String password) throws Exception;
/**
* List all of the documents that the current user is able to decrypt.
*
* @return {@link DocumentListResult} struct with vec of metadata about each document the user can decrypt.
*/
public final DocumentListResult documentList() throws Exception {
long ret = do_documentList(mNativeObj);
DocumentListResult convRet = new DocumentListResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_documentList(long self) throws Exception;
/**
* Get the metadata for a specific document given its id.
*
* @param id unique id of the document to retrieve
*
* @return {@link DocumentMetadataResult} with details about the requested document.
*/
public final DocumentMetadataResult documentGetMetadata(DocumentId id) throws Exception {
long a0 = id.mNativeObj;
long ret = do_documentGetMetadata(mNativeObj, a0);
DocumentMetadataResult convRet = new DocumentMetadataResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_documentGetMetadata(long self, long id) throws Exception;
/**
* Attempt to parse the document id out of an encrypted document.
*
* @param encryptedDocument encrypted document bytes
*
* @throws java.lang.Exception if provided encrypted document has no header
* @return extracted id
*/
public final DocumentId documentGetIdFromBytes(byte [] encryptedDocument) throws Exception {
long ret = do_documentGetIdFromBytes(mNativeObj, encryptedDocument);
DocumentId convRet = new DocumentId(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_documentGetIdFromBytes(long self, byte [] encryptedDocument) throws Exception;
/**
* Encrypt the provided document bytes.
*
* @param documentData bytes of the document to encrypt
* @param encryptOpts optional document encrypt parameters
*/
public final DocumentEncryptResult documentEncrypt(byte [] documentData, DocumentEncryptOpts encryptOpts) throws Exception {
long a1 = encryptOpts.mNativeObj;
long ret = do_documentEncrypt(mNativeObj, documentData, a1);
DocumentEncryptResult convRet = new DocumentEncryptResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(encryptOpts);
return convRet;
}
private static native long do_documentEncrypt(long self, byte [] documentData, long encryptOpts) throws Exception;
/**
* Update the encrypted content of an existing document. Persists any existing access to other users and groups.
*
* @param id id of document to update
* @param newDocumentData updated document content to encrypt
*/
public final DocumentEncryptResult documentUpdateBytes(DocumentId id, byte [] newDocumentData) throws Exception {
long a0 = id.mNativeObj;
long ret = do_documentUpdateBytes(mNativeObj, a0, newDocumentData);
DocumentEncryptResult convRet = new DocumentEncryptResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_documentUpdateBytes(long self, long id, byte [] newDocumentData) throws Exception;
/**
* Decrypts the provided encrypted document and returns details about the document as well as its decrypted bytes.
*
* @param encryptedDocument bytes of encrypted document. Should be the same bytes returned from {@link #documentEncrypt(byte[], DocumentEncryptOpts)}
*
* @return {@link DocumentDecryptResult} includes metadata about the provided document as well as the decrypted document bytes
*/
public final DocumentDecryptResult documentDecrypt(byte [] encryptedDocument) throws Exception {
long ret = do_documentDecrypt(mNativeObj, encryptedDocument);
DocumentDecryptResult convRet = new DocumentDecryptResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_documentDecrypt(long self, byte [] encryptedDocument) throws Exception;
/**
* Update a document name to a new value or clear its value.
*
* @param id id of the document to update
* @param name new name for the document. Provide a {@link DocumentName} to update to a new name or `null` to clear the name field
*
* @return metadata about the document that was updated.
*/
public final DocumentMetadataResult documentUpdateName(DocumentId id, DocumentName name) throws Exception {
long a0 = id.mNativeObj;
long a1 = 0;//TODO: use ptr::null() for corresponding constant
if (name != null) {
a1 = name.mNativeObj;
name.mNativeObj = 0;
}
long ret = do_documentUpdateName(mNativeObj, a0, a1);
DocumentMetadataResult convRet = new DocumentMetadataResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence2(id, name);
return convRet;
}
private static native long do_documentUpdateName(long self, long id, long name) throws Exception;
/**
* Grant access to a document. Recipients of document access can be either users or groups.
*
* @param documentId id of the document whose access is is being modified
* @param userGrants list of user grants
* @param groupGrants list of group grants
*
* @throws java.lang.Exception the request failed either on the client or the server rejected the whole request
* @return each individual grant to a user/group succeeded or failed
*/
public final DocumentAccessResult documentGrantAccess(DocumentId documentId, UserId [] userGrants, GroupId [] groupGrants) throws Exception {
long a0 = documentId.mNativeObj;
long ret = do_documentGrantAccess(mNativeObj, a0, userGrants, groupGrants);
DocumentAccessResult convRet = new DocumentAccessResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(documentId);
return convRet;
}
private static native long do_documentGrantAccess(long self, long documentId, UserId [] userGrants, GroupId [] groupGrants) throws Exception;
/**
* Revoke access from a document. Revocation of document access can be either users or groups.
*
* @param documentId id of the document whose access is is being modified
* @param userRevokes list of user revokes
* @param groupRevokes list of group revokes
*
* @throws java.lang.Exception the request failed either on the client or the server rejected the whole request
* @return each individual revoke from a user/group either succeeded or failed
*/
public final DocumentAccessResult documentRevokeAccess(DocumentId documentId, UserId [] userRevokes, GroupId [] groupRevokes) throws Exception {
long a0 = documentId.mNativeObj;
long ret = do_documentRevokeAccess(mNativeObj, a0, userRevokes, groupRevokes);
DocumentAccessResult convRet = new DocumentAccessResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(documentId);
return convRet;
}
private static native long do_documentRevokeAccess(long self, long documentId, UserId [] userRevokes, GroupId [] groupRevokes) throws Exception;
/**
* List all of the groups that the current user is either an admin or member of.
*
* @return list of (abbreviated) metadata about each group the user is a part of
*/
public final GroupListResult groupList() throws Exception {
long ret = do_groupList(mNativeObj);
GroupListResult convRet = new GroupListResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_groupList(long self) throws Exception;
/**
* Get the full metadata for a specific group given its ID.
*
* @param id unique id of the group to retrieve
*
* @return details about the requested group
*/
public final GroupGetResult groupGetMetadata(GroupId id) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupGetMetadata(mNativeObj, a0);
GroupGetResult convRet = new GroupGetResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupGetMetadata(long self, long id) throws Exception;
/**
* Create a group. The creating user will become a group admin.
*
* @param groupCreateOpts see {@link GroupCreateOpts}. Use `new GroupCreateOpts()` for defaults
*/
public final GroupCreateResult groupCreate(GroupCreateOpts groupCreateOpts) throws Exception {
long a0 = groupCreateOpts.mNativeObj;
long ret = do_groupCreate(mNativeObj, a0);
GroupCreateResult convRet = new GroupCreateResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(groupCreateOpts);
return convRet;
}
private static native long do_groupCreate(long self, long groupCreateOpts) throws Exception;
/**
* Update a group name to a new value or clear its value.
*
* @param id id of the group to update
* @param name new name for the group. Provide a {@link GroupName} to update to a new name or `null` to clear the name field
*
* @return metadata about the group that was updated
*/
public final GroupMetaResult groupUpdateName(GroupId id, GroupName name) throws Exception {
long a0 = id.mNativeObj;
long a1 = 0;//TODO: use ptr::null() for corresponding constant
if (name != null) {
a1 = name.mNativeObj;
name.mNativeObj = 0;
}
long ret = do_groupUpdateName(mNativeObj, a0, a1);
GroupMetaResult convRet = new GroupMetaResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence2(id, name);
return convRet;
}
private static native long do_groupUpdateName(long self, long id, long name) throws Exception;
/**
* Delete the identified group.
*
* @param id unique id of group
*
* @throws java.lang.Exception if it wasn't able to delete the group
* @return the deleted group id
*/
public final GroupId groupDelete(GroupId id) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupDelete(mNativeObj, a0);
GroupId convRet = new GroupId(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupDelete(long self, long id) throws Exception;
/**
* Add the users as members of a group.
*
* @param id id of the group to add members to
* @param users the list of users thet will be added to the group as members
*
* @return all the users that were added and all the users that were not added with the reason they were not
*/
public final GroupAccessEditResult groupAddMembers(GroupId id, UserId [] users) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupAddMembers(mNativeObj, a0, users);
GroupAccessEditResult convRet = new GroupAccessEditResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupAddMembers(long self, long id, UserId [] users) throws Exception;
/**
* Remove a list of users as members from the group.
*
* @param id id of the group to remove members from
* @param userRevokes list of user ids to remove as members
*
* @return list of users that were removed and the users that failed to be removed with the reason they were not
*/
public final GroupAccessEditResult groupRemoveMembers(GroupId id, UserId [] userRevokes) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupRemoveMembers(mNativeObj, a0, userRevokes);
GroupAccessEditResult convRet = new GroupAccessEditResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupRemoveMembers(long self, long id, UserId [] userRevokes) throws Exception;
/**
* Add the users as admins of a group.
*
* @param id id of the group to add admins to
* @param users the list of users that will be added to the group as admins
*
* @return all the users that were added and the users that were not added with the reason they were not
*/
public final GroupAccessEditResult groupAddAdmins(GroupId id, UserId [] users) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupAddAdmins(mNativeObj, a0, users);
GroupAccessEditResult convRet = new GroupAccessEditResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupAddAdmins(long self, long id, UserId [] users) throws Exception;
/**
* Remove a list of users as admins from the group.
*
* @param id id of the group
* @param userRevokes list of user ids to remove as admins
*
* @return list of users that were removed and the users that failed to be removed with the reason they were not
*/
public final GroupAccessEditResult groupRemoveAdmins(GroupId id, UserId [] userRevokes) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupRemoveAdmins(mNativeObj, a0, userRevokes);
GroupAccessEditResult convRet = new GroupAccessEditResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupRemoveAdmins(long self, long id, UserId [] userRevokes) throws Exception;
/**
* Rotate the provided group's private key, but leave the public key the same.
* There's no black magic here! This is accomplished via multi-party computation with the
* IronCore webservice.
* Note: You must be an admin of the group in order to rotate its private key.
*
* @param id id of the group you wish to rotate the private key of
* @return The id of the group whose private key got updated and associated metadata
*/
public final GroupUpdatePrivateKeyResult groupRotatePrivateKey(GroupId id) throws Exception {
long a0 = id.mNativeObj;
long ret = do_groupRotatePrivateKey(mNativeObj, a0);
GroupUpdatePrivateKeyResult convRet = new GroupUpdatePrivateKeyResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(id);
return convRet;
}
private static native long do_groupRotatePrivateKey(long self, long id) throws Exception;
/**
* Encrypt the provided document bytes. Return the encrypted document encryption keys (EDEKs) instead of creating a document entry in the IronCore webservice.
*
* @param documentData bytes of the document to encrypt
* @param encryptOpts optional document encrypt parameters
*/
public final DocumentEncryptUnmanagedResult advancedDocumentEncryptUnmanaged(byte [] documentData, DocumentEncryptOpts encryptOpts) throws Exception {
long a1 = encryptOpts.mNativeObj;
long ret = do_advancedDocumentEncryptUnmanaged(mNativeObj, documentData, a1);
DocumentEncryptUnmanagedResult convRet = new DocumentEncryptUnmanagedResult(InternalPointerMarker.RAW_PTR, ret);
JNIReachabilityFence.reachabilityFence1(encryptOpts);
return convRet;
}
private static native long do_advancedDocumentEncryptUnmanaged(long self, byte [] documentData, long encryptOpts) throws Exception;
/**
* Decrypt the provided encrypted document with the encrypted document encryption keys (EDEKs).
*
* @param encryptedData bytes of encrypted document. Should be the same bytes returned from {@link #advancedDocumentEncryptUnmanaged(byte[], DocumentEncryptOpts)}
* @param encryptedDeks encrypted document encryption keys. Should be the same edeks returned from {@link #advancedDocumentEncryptUnmanaged(byte[], DocumentEncryptOpts)}
*
* @return {@link DocumentDecryptResult} includes the id of the provided document as well as the decrypted document bytes
*/
public final DocumentDecryptUnmanagedResult advancedDocumentDecryptUnmanaged(byte [] encryptedData, byte [] encryptedDeks) throws Exception {
long ret = do_advancedDocumentDecryptUnmanaged(mNativeObj, encryptedData, encryptedDeks);
DocumentDecryptUnmanagedResult convRet = new DocumentDecryptUnmanagedResult(InternalPointerMarker.RAW_PTR, ret);
return convRet;
}
private static native long do_advancedDocumentDecryptUnmanaged(long self, byte [] encryptedData, byte [] encryptedDeks) 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*/ IronSdk(InternalPointerMarker marker, long ptr) {
assert marker == InternalPointerMarker.RAW_PTR;
this.mNativeObj = ptr;
}
/*package*/ long mNativeObj;
}