[daisy] Get RepositoryManager from ServiceManager fails
Mindaugas Idzelis
idzelis at us.ibm.com
Thu Aug 2 08:33:20 CDT 2007
I do this (update roles during user login.) and I hit the same issue you
did. What I did was instead of using an AuthenticationScheme, I replaced
the whole UserAuthenticator. The authenticator has a new method called
"update" with a parameters "UserManager" and "Credentials" that gets
passed to the scheme right after a succesful credentical check. It can
update the user with whatever roles it wants.
Gotchas that I've seen. If the Authenticator changes the role of a user
that's currently logged on, they will experience some errors. (If they
were currently editing a document, they might have access to it anymore,
etc, etc) I see no way around this though.
Thanks,
Mindaugas Idzelis
daisy-bounces at lists.cocoondev.org wrote on 08/02/2007 04:54:04 AM:
> On Wed, 2007-08-01 at 12:55 -0400, Kevin wrote:
> > Hi,
> >
> > On 8/1/07, Bruno Dumon <bruno at outerthought.org> wrote:
> > >
> > > I'm wondering why you need access to the UserManager?
> >
> > I want to (potentially) update roles if certain conditions have
> > changed since last login (in the check(Credentials) method).
> >
> > >
> > > As for getting access to the repository manager, you can only get
access
> > > to components for which you declared a dependency, e.g. like this:
> > >
> > > @avalon.dependency key="repository-manager" type="org.outerj.
> daisy.repository.RepositoryManager"
> > >
> >
> > Where do I declare this? I decorated my AuthenticationSchemeFactory
> > service method, but it threw the same exception:
> >
> > /**
> > * @avalon.dependency key="auth-scheme-registrar"
> > *
> > type="org.outerj.daisy.authentication.AuthenticationSchemeRegistrar"
> > * @avalon.dependency key="repository-manager"
> > * type="org.outerj.daisy.repository.
> RepositoryManager"
> > */
> > public void service(ServiceManager serviceManager) throws
> ServiceException {
> > super.service(serviceManager);
> >
> > this.serviceManager = serviceManager;
> >
> > Repository result = getRepository(serviceManager);
> > RepositoryManager repositoryManager = null;
> > try {
> > repositoryManager = (RepositoryManager) serviceManager
> > .lookup("repository-manager");
> > result = repositoryManager.getRepository(new Credentials(
> > "registrar", "defaultpwd"));
> > } catch (RepositoryException e) {
> > e.printStackTrace();
> > } finally {
> > if (repositoryManager != null)
> > serviceManager.release(repositoryManager);
> > }
> > System.out.println("DEBUG: " + result);
> > }
> >
> > I also tried adding
> >
> > <dependency key="repository-manager"
> > type="org.outerj.daisy.repository.RepositoryManager"/>
> >
> > To my .xinfo file in my JAR that contains the AuthenticationScheme,
>
> This is a good way to do this. This .xinfo file can be generated from
> the javadoc annotations, but that depends on your build setup.
>
> > and the repository startup froze (I did a Ctrl-Break to get the thread
> > dump in case you want to check to see why an invalid .xinfo file
> > freezes the startup).
>
> Ah yes, I didn't think of this: by introducing this dependency there's a
> circular dependency between the repository manager and the
> authenticator. So it's impossible to do it this way, so I see no
> solution without modifying Daisy sources.
>
> Your use case seems valid to me, though I would keep the check() method
> free from side-effects. Maybe we can add an updateUser() method to the
> AuthenticationScheme interface to support this need.
>
> Feel free to create a jira issue for this (and a patch against trunk is
> welcome too of course).
>
> --
> Bruno Dumon http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno at outerthought.org bruno at apache.org
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support: http://outerthought.
> org/site/services/daisy/daisysupport.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cocoondev.org/pipermail/daisy/attachments/20070802/79b75830/attachment.htm
More information about the daisy
mailing list