SensitiveDataCodec
Stay organized with collections
Save and categorize content based on your preferences.
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)
.
Public Constructor Summary
Public Method Summary
String
|
decodeData(String encrypted)
Decrypts the encoded text.
|
String
|
|
static
void
|
main(String[] args)
Encodes and decodes sensitive data.
|
Inherited Method Summary
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Constructors
public
SensitiveDataCodec
()
Public Methods
public
String
decodeData
(String encrypted)
Decrypts the encoded text.
Parameters
encrypted |
the encrypted string |
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 |
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-03-18 UTC.
[null,null,["Last updated 2025-03-18 UTC."],[],[],null,["# SensitiveDataCodec\n\npublic class **SensitiveDataCodec** extends Object \nHelper object used to encode and decode sensitive data.\n\nThere are three levels of [SensitiveDataCodec.SecurityLevel](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec.SecurityLevel), PLAIN_TEXT, OBFUSCATED and ENCRYPTED. To\nfacilitate decoding a message, first use `getSecurityLevel(String encrypted_message)`\nto get the securityLevel. If the prefix of the encrypted_message doesn't match a valid security\nlevel, the decoder uses PLAIN_TEXT by default.\n\nTo decrypt the message, use `decodeData(String encrypted)`. \n\n### Nested Class Summary\n\n|------|---|---|------------------------------------------------------------------------------|\n| enum | [SensitiveDataCodec.SecurityLevel](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec.SecurityLevel) || Values that specify the security level, used typically for a user parameter. |\n\n### Public Constructor Summary\n\n|---|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [SensitiveDataCodec](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec#SensitiveDataCodec())() |\n\n### Public Method Summary\n\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| String | [decodeData](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec#decodeData(java.lang.String))(String encrypted) Decrypts the encoded text. |\n| String | [encodeData](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec#encodeData(java.lang.String, com.google.enterprise.cloudsearch.sdk.config.SensitiveDataCodec.SecurityLevel))(String readable, [SensitiveDataCodec.SecurityLevel](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec.SecurityLevel) securityLevel) Encodes the text based on `securityLevel`. |\n| static void | [main](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec#main(java.lang.String[]))(String\\[\\] args) Encodes and decodes sensitive data. |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**SensitiveDataCodec**\n()\n\n\u003cbr /\u003e\n\nPublic Methods\n--------------\n\n#### public String\n**decodeData**\n(String encrypted)\n\nDecrypts the encoded text. \n\n##### Parameters\n\n| encrypted | the encrypted string |\n|-----------|----------------------|\n\n##### Returns\n\n- the decrypted string \n\n##### Throws\n\n| [InvalidConfigurationException](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/InvalidConfigurationException) | |\n| IOException | |\n|-------------------------------------------------------------------------------------------------------------------------------------------------|---|\n\n#### public String\n**encodeData**\n(String readable, [SensitiveDataCodec.SecurityLevel](/workspace/cloud-search/docs/reference/sdk/com/google/enterprise/cloudsearch/sdk/config/SensitiveDataCodec.SecurityLevel) securityLevel)\n\nEncodes the text based on `securityLevel`. \n\n##### Parameters\n\n| readable | original text |\n| securityLevel | one of three different security levels: PLAIN_TEXT, OBFUSCATED and ENCRYPTED using public/private key pair |\n|---------------|------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- encrypted text \n\n##### Throws\n\n| IOException | |\n|-------------|---|\n\n#### public static void\n**main**\n(String\\[\\] args)\n\nEncodes and decodes sensitive data.\n\nExample usage to get encoded sensitive data value from the command line:\n\n```\n java -DsecurityLevel=ENCRYPTED \\\n -Djavax.net.ssl.keyStore=encryptKeyStore.jks \\\n -Djavax.net.ssl.keyStorePassword=testtest \\\n -Djavax.net.ssl.keyStoreType=JKS \\\n -Dalias=testkeypair \\\n -classpath 'cloudsearch-connector-sdk-{version}-SNAPSHOT-withlib.jar' \\\n com.google.enterprise.cloudsearch.sdk.config.SensitiveDataCodec\n \n```\n\nTo enable reading the sensitive value from standard input, add a quiet parameter\n(\"--quiet\"). If the quiet parameter is present, the program outputs the encoded sensitive value\nwithout any additional text. \n\n##### Parameters\n\n| args | |\n|------|---|\n\n##### Throws\n\n| IOException | |\n|-------------|---|"]]