KickJava   Java API By Example, From Geeks To Geeks.

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


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.common.NotImplementedException;
21 import org.apache.ldap.server.PartitionNexus;
22 import org.apache.ldap.server.authn.LdapPrincipal;
23
24 import javax.naming.Name JavaDoc;
25 import javax.naming.NamingException JavaDoc;
26 import javax.naming.ldap.Control JavaDoc;
27 import javax.naming.ldap.ExtendedRequest JavaDoc;
28 import javax.naming.ldap.ExtendedResponse JavaDoc;
29 import javax.naming.ldap.LdapContext JavaDoc;
30 import java.util.Hashtable JavaDoc;
31
32
33 /**
34  * An Eve implementation of a JNDI LdapContext.
35  *
36  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
37  * @version $Rev: 169198 $
38  */

39 public class ServerLdapContext extends ServerDirContext implements LdapContext JavaDoc
40 {
41     private static final Control JavaDoc[] EMPTY_CONTROLS = new Control JavaDoc[0];
42     private Control JavaDoc[] requestControls = EMPTY_CONTROLS;
43     private Control JavaDoc[] responseControls = EMPTY_CONTROLS;
44     private Control JavaDoc[] connectControls = EMPTY_CONTROLS;
45
46
47     /**
48      * Creates an instance of an ServerLdapContext.
49      *
50      * @param nexusProxy the proxy to a partition nexus
51      * @param env the JNDI environment parameters
52      * @throws NamingException the context cannot be created
53      */

54     public ServerLdapContext( PartitionNexus nexusProxy, Hashtable JavaDoc env ) throws NamingException JavaDoc
55     {
56         super( nexusProxy, env );
57     }
58
59
60     /**
61      * Creates a new ServerDirContext with a distinguished name which is used to
62      * set the PROVIDER_URL to the distinguished name for this context.
63      *
64      * @param principal the directory user principal that is propagated
65      * @param nexusProxy the intercepting proxy to the nexus
66      * @param env the environment properties used by this context
67      * @param dn the distinguished name of this context
68      */

69     ServerLdapContext( LdapPrincipal principal, PartitionNexus nexusProxy, Hashtable JavaDoc env, Name JavaDoc dn )
70     {
71         super( principal, nexusProxy, env, dn );
72     }
73
74
75     /**
76      * @see javax.naming.ldap.LdapContext#extendedOperation(
77      * javax.naming.ldap.ExtendedRequest)
78      */

79     public ExtendedResponse JavaDoc extendedOperation( ExtendedRequest JavaDoc request )
80     {
81         throw new NotImplementedException();
82     }
83
84
85     /**
86      * @see javax.naming.ldap.LdapContext#newInstance(
87      * javax.naming.ldap.Control[])
88      */

89     public LdapContext JavaDoc newInstance( Control JavaDoc[] requestControls )
90         throws NamingException JavaDoc
91     {
92         ServerLdapContext ctx = new ServerLdapContext( getPrincipal(), getNexusProxy(),
93                 getEnvironment(), getDn() );
94         ctx.setRequestControls( requestControls );
95         return ctx;
96     }
97
98
99     /**
100      * @see javax.naming.ldap.LdapContext#reconnect(javax.naming.ldap.Control[])
101      */

102     public void reconnect( Control JavaDoc[] connCtls ) throws NamingException JavaDoc
103     {
104         this.connectControls = connCtls;
105     }
106
107
108     /**
109      * @see javax.naming.ldap.LdapContext#getConnectControls()
110      */

111     public Control JavaDoc[] getConnectControls() throws NamingException JavaDoc
112     {
113         return this.connectControls;
114     }
115
116
117     /**
118      * @see javax.naming.ldap.LdapContext#setRequestControls(
119      * javax.naming.ldap.Control[])
120      */

121     public void setRequestControls( Control JavaDoc[] requestControls )
122         throws NamingException JavaDoc
123     {
124         this.requestControls = requestControls;
125     }
126
127
128     /**
129      * @see javax.naming.ldap.LdapContext#getRequestControls()
130      */

131     public Control JavaDoc[] getRequestControls() throws NamingException JavaDoc
132     {
133         return requestControls;
134     }
135
136
137     /**
138      * @see javax.naming.ldap.LdapContext#getResponseControls()
139      */

140     public Control JavaDoc[] getResponseControls() throws NamingException JavaDoc
141     {
142         return responseControls;
143     }
144 }
145
Popular Tags