Helper object used to encode and decode sensitive data.
There are three levels of SensitiveDataCodec.SecurityLevel
, PLAIN_TEXT, OBFUSCATED and ENCRYPTED. To
facilitate decoding a message, first use getSecurityLevel(String encrypted_message)
to get the securityLevel. If the prefix of the encrypted_message doesn't match a valid security
level, the decoder uses PLAIN_TEXT by default.
To decrypt the message, use decodeData(String encrypted)
.
Nested Class Summary
enum | SensitiveDataCodec.SecurityLevel | Values that specify the security level, used typically for a user parameter. |
Public Constructor Summary
Public Method Summary
String |
decodeData(String encrypted)
Decrypts the encoded text.
|
String |
encodeData(String readable, SensitiveDataCodec.SecurityLevel securityLevel)
Encodes the text based on
securityLevel . |
static void |
main(String[] args)
Encodes and decodes sensitive data.
|
Inherited Method Summary
Public Constructors
public SensitiveDataCodec ()
Public Methods
public String decodeData (String encrypted)
Decrypts the encoded text.
Parameters
encrypted | the encrypted string |
---|
Returns
- the decrypted string
Throws
InvalidConfigurationException | |
---|---|
IOException |
public String encodeData (String readable, SensitiveDataCodec.SecurityLevel securityLevel)
Encodes the text based on securityLevel
.
Parameters
readable | original text |
---|---|
securityLevel | one of three different security levels: PLAIN_TEXT, OBFUSCATED and ENCRYPTED using public/private key pair |
Returns
- encrypted text
Throws
IOException |
---|
public static void main (String[] args)
Encodes and decodes sensitive data.
Example usage to get encoded sensitive data value from the command line:
java -DsecurityLevel=ENCRYPTED \ -Djavax.net.ssl.keyStore=encryptKeyStore.jks \ -Djavax.net.ssl.keyStorePassword=testtest \ -Djavax.net.ssl.keyStoreType=JKS \ -Dalias=testkeypair \ -classpath 'cloudsearch-connector-sdk-{version}-SNAPSHOT-withlib.jar' \ com.google.enterprise.cloudsearch.sdk.config.SensitiveDataCodec
To enable reading the sensitive value from standard input, add a quiet parameter ("--quiet"). If the quiet parameter is present, the program outputs the encoded sensitive value without any additional text.
Parameters
args |
---|
Throws
IOException |
---|