View Javadoc

1   // 
2   //Copyright (c) 2003, Caltha - Gajda, Krzewski, Mach, Potempski Sp.J. 
3   //All rights reserved. 
4   //   
5   //Redistribution and use in source and binary forms, with or without modification,  
6   //are permitted provided that the following conditions are met: 
7   //   
8   //* Redistributions of source code must retain the above copyright notice,  
9   //this list of conditions and the following disclaimer. 
10  //* Redistributions in binary form must reproduce the above copyright notice,  
11  //this list of conditions and the following disclaimer in the documentation  
12  //and/or other materials provided with the distribution. 
13  //* Neither the name of the Caltha - Gajda, Krzewski, Mach, Potempski Sp.J.  
14  //nor the names of its contributors may be used to endorse or promote products  
15  //derived from this software without specific prior written permission. 
16  // 
17  //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"  
18  //AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED  
19  //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 
20  //IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,  
21  //INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,  
22  //BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 
23  //OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,  
24  //WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)  
25  //ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE  
26  //POSSIBILITY OF SUCH DAMAGE. 
27  //
28  
29  package org.objectledge.authentication;
30  
31  import java.security.Principal;
32  import java.util.Map;
33  
34  import javax.naming.NamingException;
35  import javax.naming.directory.DirContext;
36  import javax.naming.directory.SearchControls;
37  
38  import org.jcontainer.dna.Logger;
39  import org.objectledge.naming.ContextHelper;
40  
41  /**
42   * The dummy user manager implementation.
43   * 
44   * @author <a href="mailto:pablo@caltha.pl">Pawel Potempski</a>
45   */
46  public class DummyUserManager extends UserManager
47  {
48      /***
49       * Creates an instance of the user manager.
50       */
51      public DummyUserManager()
52      {
53      }
54  
55      /*** 
56       * {@inheritDoc}
57       */
58      public boolean userExists(String dn)
59      {
60          return true;
61      }
62  
63      /***
64       * {@inheritDoc}
65       */
66      public Principal createAccount(String login, String dn, String password) 
67          throws AuthenticationException
68      {
69          throw new UnsupportedOperationException("Dummy manager cannot create new account");
70      }
71  
72      /***
73       * {@inheritDoc}
74       */
75      public void removeAccount(Principal account) throws AuthenticationException
76      {
77          throw new UnsupportedOperationException("Dummy manager cannot create new account");    
78      }
79  
80      /***
81       * {@inheritDoc}
82       */
83      public Principal getUserByName(String dn) throws AuthenticationException
84      {
85          return new DefaultPrincipal(dn);
86      }
87  
88      /***
89       * {@inheritDoc}
90       */
91      public Principal getUserByLogin(String login) throws AuthenticationException
92      {
93          return new DefaultPrincipal(login);                           
94      }
95  
96      /***
97       * {@inheritDoc}
98       */
99      public Principal getAnonymousAccount() throws AuthenticationException
100     {
101         return new DefaultPrincipal("anonymous");
102     }
103 
104     /***
105      * {@inheritDoc}
106      */
107     public Principal getSuperuserAccount() throws AuthenticationException
108     {
109         return null;
110     }
111 
112     /***
113      * {@inheritDoc}
114      */
115     public void changeUserPassword(Principal account, String password) 
116         throws AuthenticationException
117     {
118         throw new UnsupportedOperationException("Dummy manager cannot change user password");
119     }
120 
121     /***
122      * {@inheritDoc}
123      */
124     public boolean checkUserPassword(Principal account, String password)
125         throws AuthenticationException
126     {
127         return true;
128     }
129 
130     /***
131      * {@inheritDoc}
132      */
133     public DirContext getPersonalData(Principal account) throws AuthenticationException
134     {
135         return null;
136     }
137 
138     /***
139      * {@inheritDoc}
140      */
141     public Principal[] lookupAccounts(String attribute, String value) throws NamingException
142     {
143         throw new UnsupportedOperationException("Dummy manager cannot lookup accounts");
144     }
145 
146     /***
147      * {@inheritDoc}
148      */
149     public Principal[] lookupAccounts(String query) throws NamingException
150     {
151         throw new UnsupportedOperationException("Dummy manager cannot lookup accounts");
152     }
153 }