Commits

Anonymous committed ab44537

Convert UserManager.Accessor to implement an interface (ProviderAccessor). USER-83

Comments (0)

Files changed (5)

src/java/com/opensymphony/user/Entity.java

  * to write data before then.</p>
  *
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
- * @version $Revision: 1.1.1.1 $
+ * @version $Revision: 1.2 $
  */
 public abstract class Entity implements Serializable {
     //~ Instance fields ////////////////////////////////////////////////////////
      * Whether this entity is mutable (i.e. can be modifed).
      */
     protected boolean mutable;
-    private UserManager.Accessor managerAccessor;
+    private ProviderAccessor providerAccessor;
 
     //~ Constructors ///////////////////////////////////////////////////////////
 
      * Constructor to be called by User or Group. Should pass across name of Entity
      * and UserManager.Accessor for priveleged access to the UserManager.
      */
-    protected Entity(String name, UserManager.Accessor managerAccessor) {
+    protected Entity(String name, ProviderAccessor providerAccessor) {
         this.name = name;
-        this.managerAccessor = managerAccessor;
+        this.providerAccessor = providerAccessor;
     }
 
     //~ Methods ////////////////////////////////////////////////////////////////
      * Retrieve pluggable CredentialsProvider for this entity.
      */
     public CredentialsProvider getCredentialsProvider() {
-        return managerAccessor.getCredentialsProvider(name);
+        return providerAccessor.getCredentialsProvider(name);
     }
 
     /**
      * Retrieve pluggable ProfileProvider for this entity.
      */
     public ProfileProvider getProfileProvider() {
-        return managerAccessor.getProfileProvider(name);
+        return providerAccessor.getProfileProvider(name);
     }
 
     /**
      * Retrieve pluggable AccessProvider for this entity.
      */
     public AccessProvider getAccessProvider() {
-        return managerAccessor.getAccessProvider(name);
+        return providerAccessor.getAccessProvider(name);
     }
 
     /**
      * Retrieve underlying UserManager that this User is handled by.
      */
     public UserManager getUserManager() {
-        return managerAccessor.getUserManager();
+        return providerAccessor.getUserManager();
     }
 
     /**

src/java/com/opensymphony/user/Group.java

  * <p>Refer to Entity for more information.</p>
  *
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  *
  * @see com.opensymphony.user.Entity
  */
     /**
     * Constructor is only called by UserManager.
     */
-    Group(String name, UserManager.Accessor managerAccessor) {
-        super(name, managerAccessor);
+    public Group(String name, ProviderAccessor providerAccessor) {
+        super(name, providerAccessor);
         this.accessor = new Accessor();
         getAccessProvider().load(name, accessor);
     }

src/java/com/opensymphony/user/ProviderAccessor.java

+/*
+ * Copyright (c) 2002-2003 by OpenSymphony
+ * All rights reserved.
+ */
+package com.opensymphony.user;
+
+import com.opensymphony.user.provider.AccessProvider;
+import com.opensymphony.user.provider.CredentialsProvider;
+import com.opensymphony.user.provider.ProfileProvider;
+
+import java.io.Serializable;
+
+
+/**
+ * DOCUMENT ME!
+ *
+ * @author $author$
+ * @version $Revision: 1.1 $
+ */
+public interface ProviderAccessor extends Serializable {
+    //~ Methods ////////////////////////////////////////////////////////////////
+
+    public UserManager getUserManager();
+
+    /**
+     * Return appropriate AccessProvider for entity.
+     */
+    AccessProvider getAccessProvider(String name);
+
+    /**
+     * Return appropriate CredentialsProvider for entity.
+     */
+    CredentialsProvider getCredentialsProvider(String name);
+
+    /**
+     * Return appropriate ProfileProvider for entity.
+     */
+    ProfileProvider getProfileProvider(String name);
+}

src/java/com/opensymphony/user/User.java

  * <p>Refer to Entity for more information.</p>
  *
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
  *
  * @see com.opensymphony.user.Entity
  */
     /**
     * Constructor is only called by UserManager.
     */
-    User(String name, UserManager.Accessor managerAccessor) {
-        super(name, managerAccessor);
+    public User(String name, ProviderAccessor providerAccessor) {
+        super(name, providerAccessor);
         this.accessor = new Accessor();
         getCredentialsProvider().load(name, accessor);
     }

src/java/com/opensymphony/user/UserManager.java

         return buildEntity(name, provider, type);
     }
 
-    private UserProvider getProvider(String name, List providers) {
+    protected UserProvider getProvider(String name, List providers) {
         // @todo: This method is called often. Cache the results of the iteration.
         for (Iterator i = providers.iterator(); i.hasNext();) {
             UserProvider provider = (UserProvider) i.next();
      * UserManager.Accessor is a gateway that can be passed from the UserManager
      * to any other object that allows priveleged callbacks.
      */
-    public class Accessor implements Serializable {
+    public class Accessor implements ProviderAccessor {
         /**
          * Return appropriate AccessProvider for entity.
          */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.