You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Shinkan <sh...@gmail.com> on 2008/08/28 11:00:09 UTC

Programatically set torque.dsfactory..connection.url

Hi everybody !

I encounter a quite disturbing problem with Torque.
I use it over Apache Derby, and I need to set a password encrypted secure
connection to my Derby base.
So the resulting JDBC connection line is something like :
"jdbc:derby:mybase;dataEncryption=true;bootPassword=mypass"
Due to obvious security reason, I CAN NOT put this connection string on a
config file for my app, or everybody would be able to read the pass, and
connect to the base using other ways that my application plans to.
So I MUST define the "torque.dsfactory.mybase.connection.url" somewhere else
than in "Torque.properties".

I tried this :
Torque.init(_torquePropertiesPath);
Torque.getConfiguration().setProperty("torque.dsfactory.mybase.connection.url",
_secureConnectionString);

But later in my app, when I use SomeTablePeer::retrieveByPk( ... );
Torque throws an SQLException error, pretending that "The url cannot be
null".
So I deduce this is because the "setProperty" doesn't set the
torque.dsfactory.mybase.connection.url correctly ...
If I put the connection string in Torque.properties, everything is OK. BUT I
CAN NOT.
So I would like to know how to proceed to set this connection.url without
using config files ...

Thanks in advance everyone !

-- 
Pierre.
Some people, when confronted with a problem, think "I know, I'll use XML".
Now they have two problems. -- Jamie Zawinski / James Robertson

Re: Programatically set torque.dsfactory..connection.url

Posted by Shinkan <sh...@gmail.com>.
Hi everyone.

Thanks to your pointers, I've found how to proceed. This is what I do :

You have to load "manually" your Torque properties file instead of
deleguating this to Torque.init( String filePath ).
  - Create a PropertiesConfiguration : PropertiesConfiguration torqueConf =
new PropertiesConfiguration();
  - Load the .properties file :
torqueConf.load(PSCDataControl.class.getResourceAsStream(_torqueProperties));
  - Add the properties you don't have to store in your configuration file :
    torqueConf.addProperty(_torqueConnectUrlProperty, PSCSGBD.CONNECT);
  - Then, use the Torque.init( Configuration conf ) method :
Torque.init(torqueConf);
  - You can check good ignition by calling Torque.isInit().

Have a good day !

-- 
Pierre.
Some people, when confronted with a problem, think "I know, I'll use XML".
Now they have two problems. -- Jamie Zawinski / James Robertson

RE: Programatically set torque.dsfactory..connection.url

Posted by Greg Monroe <Gr...@DukeCE.com>.
> -----Original Message-----
> From: Shinkan [mailto:shinkan@gmail.com]
> 
> > Did you try to use the method
> >
> > Torque.init(org.apache.commons.configuration.Configuration conf)
> 
> 
> Yeah ... but no :D !
> In fact I need almost all properties to be set by a file, except the
> connection string one, which contains the pass ...
> Thus, I don't know which class that implements Configuration interface
> to use to load something ...

I could send you there directly, but teaching someone to find their own
answers is better... take a look at the Configuration subsite of the Apache 
Commons Project... hints: commons.apache.org .. Torque's config files is 
a property file.. and there's a user guide.
> 
> 
> >
> > By the way: there was a big discussion about keeping the db password
> > secure half a year or a year ago in the torque lists. You might be
> > interested.
> >
> 
> Sure. Where can I find that ? I'm fact I'm totally new with user's mail
> groups.
> 

Google (or some other search engine) is your friend.. 

torque-user encrypt password site:mail-archives.apache.org

or personally, I prefer www.mail-archive.com.. Nice search interface and 
thread display.


> Thanks !
> 

DukeCE Privacy Statement:
Please be advised that this e-mail and any files transmitted with
it are confidential communication or may otherwise be privileged or
confidential and are intended solely for the individual or entity
to whom they are addressed. If you are not the intended recipient
you may not rely on the contents of this email or any attachments,
and we ask that you please not read, copy or retransmit this
communication, but reply to the sender and destroy the email, its
contents, and all copies thereof immediately. Any unauthorized
dissemination, distribution or copying of this communication is
strictly prohibited.

Re: Programatically set torque.dsfactory..connection.url

Posted by Shinkan <sh...@gmail.com>.
> Did you try to use the method
>
> Torque.init(org.apache.commons.configuration.Configuration conf)


Yeah ... but no :D !
In fact I need almost all properties to be set by a file, except the
connection string one, which contains the pass ...
Thus, I don't know which class that implements Configuration interface to
use to load something ...


>
> By the way: there was a big discussion about keeping the db password
> secure half a year or a year ago in the torque lists. You might be
> interested.
>

Sure. Where can I find that ? I'm fact I'm totally new with user's mail
groups.

Thanks !


-- 
Pierre.
Some people, when confronted with a problem, think "I know, I'll use XML".
Now they have two problems. -- Jamie Zawinski / James Robertson

RE: Programatically set torque.dsfactory..connection.url

Posted by Thomas Fischer <fi...@seitenbau.net>.
Did you try to use the method

Torque.init(org.apache.commons.configuration.Configuration conf) 

instead of Torque.init(java.lang.String) ?

By the way: there was a big discussion about keeping the db password 
secure half a year or a year ago in the torque lists. You might be 
interested.

    Thomas

> 
> Hi everybody !
> 
> I encounter a quite disturbing problem with Torque.
> I use it over Apache Derby, and I need to set a password encrypted 
secure
> connection to my Derby base.
> So the resulting JDBC connection line is something like :
> "jdbc:derby:mybase;dataEncryption=true;bootPassword=mypass"
> Due to obvious security reason, I CAN NOT put this connection string on 
a
> config file for my app, or everybody would be able to read the pass, and
> connect to the base using other ways that my application plans to.
> So I MUST define the "torque.dsfactory.mybase.connection.url" somewhere 
else
> than in "Torque.properties".
> 
> I tried this :
> Torque.init(_torquePropertiesPath);
> Torque.getConfiguration().setProperty
> ("torque.dsfactory.mybase.connection.url",
> _secureConnectionString);
> 
> But later in my app, when I use SomeTablePeer::retrieveByPk( ... );
> Torque throws an SQLException error, pretending that "The url cannot be
> null".
> So I deduce this is because the "setProperty" doesn't set the
> torque.dsfactory.mybase.connection.url correctly ...
> If I put the connection string in Torque.properties, everything is OK. 
BUT I
> CAN NOT.
> So I would like to know how to proceed to set this connection.url 
without
> using config files ...
> 
> Thanks in advance everyone !
> 
> -- 
> Pierre.
> Some people, when confronted with a problem, think "I know, I'll use 
XML".
> Now they have two problems. -- Jamie Zawinski / James Robertson