public class DOKeyRing
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CIPHER_ALG_ATTRIBUTE |
static java.lang.String |
ELEMENT_KEY_FORMAT |
static java.lang.String |
GRANTED_KEY_PREFIX |
static java.lang.String |
KEY_ALG_ATTRIBUTE |
static java.lang.String |
KEY_ID_ATTRIBUTE |
static java.lang.String |
KEYRING_ELEMENT_ID |
| Constructor and Description |
|---|
DOKeyRing(java.security.PrivateKey key,
DigitalObject userObj) |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
buildKeyGrant(java.lang.String keyRecipient,
javax.crypto.SecretKey key)
This will encrypt the given key using the recipient's public key and encode
it into a block of text that can be emailed to an individual.
|
java.io.InputStream |
decryptDataElement(DataElement element)
If the given data element is encrypted, check our keychain for a key that will
decrypt it and use that key to return an InputStream from which the unencrypted
data element bytes can be returned.
|
java.io.InputStream |
decryptDataElementUsingKey(int i,
java.lang.String keyID,
java.lang.String algorithm,
DataElement element) |
javax.crypto.SecretKey |
generateEncryptionKey()
Create and return a SecretKey suitable for object encryption
|
static void |
grantKeyTo(DigitalObject granteeUserObject,
javax.crypto.SecretKey key)
Encrypt and add the given secret key, which was used to encrypt an object,
to the given recipient's keychain.
|
void |
loadKeys()
Loads the user's keychain from their digital object, consolidating any granted keys
into the main keyring
|
long |
writeEncryptedElement(DataElement element,
javax.crypto.SecretKey secKey,
java.io.InputStream source)
Encrypts and writes the data from the given source to the DataElement using the
secret key to encrypt the data while recording the key identifier in the data element's
attributes.
|
public static final java.lang.String KEYRING_ELEMENT_ID
public static final java.lang.String GRANTED_KEY_PREFIX
public static final java.lang.String KEY_ID_ATTRIBUTE
public static final java.lang.String KEY_ALG_ATTRIBUTE
public static final java.lang.String CIPHER_ALG_ATTRIBUTE
public static final java.lang.String ELEMENT_KEY_FORMAT
public DOKeyRing(java.security.PrivateKey key,
DigitalObject userObj)
throws java.lang.Exception
java.lang.Exceptionpublic void loadKeys()
throws java.lang.Exception
java.lang.Exceptionpublic static void grantKeyTo(DigitalObject granteeUserObject, javax.crypto.SecretKey key) throws java.lang.Exception
java.lang.Exceptionpublic static java.lang.String buildKeyGrant(java.lang.String keyRecipient,
javax.crypto.SecretKey key)
throws java.lang.Exception
java.lang.Exceptionpublic javax.crypto.SecretKey generateEncryptionKey()
throws java.security.spec.InvalidKeySpecException
java.security.spec.InvalidKeySpecExceptionpublic java.io.InputStream decryptDataElementUsingKey(int i,
java.lang.String keyID,
java.lang.String algorithm,
DataElement element)
public java.io.InputStream decryptDataElement(DataElement element) throws java.lang.Exception
java.lang.Exceptionpublic long writeEncryptedElement(DataElement element, javax.crypto.SecretKey secKey, java.io.InputStream source) throws java.lang.Exception
java.lang.Exception