Im generating SOLR from DB with below dataConfig section in data-config.xml file, and it's working fine.
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://127.0.0.1;databaseName=emp" user="user" password="user"/>
<document name="reviews">
<entity name="COMMON" query="select id,name from users" >
<field column="id" name="id"/>
<field column="name" name="name"/>
</entity>
</document>
</dataConfig>
I want to ENCRYPT the url, databaseName, user and password fields in above configuration.
Please Help,
Thanks in Advance.
AnilJayanti
Basically you can parameterize the pwd field (or any other field). Like here below, I have parameterized the password field:
<dataConfig>
<dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@//testdbserver:1521/db1" user="tester" password="${dataimporter.request.pwd}"/>
</dataConfig>
So when you call the server, you can pass the pwd as a parameter:
http://www.googleserver:/solr/dataimport?command=full-import&pwd=sa
Now, you would probably have to encrypt the password or user in the url above (using DES) - and then find a way to decrypt on the SolR side. For decryption on the SolR side, you would have to write a custom evaluator (though it is possible that SolR provides a function to decrypt that I could not find).
Alternately, the parameter can be taken from a custom evaluator. See the link below for understanding custom evaluators:
http://wiki.apache.org/solr/DataImportHandler#Custom_Evalutaors
So, for example:
<dataConfig>
<function name="getPwd" class="myFoo.FetchPwd"/>
<dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@//testdbserver:1521/db1" user="tester" password="${dataimporter.functions.getPwdFromAsc}"/>
</dataConfig>