Package org.mycore.crypt
Class MCRCipher
java.lang.Object
org.mycore.crypt.MCRCipher
- Direct Known Subclasses:
MCRAESCipher
Abstract class of a concrete cipherimplementation
After checking the permission call the encrypt an decrypt
functionality. The permission is set by acl.
Example for chipher with id abstract:
crypt:abstract {encrypt:decrypt} "administrators only"
- Author:
- Paul Borchert
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]
decrypt
(byte[] bytes) protected abstract byte[]
decryptImpl
(byte[] bytes) protected abstract String
decryptImpl
(String text) byte[]
encrypt
(byte[] bytes) protected abstract byte[]
encryptImpl
(byte[] bytes) protected abstract String
encryptImpl
(String text) abstract void
If no keyfile exsits, generate the secret key an write it to the keyfile.boolean
abstract void
Initialize the chipher by reading the key from file.abstract boolean
Return whether cipher has been initialized.abstract void
Generate the secret key an write it to the keyfile.abstract void
reset()
Revert init process.void
setAclEnabled
(String enabled)
-
Field Details
-
cipherID
-
-
Constructor Details
-
MCRCipher
public MCRCipher()
-
-
Method Details
-
init
Initialize the chipher by reading the key from file. If the cipher can't initialized an exception will thrown. Common issue is an missing key. In this case the methods throws a MCRCryptKeyFileNotFoundException. Needs the id of cipher as parameter, because the id can't be set during instanciating by getSingleInstanceOf.- Parameters:
id
- ID of cipher as configured- Throws:
MCRCryptKeyFileNotFoundException
InvalidKeyException
-
isInitialized
public abstract boolean isInitialized()Return whether cipher has been initialized. -
reset
public abstract void reset()Revert init process. -
generateKeyFile
If no keyfile exsits, generate the secret key an write it to the keyfile.- Throws:
FileAlreadyExistsException
-
overwriteKeyFile
public abstract void overwriteKeyFile()Generate the secret key an write it to the keyfile. Overwrites exsisting keyfile. -
getAclEnabled
public boolean getAclEnabled() -
setAclEnabled
-
encrypt
- Throws:
MCRCryptKeyNoPermissionException
-
encrypt
- Throws:
MCRCryptKeyNoPermissionException
-
decrypt
- Throws:
MCRCryptKeyNoPermissionException
-
decrypt
- Throws:
MCRCryptKeyNoPermissionException
-
encryptImpl
-
decryptImpl
-
encryptImpl
protected abstract byte[] encryptImpl(byte[] bytes) -
decryptImpl
protected abstract byte[] decryptImpl(byte[] bytes)
-