KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ldap > server > jndi > AbstractMultiUserJndiTest


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package org.apache.ldap.server.jndi;
18
19
20 import org.apache.ldap.server.AbstractCoreTest;
21
22 import javax.naming.Context JavaDoc;
23 import javax.naming.InitialContext JavaDoc;
24 import java.util.Hashtable JavaDoc;
25
26
27 /**
28  * Adds extra code to perform operations as another user besides the admin user.
29  *
30  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
31  * @version $Rev: 169198 $
32  */

33 public abstract class AbstractMultiUserJndiTest extends AbstractCoreTest
34 {
35     protected ServerLdapContext sysRootAsNonAdminUser;
36
37
38     /**
39      * Set's up a context for an authenticated non-root user.
40      *
41      * @see org.apache.ldap.server.AbstractCoreTest#setUp()
42      */

43     protected void setUp() throws Exception JavaDoc
44     {
45         // bring the system up
46

47         super.setUp();
48
49         // authenticate as akarasulu
50

51         Hashtable JavaDoc env = new Hashtable JavaDoc( );
52
53         env.put( Context.PROVIDER_URL, "ou=system" );
54
55         env.put( Context.INITIAL_CONTEXT_FACTORY, "org.apache.ldap.server.jndi.CoreContextFactory" );
56
57         env.put( Context.SECURITY_PRINCIPAL, "uid=akarasulu,ou=users,ou=system" );
58
59         env.put( Context.SECURITY_CREDENTIALS, "test" );
60
61         InitialContext JavaDoc ictx = new InitialContext JavaDoc( env );
62
63         sysRootAsNonAdminUser = ( ServerLdapContext ) ictx.lookup( "" );
64     }
65
66
67     protected void tearDown() throws Exception JavaDoc
68     {
69         super.tearDown();
70
71         sysRootAsNonAdminUser = null;
72     }
73 }
74
Popular Tags