1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ldap.server.interceptor;
18
19
20 import java.util.Iterator;
21 import java.util.Map;
22
23 import javax.naming.Context;
24 import javax.naming.Name;
25 import javax.naming.NamingEnumeration;
26 import javax.naming.NamingException;
27 import javax.naming.directory.Attributes;
28 import javax.naming.directory.ModificationItem;
29 import javax.naming.directory.SearchControls;
30 import javax.naming.ldap.LdapContext;
31
32 import org.apache.ldap.common.filter.ExprNode;
33 import org.apache.ldap.server.authn.LdapPrincipal;
34 import org.apache.ldap.server.configuration.InterceptorConfiguration;
35 import org.apache.ldap.server.invocation.InvocationStack;
36 import org.apache.ldap.server.jndi.ContextFactoryConfiguration;
37 import org.apache.ldap.server.jndi.ServerContext;
38
39
40 /***
41 * A easy-to-use implementation of {@link Interceptor}. All methods are
42 * implemented to pass the flow of control to next interceptor by defaults.
43 * Please override the methods you have concern in.
44 *
45 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
46 * @version $Rev: 226451 $, $Date: 2005-07-29 20:54:58 -0400 (Fri, 29 Jul 2005) $
47 */
48 public abstract class BaseInterceptor implements Interceptor
49 {
50 /***
51 * Returns {@link LdapPrincipal} of current context.
52 */
53 public static LdapPrincipal getPrincipal()
54 {
55 ServerContext ctx = ( ServerContext ) getContext();
56 return ctx.getPrincipal();
57 }
58
59 /***
60 * Returns the current JNDI {@link Context}.
61 */
62 public static LdapContext getContext()
63 {
64 return ( LdapContext ) InvocationStack.getInstance().peek().getCaller();
65 }
66
67
68 /***
69 * Creates a new instance.
70 */
71 protected BaseInterceptor()
72 {
73 }
74
75
76 /***
77 * This method does nothing by default.
78 */
79 public void init( ContextFactoryConfiguration factoryCfg, InterceptorConfiguration cfg ) throws NamingException
80 {
81 }
82
83
84 /***
85 * This method does nothing by default.
86 */
87 public void destroy()
88 {
89 }
90
91
92
93
94
95
96 public void add( NextInterceptor next, String upName, Name normName, Attributes entry ) throws NamingException
97 {
98 next.add( upName, normName, entry );
99 }
100
101
102 public void delete( NextInterceptor next, Name name ) throws NamingException
103 {
104 next.delete( name );
105 }
106
107
108 public Name getMatchedName( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
109 {
110 return next.getMatchedName( dn, normalized );
111 }
112
113
114 public Attributes getRootDSE( NextInterceptor next ) throws NamingException
115 {
116 return next.getRootDSE();
117 }
118
119
120 public Name getSuffix( NextInterceptor next, Name dn, boolean normalized ) throws NamingException
121 {
122 return next.getSuffix( dn, normalized );
123 }
124
125
126 public boolean hasEntry( NextInterceptor next, Name name ) throws NamingException
127 {
128 return next.hasEntry( name );
129 }
130
131
132 public boolean isSuffix( NextInterceptor next, Name name ) throws NamingException
133 {
134 return next.isSuffix( name );
135 }
136
137
138 public NamingEnumeration list( NextInterceptor next, Name base ) throws NamingException
139 {
140 return next.list( base );
141 }
142
143
144 public Iterator listSuffixes( NextInterceptor next, boolean normalized ) throws NamingException
145 {
146 return next.listSuffixes( normalized );
147 }
148
149
150 public Attributes lookup( NextInterceptor next, Name dn, String[] attrIds ) throws NamingException
151 {
152 return next.lookup( dn, attrIds );
153 }
154
155
156 public Attributes lookup( NextInterceptor next, Name name ) throws NamingException
157 {
158 return next.lookup( name );
159 }
160
161
162 public void modify( NextInterceptor next, Name name, int modOp, Attributes mods ) throws NamingException
163 {
164 next.modify( name, modOp, mods );
165 }
166
167
168 public void modify( NextInterceptor next, Name name, ModificationItem[] mods ) throws NamingException
169 {
170 next.modify( name, mods );
171 }
172
173
174 public void modifyRn( NextInterceptor next, Name name, String newRn, boolean deleteOldRn ) throws NamingException
175 {
176 next.modifyRn( name, newRn, deleteOldRn );
177 }
178
179
180 public void move( NextInterceptor next, Name oriChildName, Name newParentName, String newRn, boolean deleteOldRn ) throws NamingException
181 {
182 next.move( oriChildName, newParentName, newRn, deleteOldRn );
183 }
184
185
186 public void move( NextInterceptor next, Name oriChildName, Name newParentName ) throws NamingException
187 {
188 next.move( oriChildName, newParentName );
189 }
190
191
192 public NamingEnumeration search( NextInterceptor next, Name base, Map env, ExprNode filter, SearchControls searchCtls ) throws NamingException
193 {
194 return next.search( base, env, filter, searchCtls );
195 }
196 }