Jeremy,

This is one of those long list of tutorials I have promised myself to
write (oh... yearning for that 25 hour day ;P)

1) Can someone point me in the right direction, either with an example or
document, on how to use the database as a backend for users?

It's actually quite simple; the relevant part in java would look
something like (in this case i'm getting my beans from submissions):

       Account ac = getSubmissionBean(Account.class);
       RoleUser user = getSubmissionBean(RoleUser.class);

       if (Utils.validate(user, ac)) {
           Datasource ds = (Datasource) getProperty(DATASOURCE);
           DatabaseUsers users = DatabaseUsersFactory.getInstance(ds);

           ContentQueryManager<Account> accounts = new
ContentQueryManager<Account>(ds, Account.class);

           try {
               users.addUser(user.getLogin(), new
RoleUserAttributes(user.getPassword(), new String[] { "user" }));

               ac.setUserId(users.getUserId(user.getLogin()));
               accounts.save(ac);

               //tt.setBlock("form", "sucess");
               // forces login (TODO: autologin)
               exit(HOME);
           } catch (CredentialsManagerException e) {
Logger.getLogger("friends").severe(ExceptionUtils.getExceptionStackTrace(e));
           }

So the only class I have to personally implement in this case is my
custom Account class; the DatabaseUsers and related classes are
provided by the rife authentication toolkit.

2) Can someone explain to me the necessary components of implementing
authentication/authorization in RIFE?

Generally, for auth'ing, you create an Element declaration that
extends the authenticated database.xml file, and then supply values to
certain properties/params it offers. For instance, I have a "User"
element as:

                <element id="User" extends="rife/authenticated/database.xml">
                        <property 
name="datasource"><datasource>derby</datasource></property>
                        <property name="password_encryption">SHA</property>
                        <property name="template_name">global.Login</property>
                        <property name="submission_name">authenticate</property>
                        <property name="authvar_type">cookie</property>   
                        <property name="role">user</property>
                        
                        <exit name="Register" />                        
                        <flowlink srcexit="Register" destid="global.Register"/>
                        
                        <submission name="authenticate">
                                <param name="login" />
                                <param name="password" />
                                <param name="remember" />
                        </submission>
                        
                        <incookie  name="rememberid" />
                        <outcookie name="rememberid" />
                        
                        <childtrigger name="authid" />
                </element>

Then further down in my site declaration, I have an element which
leads to a subsite that looks like:

<subsite id="user" inherits="User"  file="user.xml" urlprefix="/user" />

In user, I have an element like:

        <element id="Home" implementation="friends.elements.user.Home" 
url="home">
                
                <property name="template">user.Home</property>

                <exit name="Profile" />
                <exit name="EditProfile"/>
                <exit name="Settings"/>
                <exit name="Friends"/>
                <exit name="Invite"/>
                <exit name="Mailbox"/>
                <exit name="Search"/>
                <exit name="Logout"/>
                
                
                <flowlink srcexit="Profile" destid="Profile"/>
                <flowlink srcexit="EditProfile" destid="EditProfile"/>
                <flowlink srcexit="Settings" destid="Settings"/>
                <flowlink srcexit="Friends" destid="Friends"/>                
                <flowlink srcexit="Invite" destid="Invite"/>          
                <flowlink srcexit="Logout" destid="Logout"/>


                <submission name="invite">
                </submission>
                
                <submission name="search">
                </submission>
        </element>

The "User" element (which extends the authenticated database.xml file)
works almost like a "tag"; When a user accesses a url which leads to
any element in my user subsite, say /user/home (effectively an element
that inherits from the User element, which in turn extends
database.xml), the visitor is forced to login (if they are not already
authenticated); the "template_name" property in the "User" declaration
is what would point to your "login" form/page. In addition to that,
you have a "submission_name" property which you map to the submission
that would deliver your login, password, and remember parameters. All
you have to do is design your template and have the right input names
for the parameters set; everything else is handled by the
authentication toolkit.

I think the links to the guides you provided do a good job on
childtriggers and how they tie in with all this.

HTH.

cheers,
Emmanuel


On 5/10/06, Jeremy Whitlock <[EMAIL PROTECTED]> wrote:
Hey all,
     I have been going through the following to properly implement
authentication/authorization in RIFE:

http://rifers.org/wiki/display/RIFE/Authentication
http://rifers.org/wiki/display/RIFE/GuideAuthentication
http://rifers.org/docs/usersguide/ch08.html (For some
reason, this url isn't working today)

My first problem I ran into is that I have not found the guide/example on
how to do this with the users being stored in a database.  The second is
that none of the documentation really explain the necessary components and
their explanation.  So what do I need?

1) Can someone point me in the right direction, either with an example or
document, on how to use the database as a backend for users?
2) Can someone explain to me the necessary components of implementing
authentication/authorization in RIFE?

Thanks for humoring me,

Jeremy

_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users





--
Benjamin Disraeli - "Nurture your minds with great thoughts. To
believe in the heroic makes heroes."
_______________________________________________
Rife-users mailing list
Rife-users@uwyn.com
http://lists.uwyn.com/mailman/listinfo/rife-users

Reply via email to