litesoft
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
package org.litesoft.encryption.symmetric;
import java.util.*;
import org.litesoft.core.util.*;
public class SymmetricEncryptorManagerImpl implements SymmetricEncryptorManager
{
private static final String SYMMETRIC_ENCRYPTOR_GET_IDENTIFIER_AND_VERSION = "SymmetricEncryptor.getIdentifierAndVersion()";
private Map<String, SymmetricEncryptor> mSymmetricEncryptors = new HashMap<String, SymmetricEncryptor>();
private SymmetricEncryptor mSymmetricEncryptor;
/**
* @return a non-null SHORT string with NO leading or trailing whitespace that contains an Idetifier
* for the Implementation and a Version Number (colons ':' are NOT allowed to be in this String)
*/
private void validateSymmetricEncryptorID( String pIdentifierAndVersion )
{
UtilsCommon.assertNotNullNotEmpty( SYMMETRIC_ENCRYPTOR_GET_IDENTIFIER_AND_VERSION, pIdentifierAndVersion );
UtilsCommon.assertNoLeadingOrTrailingWhiteSpace( SYMMETRIC_ENCRYPTOR_GET_IDENTIFIER_AND_VERSION, pIdentifierAndVersion );
if ( pIdentifierAndVersion.indexOf( ':' ) != -1 )
{
throw new IllegalArgumentException( "Colon (':') not allowed in the " + SYMMETRIC_ENCRYPTOR_GET_IDENTIFIER_AND_VERSION );
}
}
public SymmetricEncryptorManagerImpl()
{
setSymmetricEncryptor( BrainDeadSymmetricEncryptor.INSTANCE );
}
public synchronized void addDecryptor( SymmetricEncryptor pSymmetricEncryptor )
{
if ( pSymmetricEncryptor != null )
{
String zIdentifierAndVersion = pSymmetricEncryptor.getIdentifierAndVersion();
validateSymmetricEncryptorID( zIdentifierAndVersion );
mSymmetricEncryptors.put( zIdentifierAndVersion, pSymmetricEncryptor );
}
}
public void setSymmetricEncryptor( SymmetricEncryptor pSymmetricEncryptor )
{
if ( pSymmetricEncryptor != null )
{
addDecryptor( pSymmetricEncryptor );
mSymmetricEncryptor = pSymmetricEncryptor;
}
}
public synchronized SymmetricEncryptor getSymmetricEncryptor()
{
return mSymmetricEncryptor;
}
public synchronized SymmetricEncryptor getSymmetricEncryptor( String pIdentifierAndVersion )
{
return pIdentifierAndVersion != null ? mSymmetricEncryptors.get( pIdentifierAndVersion ) : null;
}
}
|
Revision |
Author |
Commited |
Message |
2
|
GeorgeS
|
Sun 07 Feb, 2010 12:50:58 +0000 |
|