Table of Contents
Links#
See also:- https://issues.apache.org/jira/browse/JSPWIKI-205
- http://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html
- EncryptedPageFilter
Overview#
This is a new feature part of JSPWiki 2.10.2The WikiEngine, now contains access to a CryptoManager which can be accessed by wikiEngine.getCryptoManager()
The CryptoManager has one function getCryptoProvider() which gets the CryptoProvider as specified by jspwiki.cryptoProvider property in jspwiki-custom.properties. The CryptoProvider has the following interface methods:
public byte[] encrypt(char[] key, byte[] content) throws EncryptionException; public byte[] decrypt(char[] key, byte[] content) throws EncryptionException;
CryptoProvider cryptoProvider = wikiEngine.getCryptoManager().getCryptoProvider(); byte[] encrypted = cryptoProvider.encrypt("secretkey".toCharArray(),"content".getBytes()); String decrypted = new String(cryptoProvider.decrypt("secretkey".toCharArray(),encrypted));
BaseCryptoProvider#
The default value for the cryptoProvider is a org.apache.wiki.crypto.BaseCryptoProvider which is an Identity provider, and does no encryption or decryption at all.The BaseCryptoProvider can be a base class to other cryptoProviders.
It reads the jspwiki.properties value jspwiki.cryptoFile (defaults to jspwiki-crypto.properties) and loads these properties into cryptoProperties i.e. getCryptoProperties()
PBECryptoProvider#
Another cryptoProvider implementation is the PBECryptoProvider (Password Base Encryption).
This provider expects the following cryptoProperties:
Property | description | type | default |
---|---|---|---|
crypto.base64 | if true changed encrypted string to base64 | boolean | true |
crypto.salt | The salt used to create the PBEParameterSpec | String | A random string |
crypto.blocksize | The block size of the salt for the PBE algorithm | int | 8 |
crypto.itrcount | The iteration count for the PBE algorithm | int | 2048 |
crypto.algorithm | The algorithm to be used as per CryptoSpec | String | PBEWithMD5AndDES |
Category.Documentation