Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 345835 - Provide a user manager that knows about its repository
Summary: Provide a user manager that knows about its repository
Status: CLOSED FIXED
Alias: None
Product: EMF
Classification: Modeling
Component: cdo.core (show other bugs)
Version: 4.0   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Eike Stepper CLA
QA Contact: Eike Stepper CLA
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2011-05-15 05:23 EDT by Eike Stepper CLA
Modified: 2011-06-23 03:40 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eike Stepper CLA 2011-05-15 05:23:00 EDT
The default implementations of IUserManager currently shipped do not know about their context. In other words, they're like singletons in their IManagedContainer.

An IElementProcessor can be used to inject an IRepository into the user manager...
Comment 1 Eike Stepper CLA 2011-05-15 06:51:14 EDT
You'll need to create your custom RepositoryUserManager and a respective custom RepositoryUserManagerFactory, e.g.:

    public class TestRepositoryUserManager extends RepositoryUserManager
    {
      @Override
      protected char[] getPassword(IRepository repository, String userID)
      {
        System.out.println(userID + " --> " + repository.getName());
        return "12345".toCharArray(); // TODO Retrieve the password from the repository
      }
    
      public static class Factory extends RepositoryUserManagerFactory
      {
        public Factory()
        {
          super("TestRepository"); // Must match the type attribute in plugin.xml
        }
    
        @Override
        protected RepositoryUserManager doCreate(String description) throws ProductCreationException
        {
          return new TestRepositoryUserManager();
        }
      }
    }

Then you register this factory in your plugin.xml:

		<extension point="org.eclipse.net4j.util.factories">
      	<factory
            productGroup="org.eclipse.net4j.userManagers"
            type="TestRepository"
            class="com.foo.bar.TestRepositoryUserManager$Factory"/>
   	</extension>

Then you can use this markup in your cdo-server.xml:

  	<repository name="repo1">
				<userManager type="TestRepository" description="repo1"/>
				...
Comment 2 Eike Stepper CLA 2011-05-15 06:54:09 EDT
Committed revision 7722
Comment 3 Eike Stepper CLA 2011-06-23 03:40:50 EDT
Available in R20110608-1407