You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Segura <Se...@yandex.ru> on 2013/01/27 16:58:03 UTC
Call Tynamo's SimpleAccountRealm's methods
Hello.
Trying to configurate Tapestry-Security.
Added into my AppModule
@Contribute(WebSecurityManager.class)
public static void addRealms(Configuration<Realm> configuration) {
SimpleAccountRealm realm = new SimpleAccountRealm();
configuration.add(realm);
}
But i cant understand how to call SimpleAccountRealm's methods (addAccount,
getUsername, etc). I need registration form. Is it possible?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578.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: Call Tynamo's SimpleAccountRealm's methods
Posted by Kalle Korhonen <ka...@gmail.com>.
If you make your Realm a service, then yes, absolutely.
Kalle
On Sun, Jan 27, 2013 at 8:49 AM, Segura <Se...@yandex.ru> wrote:
> Yes, i know it. And i read all of
> http://tynamo.org/tapestry-security+guide
> <http://tynamo.org/tapestry-security+guide> , but have not found a
> Realm's
> method call.
> I thought that it is like working with the hibernate session:
>
> @Inject
> private MyRealm realm;
> ...
> void foo()
> {
> realm.addAccount(name, password);
> realm.deleteAccount(name);
> etc...
> }
>
> Is my thinking correct?
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578p5719583.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: Call Tynamo's SimpleAccountRealm's methods
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Mon, 28 Jan 2013 09:58:07 -0200, Segura <Se...@yandex.ru> wrote:
> @Contribute(WebSecurityManager.class)
> public static void addRealms(Configuration<Realm> configuration) {
> AccountRealmImpl realm = new AccountRealmImpl();
> configuration.add(realm);
> }
It doesn't make any sense to to instantiate AccountRealmImpl directly if
it's was configured as a service already. Do this instead:
@Contribute(WebSecurityManager.class)
public static void addRealms(Configuration<Realm> configuration,
AccountRealm realm) {
configuration.add(realm);
}
This probably wasn't the source of your problem, but at least your code
will be better written.
> but code
>
> @Inject
> private AccountRealm realm;
>
> void onActivate() {
> realm.addAccount("User", "123");
> }
>
> throws "No service implements the interface java.lang.String". Whats
> wrong in my code?
Full stack trace please. I don't think this error is related to code
above. It seems you put @Inject in a String field.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Call Tynamo's SimpleAccountRealm's methods
Posted by Segura <Se...@yandex.ru>.
Kalle, really useful tip. But...
I wrote simple interface
public interface AccountRealm {
void addAccount(String username, String password);
boolean accountExists(String username);
}
and changed my realm description to
public class AccountRealmImpl extends AuthorizingRealm implements
AccountRealm
changed to AppModule
public static void bind(ServiceBinder binder)
{
binder.bind(AccountRealm.class, AccountRealmImpl.class);
}
@Contribute(WebSecurityManager.class)
public static void addRealms(Configuration<Realm> configuration) {
AccountRealmImpl realm = new AccountRealmImpl();
configuration.add(realm);
}
but code
@Inject
private AccountRealm realm;
void onActivate() {
realm.addAccount("User", "123");
}
throws "No service implements the interface java.lang.String". Whats wrong
in my code?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578p5719608.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: Call Tynamo's SimpleAccountRealm's methods
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
Also, remember that tynamo-security is just a front end to Apache Shiro. You need to understand how it works before you can fully understand the concepts here. They have great documentation and sample code.
On Jan 27, 2013, at 11:49 AM, Segura <Se...@yandex.ru> wrote:
> Yes, i know it. And i read all of http://tynamo.org/tapestry-security+guide
> <http://tynamo.org/tapestry-security+guide> , but have not found a Realm's
> method call.
> I thought that it is like working with the hibernate session:
>
> @Inject
> private MyRealm realm;
> ...
> void foo()
> {
> realm.addAccount(name, password);
> realm.deleteAccount(name);
> etc...
> }
>
> Is my thinking correct?
>
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578p5719583.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
Re: Call Tynamo's SimpleAccountRealm's methods
Posted by Segura <Se...@yandex.ru>.
Yes, i know it. And i read all of http://tynamo.org/tapestry-security+guide
<http://tynamo.org/tapestry-security+guide> , but have not found a Realm's
method call.
I thought that it is like working with the hibernate session:
@Inject
private MyRealm realm;
...
void foo()
{
realm.addAccount(name, password);
realm.deleteAccount(name);
etc...
}
Is my thinking correct?
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578p5719583.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: Call Tynamo's SimpleAccountRealm's methods
Posted by Kalle Korhonen <ka...@gmail.com>.
SimpleAccountRealm is an in-memory realm (
http://shiro.apache.org/static/current/apidocs/org/apache/shiro/realm/SimpleAccountRealm.html).
It's great for sample and automated testing applications where you don't
have a database but not meant for production applications. You'd typically
create the users at the time you are creating your realm.
For production applications, you typically create your own persistent user
model (e.g. a Hibernate/JPA User entity), a registration form like any
other Tapestry page and then implement a custom realm that reads from the
database using your entity. http://tynamo.org/tapestry-security+guide has
many links to sample code.
Kalle
On Sun, Jan 27, 2013 at 7:58 AM, Segura <Se...@yandex.ru> wrote:
> Hello.
> Trying to configurate Tapestry-Security.
> Added into my AppModule
>
> @Contribute(WebSecurityManager.class)
> public static void addRealms(Configuration<Realm> configuration) {
> SimpleAccountRealm realm = new SimpleAccountRealm();
> configuration.add(realm);
> }
>
> But i cant understand how to call SimpleAccountRealm's methods (addAccount,
> getUsername, etc). I need registration form. Is it possible?
>
>
>
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Call-Tynamo-s-SimpleAccountRealm-s-methods-tp5719578.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
>
>