public class EncryptionHelper extends Object
Container
and SecuredContainer
for a specific user (KeyRing
) and public key source (IPublicKeySource
). It will use the IPublicKeySource
for getting all
public signing and derivation keys of other users needed to perform the cryptographic operations. Public keys of the
user will be retrieved from the KeyRing
itself. Out of the box, the OfsProvider uses the PublicKeyOfsMapper
for all public keys of other users. The PublicKeyOfsMapper implements IPublicKeySource
. The ServerProvider
uses the PublicKeyMapper
for all public keys of other users. The PublicKeyMapper
also implements IPublicKeySource
. If you want to map public keys yourself, you will want your class to
implement the IPublicKeySource
interface.Constructor and Description |
---|
EncryptionHelper(KeyRing keyRing,
IPublicKeySource publicKeySource)
Create an encryption helper for a specific
KeyRing and IPublicKeySource . |
Modifier and Type | Method and Description |
---|---|
Container |
decrypt(SecuredContainer securedContainer)
|
SecuredContainer |
encrypt(Container container)
|
SecuredContainer |
encrypt(Container container,
Keys keys)
|
Keys |
findSecuredContainerKeys(Metadata metadata)
Find the access for the current user and decrypt the
Keys . |
void |
initializeAccessLevelsKeyBlobAsync(List<Access> accesses,
UUID containerId,
Keys keys)
This will ensure the access entries have the correct container id set and create the appropriate key blob.
|
void |
setKeyRing(KeyRing keyRing)
Sets the user's
KeyRing . |
public EncryptionHelper(KeyRing keyRing, IPublicKeySource publicKeySource) throws NoSuchPaddingException, NoSuchAlgorithmException
KeyRing
and IPublicKeySource
.keyRing
- the sender in all encryption and the recipient in all decryptionpublicKeySource
- the source of all public keys (aside from the key ring)NoSuchAlgorithmException
- thrown if CipherTransformation.AES_CTR_NOPADDING
is not supportedNoSuchPaddingException
- thrown if CipherTransformation.AES_CTR_NOPADDING
is not supportedpublic Container decrypt(SecuredContainer securedContainer) throws Exception
securedContainer
- the secured container to decryptContainer
Exception
- thrown if there are any issues decrypting the SecuredContainer
public SecuredContainer encrypt(Container container) throws Exception
public SecuredContainer encrypt(Container container, Keys keys) throws Exception
public Keys findSecuredContainerKeys(Metadata metadata) throws Exception
Keys
.metadata
- the Metadata
to search for access fromKeys
used to encrypt the SecuredContainer
Exception
- thrown if there are any issues decrypting or getting public keyspublic void initializeAccessLevelsKeyBlobAsync(List<Access> accesses, UUID containerId, Keys keys) throws Exception
Copyright © 2021. All rights reserved.