Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Hiding password value from persistance.xml

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I am using JPA(Hibernate) as ORM. My Persistance xml looks like
<persistence-unit name="JPATestPU" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name = "hibernate.connection.driver_class" value = "oracle.jdbc.driver.OracleDriver"/>
<property name = "hibernate.connection.url" value = "jdbc:oracle:thin:@100.100.100.100:1521:ecprod"/>
<property name = "hibernate.connection.username" value = "abcd"/>
<property name = "hibernate.connection.password" value = "*******"/>
</properties>
</persistence-unit>
I do not want to display the password in this xml file. Is there any way to hide thi password value.
Thanks in advance.

Amit
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could programatically configure this if you really feel this is an issue.
 
AmitKumar Dutta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul..
Any pointer how to configure programatically.
 
AmitKumar Dutta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All
Following is the java code :

Map properties = new HashMap();
properties.put("hibernate.connection.password", "password");

emf = Persistence.createEntityManagerFactory("MyJPA", properties);

Thanks
Amit
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why don't you want it in the persistence file?

If your hypothetical "bad people" have access to that file, they already have access to your machine, and you're already way more screwed than if they just had access to the DB.
 
AmitKumar Dutta
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, correct I understand your point.
But the requirement is not display username, password in the XML .
I am thinking if
1) I could encrypt the password and place it in a properties file
2) use a datasource thru jndi
Can anyone suggest any standard way?
Thanks
Amit
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Requirements like that usually come from people that don't know what they're talking about. It'd be easier to configure a JNDI resource.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic