com.silverpeas.util.security
Class ContentEncryptionServiceTest

java.lang.Object
  extended by com.silverpeas.util.security.ContentEncryptionServiceTest
Direct Known Subclasses:
ConcurrentExecutionTest, ContentEncryptionTest, KeyManagementTest

public class ContentEncryptionServiceTest
extends Object

The base class of all tests on the services provided by the DefaultContentEncryptionService instances. It allocates all the required resources for the tests and frees them once the tests are done. It creates the security directory to receive the key file, but the key file and it constructs a DefaultContentEncryptionService instance ready to be tested.


Field Summary
protected static String ACTUAL_KEY_FILE_PATH
           
protected static CipherKey CIPHER_KEY
           
protected static String DEPRECATED_KEY_FILE_PATH
           
 
Constructor Summary
ContentEncryptionServiceTest()
           
 
Method Summary
static void createKeyFileWithTheActualKey(String key)
          Creates the key file with the specified actual key in hexadecimal.
static void createKeyFileWithTheDeprecatedKey(String key)
          Creates the key file with the specified deprecated key in hexadecimal.
static void createSecurityDirectoryAndSetupJCEProviders()
           
 void deleteKeyFile()
           
static void deleteSecurityDirectory()
           
static TextContent[] encryptTextContents(TextContent[] contents, String key)
          Encrypts the specified text contents by using the specified cipher key in hexadecimal.
static String generateAESKey()
          Generates a key for an AES enciphering.
static TextContent[] generateTextContents(int count)
          Generates the specified count of text contents for testing purpose.
 DefaultContentEncryptionService getContentEncryptionService()
           
 void setUpContentEncryptionService()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTUAL_KEY_FILE_PATH

protected static final String ACTUAL_KEY_FILE_PATH

DEPRECATED_KEY_FILE_PATH

protected static final String DEPRECATED_KEY_FILE_PATH

CIPHER_KEY

protected static final CipherKey CIPHER_KEY
Constructor Detail

ContentEncryptionServiceTest

public ContentEncryptionServiceTest()
Method Detail

createSecurityDirectoryAndSetupJCEProviders

public static void createSecurityDirectoryAndSetupJCEProviders()
                                                        throws IOException
Throws:
IOException

deleteSecurityDirectory

public static void deleteSecurityDirectory()
                                    throws IOException
Throws:
IOException

setUpContentEncryptionService

public void setUpContentEncryptionService()
                                   throws Exception
Throws:
Exception

deleteKeyFile

public void deleteKeyFile()
                   throws Exception
Throws:
Exception

getContentEncryptionService

public DefaultContentEncryptionService getContentEncryptionService()

generateAESKey

public static String generateAESKey()
                             throws Exception
Generates a key for an AES enciphering.

Returns:
the key in hexadecimal.
Throws:
Exception - if the key cannot be generated.

createKeyFileWithTheActualKey

public static void createKeyFileWithTheActualKey(String key)
                                          throws Exception
Creates the key file with the specified actual key in hexadecimal.

Parameters:
key - the key used in a content encryption and to store in the key file.
Throws:
Exception - if the key file creation failed.

createKeyFileWithTheDeprecatedKey

public static void createKeyFileWithTheDeprecatedKey(String key)
                                              throws Exception
Creates the key file with the specified deprecated key in hexadecimal.

Parameters:
key - the key used in a content encryption and to store in the old key file.
Throws:
Exception - if the key file creation failed.

generateTextContents

public static TextContent[] generateTextContents(int count)
Generates the specified count of text contents for testing purpose.

Parameters:
count - the number of text contents to generate.
Returns:
an array with the generated text contents.

encryptTextContents

public static TextContent[] encryptTextContents(TextContent[] contents,
                                                String key)
                                         throws Exception
Encrypts the specified text contents by using the specified cipher key in hexadecimal.

Parameters:
contents - the contents to encrypt.
key - the cipher key to use in hexadecimal.
Returns:
an array with the encrypted text contents.
Throws:
Exception - if an error occurs while encrypting the contents.


Copyright © 2016 Silverpeas. All Rights Reserved.