Re: WO-Java Client Newbie Question
Des Oates <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.newbies |
|---|---|
| Message-ID | <[email protected]> |
Thanks for these great pointers. It's meant a rethink to my application but I am clearer in how this all works. Hopefully its just a case of working through this framework, and reapplying it to my own app. The framework's source is also a helpful reference well -- Especially since Google returns a whole 2 hits on "JCAuthentication" (One of which is Apple's online docs) Anyway, thanks for taking the time to reply. des_o --- Benjamin J Doherty <[email protected]> wrote: > > On Nov 19, 2004, at 6:29 PM, Des Oates wrote: > > > > > Thanks for the tip. I had already taken a look at > > JCDiscussionBoard, however it wasn't immediately > > obvious to me how its login window was being > > generated. (No nib file in the project, and little > > obvious in the rules file.) However, I'll go back > and > > have a look at it again to see what I can pick up > > there. > > > > If you've any book/tutorial recomendations that > > address these types of Java client/ D2J issues, > then > > I'd be very interested in them. > > > > There is no NIB file because the interface is > rule-driven. So if > you're interested in building D2JC applications, > don't look for NIBs to > inform your knowledge or solve your problems, > because you won't find > them. > > The key to the JCAuthentication framework is to set > up some entities in > your models, an override in your Session class, and > custom classes for > the entities you decide should be involved in the > Authentication > process (usually User and UserDefaults, like the > examples show). What > you need to do is override the Session class with an > > AuthenticationSession. Then you need to tell > AuthenticationSession > where (i.e. which entities) to find User data and > User Defaults data. > I think JCAuthentication.framework is included in > the sample projects > that come with WO (look in the > JavaWebObjects/Frameworks directory) and > it has some documentation. It's not full of > examples, which is why you > should rely on JCRealEstate and JCDiscussionBoard > for examples, but the > documentation tells you the "minimums" that need to > be in place to make > JCAuthentication.framework work for you. > > Just to give you a heads-up, I'll tell you that I > ran into a problem > with the userDefaults setting, because I was > entering the entity name > of the user defaults entity. What it actually wants > is the ATTRIBUTE > (which is a relationship) name from the User entity. > You will also > need to look at the custom code in the User EO > class, because what > JCAuthentication wants to do is create a set of > defaults (window size, > positions, and maybe more) when the user logs in. > The code for that > will be in the User class of the SERVER-SIDE EO > classes on the sample > apps. > > Also remember that you need to make > JCAuthentication.framework part of > BOTH the Application Server and Web-Server targets. > (Or If I have my > name wrong, what I mean is "both targets.") > JCAuthentication has code > that runs on the server and on the client. > > I can't say it enough: JCAuthentication is REALLY > WORTH IT. I was a > little annoyed when I was reading the Apple Desktop > Applications book > to see them tell me how to set up a login window > only to see them say > "there's a better way that you should use but we're > not going to tell > you how to use it, so look at the examples." I bet > you could easily > get it to work with LDAP too, which Chuck Hill's > book will help you > with when you're ready for it. > > Here's my example, which is about as BASIC and > SIMPLE and no frills as > you can get. I don't have any roles, because this > application is used > by 5 people who all trust each other, but it is > something I will use > one day, so you should figure it out. Also, all > role-based privileges > and restrictions are determined by the rule system, > so you're gonna > have to be ready for that. But like I said, it's SO > WORTH IT. It's > the only ready-to-go JC login and privileges > framework out there. > Project Wonder doesn't support D2JC or JC very > wellif at allso you > won't find their ostensibly very capable frameworks > to be helpful for > you. > > // > // Session.java > // Project lpcis > // > // Created by bjd on Tue Apr 06 2004 > // > > import com.webobjects.foundation.*; > import com.webobjects.appserver.*; > import com.webobjects.eocontrol.*; > import com.webobjects.eoaccess.*; > import webobjectsexamples.authentication.*; > import org.bangpound.lpcis.server.*; > > public class Session extends AuthenticationSession { > > public Session() { > super(); > } > > protected String userEntityName() { > return "User"; > } > > protected String userNameKey() { > return "login"; > } > > protected String userPasswordKey() { > return "password"; > } > > protected String userRole(EOEditingContext > userEditingContext, > EOEnterpriseObject user) { > return user.entityName(); > } > > protected EOEnterpriseObject > newUserWithRole(EOEditingContext > editingContext, String role) { > return > EOUtilities.createAndInsertInstance(editingContext, > role); > } > > protected EOEnterpriseObject > userDefaultsObject(EOEditingContext > userEditingContext, EOEnterpriseObject user, boolean > createIfNecessary) > { > return (createIfNecessary) ? > ((User)user).mainDefaultsGuaranteed() : > ((User)user).mainDefaults(); > } > > protected String userDefaultsKey() { > return "userDefaults"; > } > > public NSArray registrationRoles() { > return new NSArray(new Object[] {"User"}); > } > > public NSArray registrationAdditionalKeys() { > return new NSArray(new Object[] {}); > } > } > > > > ------------------------ Yahoo! Groups Sponsor > --------------------~--> > Make a clean sweep of pop-up ads. Yahoo! Companion > Toolbar. > Now with Pop-Up Blocker. Get it for free! > http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/nhFolB/TM > --------------------------------------------------------------------~-> > > > > Yahoo! Groups Links > > http://groups.yahoo.com/group/webobjects-newbies/ > > === message truncated === __________________________________ Do you Yahoo!? Meet the all-new My Yahoo! - Try it today! http://my.yahoo.com ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/nhFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/webobjects-newbies/ <*> To unsubscribe from this group, send an email to: [email protected] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/