You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andrey Gladilin <an...@gmail.com> on 2010/10/16 15:50:50 UTC
login with stored procedure
Hi guys,
Is there a way to make authentication in Tapestry using store procedure.
I have several stored procedures in Postgres, like
login(session_id, username, password, locale)
logout(session_id)
get_roles(session_id)
I was trying to use Spring Security, but did not find a way to use
stored procedures with it.
Could you put me on a proper way?
Thanks.
P.S. Please don't ask me to throw away stored procedures, I can not do it.
--
С уважением, Гладилин Андрей.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sat, 16 Oct 2010 10:50:50 -0300, Andrey Gladilin
<an...@gmail.com> wrote:
> Hi guys,
Hi!
> Is there a way to make authentication in Tapestry using store procedure.
> I have several stored procedures in Postgres, like
> login(session_id, username, password, locale)
> logout(session_id)
> get_roles(session_id)
This isn't related to Tapestry at all. Tapestry is a framework and what
you're asking is data access. What about using JDBC?
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Kalle Korhonen <ka...@gmail.com>.
Hibernate has a fine support for executing stored procedures (see e.g.
http://blog.randompage.org/2008/03/stored-procedures-made-easy-with.html).
Probably similar for Spring Security but at least with Tynamo's
tapestry-security module (http://tynamo.org/tapestry-security+guide),
you'd just need to implement a custom realm that uses Hibernate
Session and would happily go about executing your stored procedures.
Kalle
On Sat, Oct 16, 2010 at 6:50 AM, Andrey Gladilin
<an...@gmail.com> wrote:
> Hi guys,
>
> Is there a way to make authentication in Tapestry using store procedure.
> I have several stored procedures in Postgres, like
> login(session_id, username, password, locale)
> logout(session_id)
> get_roles(session_id)
>
> I was trying to use Spring Security, but did not find a way to use
> stored procedures with it.
>
> Could you put me on a proper way?
>
> Thanks.
>
> P.S. Please don't ask me to throw away stored procedures, I can not do it.
>
> --
> С уважением, Гладилин Андрей.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Andrey Gladilin <an...@gmail.com>.
Stupid me. I've been checking the `password.toString()`, but should
have to do `new String(password)`.
My login form is working fine.
Thank you all for help!
On Wed, Oct 20, 2010 at 11:12 PM, Andrey Gladilin
<an...@gmail.com> wrote:
> Seems that this advise does not work for me.
> Look, I implement a realm which calls stored procedure login(username,
> password), which accepts plain text password.
> Code:
>
> public class ProcRealm extends AuthorizingRealm {
> protected DataSource dataSource;
> private static final Logger log = LoggerFactory.getLogger(ProcRealm.class);
>
>
> @Override
> protected AuthenticationInfo
> doGetAuthenticationInfo(AuthenticationToken token)
> throws AuthenticationException {
>
> UsernamePasswordToken upToken = (UsernamePasswordToken) token;
> String username = upToken.getUsername();
> char[] password = upToken.getPassword();
>
> log.info("username=" + username + ", password=" + password);
> ....
> stmt = conn.prepareCall("select api.login('abc', ?, ?, 'en')");
> stmt.setString(1, username);
> stmt.setString(2, password.toString());
>
> stmt.execute();
> ...
>
> I don't use any matcher here. As far as I can understand, matchers are
> used in realms, am I right?
>
> So, how can I get a plain text password here?
> Or how can I decode it?
>
>
> On Wed, Oct 20, 2010 at 11:18 AM, Andrey Gladilin
> <an...@gmail.com> wrote:
>> Thanks Kalle, I will try.
>>
>> I will compare hashes, but a bit later. By now I need the simplest way
>> to make my application up and running.
>>
>>
>> On Wed, Oct 20, 2010 at 10:42 AM, Kalle Korhonen
>> <ka...@gmail.com> wrote:
>>> In your contributeWebSecurityManager(...) simply call:
>>> yourRealm.setCredentialsMatcher(new SimpleCredentialsMatcher());
>>>
>>> But wouldn't you rather want to compare the hashes?
>>>
>>> Kalle
>>>
>>> PS. attachments won't go through
>>>
>>>
>>> On Tue, Oct 19, 2010 at 11:31 PM, Andrey Gladilin
>>> <an...@gmail.com> wrote:
>>>> Thank you all for answeres.
>>>> I have chosen Tynamo-security and implemented a realm. You can find it attached.
>>>> But when I try to login, I receive encrypted password. But I want it
>>>> as plain text.
>>>>
>>>> There are some matchers but I can not get the way how to use it.
>>>> link: http://shiro.apache.org/configuration.html#Configuration-EncryptingPasswords
>>>>
>>>> Could you advise?
>>>> Thanks.
>>>>
>>>>
>>>> On Sun, Oct 17, 2010 at 9:15 AM, ael <al...@dash.com.ph> wrote:
>>>>>
>>>>> In Postgres
>>>>>
>>>>> you can create a function that will return a boolean data type.
>>>>>
>>>>> Then let tapestry decide ^_^.
>>>>> --
>>>>> View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
>>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> С уважением, Гладилин Андрей.
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> С уважением, Гладилин Андрей.
>>
>
>
>
> --
> С уважением, Гладилин Андрей.
>
--
С уважением, Гладилин Андрей.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Andrey Gladilin <an...@gmail.com>.
Seems that this advise does not work for me.
Look, I implement a realm which calls stored procedure login(username,
password), which accepts plain text password.
Code:
public class ProcRealm extends AuthorizingRealm {
protected DataSource dataSource;
private static final Logger log = LoggerFactory.getLogger(ProcRealm.class);
@Override
protected AuthenticationInfo
doGetAuthenticationInfo(AuthenticationToken token)
throws AuthenticationException {
UsernamePasswordToken upToken = (UsernamePasswordToken) token;
String username = upToken.getUsername();
char[] password = upToken.getPassword();
log.info("username=" + username + ", password=" + password);
....
stmt = conn.prepareCall("select api.login('abc', ?, ?, 'en')");
stmt.setString(1, username);
stmt.setString(2, password.toString());
stmt.execute();
...
I don't use any matcher here. As far as I can understand, matchers are
used in realms, am I right?
So, how can I get a plain text password here?
Or how can I decode it?
On Wed, Oct 20, 2010 at 11:18 AM, Andrey Gladilin
<an...@gmail.com> wrote:
> Thanks Kalle, I will try.
>
> I will compare hashes, but a bit later. By now I need the simplest way
> to make my application up and running.
>
>
> On Wed, Oct 20, 2010 at 10:42 AM, Kalle Korhonen
> <ka...@gmail.com> wrote:
>> In your contributeWebSecurityManager(...) simply call:
>> yourRealm.setCredentialsMatcher(new SimpleCredentialsMatcher());
>>
>> But wouldn't you rather want to compare the hashes?
>>
>> Kalle
>>
>> PS. attachments won't go through
>>
>>
>> On Tue, Oct 19, 2010 at 11:31 PM, Andrey Gladilin
>> <an...@gmail.com> wrote:
>>> Thank you all for answeres.
>>> I have chosen Tynamo-security and implemented a realm. You can find it attached.
>>> But when I try to login, I receive encrypted password. But I want it
>>> as plain text.
>>>
>>> There are some matchers but I can not get the way how to use it.
>>> link: http://shiro.apache.org/configuration.html#Configuration-EncryptingPasswords
>>>
>>> Could you advise?
>>> Thanks.
>>>
>>>
>>> On Sun, Oct 17, 2010 at 9:15 AM, ael <al...@dash.com.ph> wrote:
>>>>
>>>> In Postgres
>>>>
>>>> you can create a function that will return a boolean data type.
>>>>
>>>> Then let tapestry decide ^_^.
>>>> --
>>>> View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> С уважением, Гладилин Андрей.
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> С уважением, Гладилин Андрей.
>
--
С уважением, Гладилин Андрей.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Andrey Gladilin <an...@gmail.com>.
Thanks Kalle, I will try.
I will compare hashes, but a bit later. By now I need the simplest way
to make my application up and running.
On Wed, Oct 20, 2010 at 10:42 AM, Kalle Korhonen
<ka...@gmail.com> wrote:
> In your contributeWebSecurityManager(...) simply call:
> yourRealm.setCredentialsMatcher(new SimpleCredentialsMatcher());
>
> But wouldn't you rather want to compare the hashes?
>
> Kalle
>
> PS. attachments won't go through
>
>
> On Tue, Oct 19, 2010 at 11:31 PM, Andrey Gladilin
> <an...@gmail.com> wrote:
>> Thank you all for answeres.
>> I have chosen Tynamo-security and implemented a realm. You can find it attached.
>> But when I try to login, I receive encrypted password. But I want it
>> as plain text.
>>
>> There are some matchers but I can not get the way how to use it.
>> link: http://shiro.apache.org/configuration.html#Configuration-EncryptingPasswords
>>
>> Could you advise?
>> Thanks.
>>
>>
>> On Sun, Oct 17, 2010 at 9:15 AM, ael <al...@dash.com.ph> wrote:
>>>
>>> In Postgres
>>>
>>> you can create a function that will return a boolean data type.
>>>
>>> Then let tapestry decide ^_^.
>>> --
>>> View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>>
>> --
>> С уважением, Гладилин Андрей.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
С уважением, Гладилин Андрей.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Kalle Korhonen <ka...@gmail.com>.
In your contributeWebSecurityManager(...) simply call:
yourRealm.setCredentialsMatcher(new SimpleCredentialsMatcher());
But wouldn't you rather want to compare the hashes?
Kalle
PS. attachments won't go through
On Tue, Oct 19, 2010 at 11:31 PM, Andrey Gladilin
<an...@gmail.com> wrote:
> Thank you all for answeres.
> I have chosen Tynamo-security and implemented a realm. You can find it attached.
> But when I try to login, I receive encrypted password. But I want it
> as plain text.
>
> There are some matchers but I can not get the way how to use it.
> link: http://shiro.apache.org/configuration.html#Configuration-EncryptingPasswords
>
> Could you advise?
> Thanks.
>
>
> On Sun, Oct 17, 2010 at 9:15 AM, ael <al...@dash.com.ph> wrote:
>>
>> In Postgres
>>
>> you can create a function that will return a boolean data type.
>>
>> Then let tapestry decide ^_^.
>> --
>> View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
>
> --
> С уважением, Гладилин Андрей.
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Andrey Gladilin <an...@gmail.com>.
Thank you all for answeres.
I have chosen Tynamo-security and implemented a realm. You can find it attached.
But when I try to login, I receive encrypted password. But I want it
as plain text.
There are some matchers but I can not get the way how to use it.
link: http://shiro.apache.org/configuration.html#Configuration-EncryptingPasswords
Could you advise?
Thanks.
On Sun, Oct 17, 2010 at 9:15 AM, ael <al...@dash.com.ph> wrote:
>
> In Postgres
>
> you can create a function that will return a boolean data type.
>
> Then let tapestry decide ^_^.
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
С уважением, Гладилин Андрей.
Re: login with stored procedure
Posted by ael <al...@dash.com.ph>.
In Postgres
you can create a function that will return a boolean data type.
Then let tapestry decide ^_^.
--
View this message in context: http://tapestry.1045711.n5.nabble.com/login-with-stored-procedure-tp3215112p3215941.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: login with stored procedure
Posted by Chris Poulsen <ma...@nesluop.dk>.
Hi,
On 16-10-2010 15:50, Andrey Gladilin wrote:
> Hi guys,
>
> Is there a way to make authentication in Tapestry using store procedure.
Yes, Tapestry does not care much about how you implement your security.
> I have several stored procedures in Postgres, like
> login(session_id, username, password, locale)
> logout(session_id)
> get_roles(session_id)
>
> I was trying to use Spring Security, but did not find a way to use
> stored procedures with it.
Spring security is highly customizable and does support what you ask,
read the docs and take a look at the jdbc-dao-something sources and
figure out what needs to be overridden/implemented to meet your
requirements.
Spring security may be overly complex for what you need, but you can't
blame tapestry for that.
> Could you put me on a proper way?
> Thanks.
>
> P.S. Please don't ask me to throw away stored procedures, I can not do it.
If you need something really simple, just roll your own auth code and
save some kind of auth-token in your session (@SessionState)
and act on that token some place where it makes sense (in each page,
possibly by sharing it through a base page or maybe in a dispatcher)
Personally I'd probably use some kind of filter based security solution
to keep as much of the security code as possible away from the
application code. (I have used Spring security extensively in several
applications and it is definitely a good candidate, apache shiro does
look very tempting, but I haven't had the time to play with that one yet.)
Sorry for being a little vague on the tapestry side of the things, but I
guess others are much better qualified to help you there.
--
Chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org