Author: trustin
Date: Fri Mar 18 07:24:21 2005
New Revision: 158080
URL: http://svn.apache.org/viewcvs?view=rev&rev=158080
Log:
RequestProcessor was not a good name. Going back to 'interceptor'.
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java
(with props)
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java
(with props)
Removed:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/processor/
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,200 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.jndi.request.interceptor;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.exception.LdapAuthenticationException;
+import
org.apache.ldap.common.exception.LdapAuthenticationNotSupportedException;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.common.util.StringTools;
+import org.apache.ldap.server.auth.AbstractAuthenticator;
+import org.apache.ldap.server.auth.Authenticator;
+import org.apache.ldap.server.auth.LdapPrincipal;
+import org.apache.ldap.server.jndi.ServerContext;
+import org.apache.ldap.server.jndi.ServerLdapContext;
+import org.apache.ldap.server.jndi.request.Request;
+
+/**
+ * A service used to for authenticating users.
+ *
+ * @author <a href="mailto:[email protected]">Apache Directory
Project</a>
+ * @version $Rev$
+ */
+public class Authenticatior implements Interceptor
+{
+ /** short for Context.SECURITY_AUTHENTICATION */
+ private static final String AUTH_TYPE = Context.SECURITY_AUTHENTICATION;
+
+ /** short for Context.SECURITY_CREDENTIALS */
+ private static final String CREDS = Context.SECURITY_CREDENTIALS;
+
+ /** authenticators **/
+ public Map authenticators = new LinkedHashMap();
+
+
+ /**
+ * Creates an authentication service interceptor.
+ */
+ public Authenticatior()
+ {
+ }
+
+ /**
+ * Registers an Authenticator with this AuthenticatorService. Called by
each
+ * Authenticator implementation after it has started to register for
+ * authentication operation calls.
+ *
+ * @param authenticator Authenticator component to register with this
+ * AuthenticatorService.
+ */
+ public void register( AbstractAuthenticator authenticator )
+ {
+ Collection authenticatorList = getAuthenticators(
authenticator.getType() );
+ if ( authenticatorList == null )
+ {
+ authenticatorList = new ArrayList();
+ authenticators.put( authenticator.getType(), authenticatorList );
+ }
+ authenticatorList.add( authenticator );
+ }
+
+ /**
+ * Unregisters an Authenticator with this AuthenticatorService. Called
for each
+ * registered Authenticator right before it is to be stopped. This
prevents
+ * protocol server requests from reaching the Backend and effectively puts
+ * the ContextPartition's naming context offline.
+ *
+ * @param authenticator Authenticator component to unregister with this
+ * AuthenticatorService.
+ */
+ public void unregister( Authenticator authenticator )
+ {
+ Collection authenticatorList = getAuthenticators(
authenticator.getType() );
+ if ( authenticatorList == null )
+ {
+ return;
+ }
+ authenticatorList.remove( authenticator );
+ }
+
+ /**
+ * Gets the authenticators with a specific type.
+ *
+ * @param type the authentication type
+ * @return the authenticators with the specified type
+ */
+ public Collection getAuthenticators( String type )
+ {
+ return (Collection)authenticators.get( type );
+ }
+
+ public void init( Properties config )
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void process( NextInterceptor nextProcessor, Request request )
throws NamingException
+ {
+ // check if we are already authenticated and if so we return making
+ // sure first that the credentials are not exposed within context
+ ServerContext ctx = ( ServerLdapContext )
request.getContextStack().peek();
+ if ( ctx.getPrincipal() != null )
+ {
+ if ( ctx.getEnvironment().containsKey( CREDS ) )
+ {
+ ctx.removeFromEnvironment( CREDS );
+ }
+
+ nextProcessor.process(request);
+ }
+
+ String authList = ( String ) ctx.getEnvironment().get( AUTH_TYPE );
+
+ if ( authList == null )
+ {
+ if ( ctx.getEnvironment().containsKey( CREDS ) )
+ {
+ // authentication type is simple here
+ authList = "simple";
+ }
+ else
+ {
+ // authentication type is anonymous
+ authList = "none";
+ }
+
+ }
+
+ authList = StringTools.deepTrim( authList );
+ String[] auth = authList.split( " " );
+
+ Collection authenticators = null;
+
+ // pick the first matching authenticator type
+ for ( int i=0; i<auth.length; i++)
+ {
+ authenticators = getAuthenticators( auth[i] );
+ if ( authenticators != null ) break;
+ }
+
+ if ( authenticators == null )
+ {
+ ctx.getEnvironment(); // shut's up idea's yellow light
+ ResultCodeEnum rc = ResultCodeEnum.AUTHMETHODNOTSUPPORTED;
+ throw new LdapAuthenticationNotSupportedException( rc );
+ }
+
+ // try each authenticators
+ for ( Iterator i = authenticators.iterator(); i.hasNext(); )
+ {
+ try
+ {
+ Authenticator authenticator = ( Authenticator ) i.next();
+
+ // perform the authentication
+ LdapPrincipal authorizationId = authenticator.authenticate(
ctx );
+
+ // authentication was successful
+ ctx.setPrincipal( authorizationId );
+
+ // remove creds so there is no security risk
+ ctx.removeFromEnvironment( CREDS );
+ nextProcessor.process(request);
+ return;
+ }
+ catch ( LdapAuthenticationException e )
+ {
+ // authentication failed, try the next authenticator
+ }
+ }
+
+ throw new LdapAuthenticationException();
+ }
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authenticatior.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.jndi.request.interceptor;
+
+
+import java.util.Properties;
+
+import javax.naming.Name;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.ModificationItem;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+import javax.naming.ldap.LdapContext;
+
+import org.apache.ldap.common.exception.LdapNoPermissionException;
+import org.apache.ldap.common.name.DnParser;
+import org.apache.ldap.common.name.NameComponentNormalizer;
+import org.apache.ldap.server.SystemPartition;
+import org.apache.ldap.server.db.ResultFilteringEnumeration;
+import org.apache.ldap.server.db.SearchResultFilter;
+import org.apache.ldap.server.jndi.ServerContext;
+import org.apache.ldap.server.jndi.ibs.FilterService;
+import org.apache.ldap.server.jndi.request.DeleteRequest;
+import org.apache.ldap.server.jndi.request.HasEntryRequest;
+import org.apache.ldap.server.jndi.request.LookUpRequest;
+import org.apache.ldap.server.jndi.request.LookUpWithAttributeIdsRequest;
+import org.apache.ldap.server.jndi.request.ModifyManyRequest;
+import org.apache.ldap.server.jndi.request.ModifyRelativeNameRequest;
+import org.apache.ldap.server.jndi.request.ModifyRequest;
+import org.apache.ldap.server.jndi.request.MoveRequest;
+import org.apache.ldap.server.jndi.request.MoveWithNewRelativeNameRequest;
+import org.apache.ldap.server.jndi.request.Request;
+import org.apache.ldap.server.jndi.request.SearchRequest;
+
+
+/**
+ * A service used for applying access controls to backing store operations.
+ *
+ * @author <a href="mailto:[email protected]">Apache Directory
Project</a>
+ * @version $Rev$
+ */
+public class Authorizer extends BaseInterceptor
+{
+ /** the administrator's distinguished [EMAIL PROTECTED] Name} */
+ private static final Name ADMIN_DN = SystemPartition.getAdminDn();
+ /** the base distinguished [EMAIL PROTECTED] Name} for all users */
+ private static final Name USER_BASE_DN = SystemPartition.getUsersBaseDn();
+ /** the base distinguished [EMAIL PROTECTED] Name} for all groups */
+ private static final Name GROUP_BASE_DN =
SystemPartition.getGroupsBaseDn();
+
+ /** the name parser used by this service */
+ private final DnParser dnParser;
+
+
+ /**
+ * Creates an authorization service interceptor.
+ *
+ * @param normalizer a schema enabled name component normalizer
+ * @param filterService a [EMAIL PROTECTED] FilterService} to register
filters with
+ */
+ public Authorizer( NameComponentNormalizer normalizer )
+ throws NamingException
+ {
+ this.dnParser = new DnParser( normalizer );
+ }
+
+ public void init( Properties config )
+ {
+ }
+
+ public void destroy()
+ {
+ }
+
+ // Note:
+ // Lookup, search and list operations need to be handled using a filter
+ // and so we need access to the filter service.
+
+ protected void process( NextInterceptor nextProcessor, DeleteRequest
request ) throws NamingException
+ {
+ Name name = request.getName();
+ Name principalDn = getPrincipal( request ).getDn();
+
+ if ( name.toString().equals( "" ) )
+ {
+ String msg = "The rootDSE cannot be deleted!";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( name == ADMIN_DN || name.equals( ADMIN_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to delete the admin account.";
+ msg += " No one not even the admin can delete this account!";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( name.size() > 2 && name.startsWith( USER_BASE_DN )
+ && ! principalDn.equals( ADMIN_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to delete the user account: ";
+ msg += name + ". Only the admin can delete user accounts.";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( name.size() > 2 && name.startsWith( GROUP_BASE_DN )
+ && ! principalDn.equals( ADMIN_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to delete the group entry: ";
+ msg += name + ". Only the admin can delete groups.";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ nextProcessor.process( request );
+ }
+
+
+ /**
+ * Note that we do nothing here. First because this is not an externally
+ * exposed function via the JNDI interfaces. It is used internally by the
+ * provider for optimization purposes so there is no reason for us to start
+ * to constrain it.
+ *
+ * @see org.apache.ldap.server.jndi.BaseInterceptor#hasEntry(Name)
+ */
+ protected void process( NextInterceptor nextProcessor, HasEntryRequest
request ) throws NamingException
+ {
+ super.process( nextProcessor, request );
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Entry Modification Operations
+ // ------------------------------------------------------------------------
+
+
+ /**
+ * This policy needs to be really tight too because some attributes may
+ * take part in giving the user permissions to protected resources. We
+ * do not want users to self access these resources. As far as we're
+ * concerned no one but the admin needs access.
+ *
+ * @see BaseInterceptor#modify(Name, int, Attributes)
+ */
+ protected void process( NextInterceptor nextProcessor, ModifyRequest
request ) throws NamingException
+ {
+ protectModifyAlterations( request, request.getName() );
+ nextProcessor.process( request );
+ }
+
+
+ /**
+ * This policy needs to be really tight too because some attributes may
+ * take part in giving the user permissions to protected resources. We
+ * do not want users to self access these resources. As far as we're
+ * concerned no one but the admin needs access.
+ *
+ * @see BaseInterceptor#modify(Name, ModificationItem[])
+ */
+ protected void process( NextInterceptor nextProcessor, ModifyManyRequest
request ) throws NamingException
+ {
+ protectModifyAlterations( request, request.getName() );
+ nextProcessor.process( request );
+ }
+
+
+ private void protectModifyAlterations( Request request, Name dn ) throws
LdapNoPermissionException
+ {
+ Name principalDn = getPrincipal( request ).getDn();
+
+ if ( dn.toString().equals( "" ) )
+ {
+ String msg = "The rootDSE cannot be modified!";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( ! principalDn.equals( ADMIN_DN ) )
+ {
+ if ( dn == ADMIN_DN || dn.equals( ADMIN_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to modify the admin
account.";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.size() > 2 && dn.startsWith( USER_BASE_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to modify the account of
the";
+ msg += " user " + dn + ".\nEven the owner of an account
cannot";
+ msg += " modify it.\nUser accounts can only be modified by
the";
+ msg += " administrator.";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.size() > 2 && dn.startsWith( GROUP_BASE_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to modify the group entry ";
+ msg += dn + ".\nGroups can only be modified by the admin.";
+ throw new LdapNoPermissionException( msg );
+ }
+ }
+ }
+
+
+ // ------------------------------------------------------------------------
+ // DN altering operations are a no no for any user entry. Basically here
+ // are the rules of conduct to follow:
+ //
+ // o No user should have the ability to move or rename their entry
+ // o Only the administrator can move or rename non-admin user entries
+ // o The administrator entry cannot be moved or renamed by anyone
+ // ------------------------------------------------------------------------
+
+
+ protected void process( NextInterceptor nextProcessor,
ModifyRelativeNameRequest request ) throws NamingException
+ {
+ protectDnAlterations( request, request.getName() );
+ nextProcessor.process( request );
+ }
+
+
+ protected void process( NextInterceptor nextProcessor, MoveRequest request
) throws NamingException
+ {
+ protectDnAlterations( request, request.getName() );
+ nextProcessor.process( request );
+ }
+
+
+ protected void process( NextInterceptor nextProcessor,
MoveWithNewRelativeNameRequest request ) throws NamingException
+ {
+ protectDnAlterations( request, request.getName() );
+ nextProcessor.process( request );
+ }
+
+
+ private void protectDnAlterations( Request request, Name dn ) throws
LdapNoPermissionException
+ {
+ Name principalDn = getPrincipal( request ).getDn();
+
+ if ( dn.toString().equals( "" ) )
+ {
+ String msg = "The rootDSE cannot be moved or renamed!";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn == ADMIN_DN || dn.equals( ADMIN_DN ) )
+ {
+ String msg = "User '" + principalDn;
+ msg += "' does not have permission to move or rename the admin";
+ msg += " account. No one not even the admin can move or";
+ msg += " rename " + dn + "!";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.size() > 2 && dn.startsWith( USER_BASE_DN ) && !
principalDn.equals( ADMIN_DN ) )
+ {
+ String msg = "User '" + principalDn;
+ msg += "' does not have permission to move or rename the user";
+ msg += " account: " + dn + ". Only the admin can move or";
+ msg += " rename user accounts.";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.size() > 2 && dn.startsWith( GROUP_BASE_DN ) && !
principalDn.equals( ADMIN_DN ) )
+ {
+ String msg = "User " + principalDn;
+ msg += " does not have permission to move or rename the group
entry ";
+ msg += dn + ".\nGroups can only be moved or renamed by the admin.";
+ throw new LdapNoPermissionException( msg );
+ }
+ }
+
+ protected void process(NextInterceptor nextProcessor, LookUpRequest
request) throws NamingException {
+ super.process(nextProcessor, request);
+
+ Attributes attributes = ( Attributes ) request.getResponse();
+ if( attributes == null )
+ {
+ return;
+ }
+
+ Attributes retval = ( Attributes ) attributes.clone();
+ LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
+ protectLookUp( ctx, request.getName() );
+ request.setResponse( retval );
+ }
+
+ protected void process(NextInterceptor nextProcessor,
LookUpWithAttributeIdsRequest request) throws NamingException {
+ super.process(nextProcessor, request);
+
+ Attributes attributes = ( Attributes ) request.getResponse();
+ if( attributes == null )
+ {
+ return;
+ }
+
+ Attributes retval = ( Attributes ) attributes.clone();
+ LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
+ protectLookUp( ctx, request.getName() );
+ request.setResponse( retval );
+ }
+
+ private void protectLookUp( LdapContext ctx, Name dn ) throws
NamingException
+ {
+ Name principalDn = ( ( ServerContext ) ctx ).getPrincipal().getDn();
+
+ if ( ! principalDn.equals( ADMIN_DN ) )
+ {
+ if ( dn.size() > 2 && dn.startsWith( USER_BASE_DN ) )
+ {
+ // allow for self reads
+ if ( dn.toString().equals( principalDn.toString() ) )
+ {
+ return;
+ }
+
+ String msg = "Access to user account '" + dn + "' not
permitted";
+ msg += " for user '" + principalDn + "'. Only the admin can";
+ msg += " access user account information";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.size() > 2 && dn.startsWith( GROUP_BASE_DN ) )
+ {
+ // allow for self reads
+ if ( dn.toString().equals( principalDn.toString() ) )
+ {
+ return;
+ }
+
+ String msg = "Access to group '" + dn + "' not permitted";
+ msg += " for user '" + principalDn + "'. Only the admin can";
+ msg += " access group information";
+ throw new LdapNoPermissionException( msg );
+ }
+
+ if ( dn.equals( ADMIN_DN ) )
+ {
+ // allow for self reads
+ if ( dn.toString().equals( principalDn.toString() ) )
+ {
+ return;
+ }
+
+ String msg = "Access to admin account not permitted for user
'";
+ msg += principalDn + "'. Only the admin can";
+ msg += " access admin account information";
+ throw new LdapNoPermissionException( msg );
+ }
+ }
+ }
+
+ protected void process(NextInterceptor nextProcessor, SearchRequest
request) throws NamingException {
+ super.process(nextProcessor, request);
+
+ SearchControls searchControls = request.getSearchControls();
+ if ( searchControls.getReturningAttributes() != null )
+ {
+ return;
+ }
+
+ NamingEnumeration e ;
+ ResultFilteringEnumeration retval;
+ LdapContext ctx = ( LdapContext ) request.getContextStack().peek();
+ e = ( NamingEnumeration ) request.getResponse();
+ retval = new ResultFilteringEnumeration( e, searchControls, ctx,
+ new SearchResultFilter()
+ {
+ public boolean accept( LdapContext ctx, SearchResult result,
+ SearchControls controls )
+ throws NamingException
+ {
+ return Authorizer.this.isSearchable( ctx, result, controls
);
+ }
+ } );
+
+ request.setResponse( retval );
+ }
+
+ private boolean isSearchable( LdapContext ctx, SearchResult result,
SearchControls controls )
+ throws NamingException
+ {
+ Name dn;
+
+ synchronized( dnParser )
+ {
+ dn = dnParser.parse( result.getName() );
+ }
+
+ Name principalDn = ( ( ServerContext ) ctx ).getPrincipal().getDn();
+ if ( ! principalDn.equals( ADMIN_DN ) )
+ {
+ if ( dn.size() > 2 )
+ {
+ if ( dn.startsWith( USER_BASE_DN ) || dn.startsWith(
GROUP_BASE_DN ) )
+ {
+ return false;
+ }
+ }
+
+ if ( dn.equals( ADMIN_DN ) )
+ {
+ return false;
+ }
+
+ }
+
+ return true;
+ }
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Authorizer.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,265 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.jndi.request.interceptor;
+
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.auth.LdapPrincipal;
+import org.apache.ldap.server.jndi.ServerContext;
+import org.apache.ldap.server.jndi.request.AddRequest;
+import org.apache.ldap.server.jndi.request.DeleteRequest;
+import org.apache.ldap.server.jndi.request.GetMatchedNameRequest;
+import org.apache.ldap.server.jndi.request.GetSuffixRequest;
+import org.apache.ldap.server.jndi.request.HasEntryRequest;
+import org.apache.ldap.server.jndi.request.IsSuffixRequest;
+import org.apache.ldap.server.jndi.request.ListRequest;
+import org.apache.ldap.server.jndi.request.ListSuffixesRequest;
+import org.apache.ldap.server.jndi.request.LookUpRequest;
+import org.apache.ldap.server.jndi.request.LookUpWithAttributeIdsRequest;
+import org.apache.ldap.server.jndi.request.ModifyManyRequest;
+import org.apache.ldap.server.jndi.request.ModifyRelativeNameRequest;
+import org.apache.ldap.server.jndi.request.ModifyRequest;
+import org.apache.ldap.server.jndi.request.MoveRequest;
+import org.apache.ldap.server.jndi.request.MoveWithNewRelativeNameRequest;
+import org.apache.ldap.server.jndi.request.Request;
+import org.apache.ldap.server.jndi.request.SearchRequest;
+
+
+/**
+ * An interceptor base class which delegates handling of specific Invocations
+ * to member methods within this Interceptor. These handler methods are
+ * analogous to the methods assocated with the Invocation. They have the same
+ * name and arguments as do the method associated with the Invocation. The
+ * analog member methods simply serve as a clean way to handle interception
+ * without having to cast parameter Objects or recode this huge switch
statement
+ * for each concrete Interceptor implementation.
+ *
+ * A ThreadLocal is used by all BaseInterceptors to associate the current
+ * Thread of execution with an Invocation object. This is done to optimize
+ * the use of a single thread local for all instances of the BaseInterceptor
+ * class. It also removes the need for the invoke() method implementation to
+ * have to set and [un]set the thread local Invocation on each invoke call of
+ * every BaseInterceptor instance.
+ *
+ * The question then arrises, "Why do we need the ThreadLocal?" Well why pass
+ * around the Invocation object to all analog methods. Plus we use member
+ * methods rather than static methods to access thread locals and make the
+ * analogs appear cleaner matching their respective invocation methods.
+ *
+ * @author <a href="mailto:[email protected]">Apache Directory
Project</a>
+ * @version $Rev$
+ */
+public abstract class BaseInterceptor implements Interceptor
+{
+ /**
+ * Gets the request's current context's Principal.
+ *
+ * @return the principal making the call
+ */
+ public static LdapPrincipal getPrincipal( Request request )
+ {
+ ServerContext ctx = ( ServerContext ) request.getContextStack().peek();
+ return ctx.getPrincipal();
+ }
+
+ protected BaseInterceptor()
+ {
+ }
+
+ // ------------------------------------------------------------------------
+ // Interceptor's Invoke Method
+ // ------------------------------------------------------------------------
+
+ /**
+ * Uses a switch on the invocation method type to call the respective
member
+ * analog method that does the work of the Interceptor for that Invocation
+ * method.
+ */
+ public void process( NextInterceptor nextProcessor, Request request )
+ throws NamingException
+ {
+ if( request instanceof AddRequest )
+ {
+ process( nextProcessor, ( AddRequest ) request );
+ }
+ else if( request instanceof DeleteRequest )
+ {
+ process( nextProcessor, ( DeleteRequest ) request );
+ }
+ else if( request instanceof GetMatchedNameRequest )
+ {
+ process( nextProcessor, ( GetMatchedNameRequest ) request );
+ }
+ else if( request instanceof GetSuffixRequest )
+ {
+ process( nextProcessor, ( GetSuffixRequest ) request );
+ }
+ else if( request instanceof HasEntryRequest )
+ {
+ process( nextProcessor, ( HasEntryRequest ) request );
+ }
+ else if( request instanceof IsSuffixRequest )
+ {
+ process( nextProcessor, ( IsSuffixRequest ) request );
+ }
+ else if( request instanceof ListRequest )
+ {
+ process( nextProcessor, ( ListRequest ) request );
+ }
+ else if( request instanceof ListSuffixesRequest )
+ {
+ process( nextProcessor, ( ListSuffixesRequest ) request );
+ }
+ else if( request instanceof LookUpRequest )
+ {
+ process( nextProcessor, ( LookUpRequest ) request );
+ }
+ else if( request instanceof LookUpWithAttributeIdsRequest )
+ {
+ process( nextProcessor, ( LookUpWithAttributeIdsRequest ) request
);
+ }
+ else if( request instanceof ModifyRequest )
+ {
+ process( nextProcessor, ( ModifyRequest ) request );
+ }
+ else if( request instanceof ModifyManyRequest )
+ {
+ process( nextProcessor, ( ModifyManyRequest ) request );
+ }
+ else if( request instanceof ModifyRelativeNameRequest )
+ {
+ process( nextProcessor, ( ModifyRelativeNameRequest ) request );
+ }
+ else if( request instanceof MoveRequest )
+ {
+ process( nextProcessor, ( MoveRequest ) request );
+ }
+ else if( request instanceof MoveWithNewRelativeNameRequest )
+ {
+ process( nextProcessor, ( MoveWithNewRelativeNameRequest ) request
);
+ }
+ else if( request instanceof SearchRequest )
+ {
+ process( nextProcessor, ( SearchRequest ) request );
+ }
+ else {
+ throw new IllegalArgumentException(
+ "Unknown request type: " + request.getClass() );
+ }
+ }
+
+ // ------------------------------------------------------------------------
+ // Invocation Analogs
+ // ------------------------------------------------------------------------
+
+ protected void process( NextInterceptor nextProcessor, AddRequest request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, DeleteRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor,
GetMatchedNameRequest request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, GetSuffixRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, HasEntryRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, IsSuffixRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, ListRequest request
)
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, ListSuffixesRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, LookUpRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor,
LookUpWithAttributeIdsRequest request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, ModifyRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, ModifyManyRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor,
ModifyRelativeNameRequest request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, MoveRequest request
)
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor,
MoveWithNewRelativeNameRequest request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+
+ protected void process( NextInterceptor nextProcessor, SearchRequest
request )
+ throws NamingException
+ {
+ nextProcessor.process( request );
+ }
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/BaseInterceptor.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.jndi.request.interceptor;
+
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.jndi.request.Request;
+
+/**
+ * Processes or filters any directory operations. You can intercept the
+ * [EMAIL PROTECTED] Invocation}s and perform 'before', 'after', 'around' any
any other
+ * filtering operations.
+ *
+ * @author The Apache Directory Project ([email protected])
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public interface Interceptor
+{
+ /**
+ * Intializes this interceptor. This is invoked by directory service
+ * provider when this intercepter is loaded into interceptor chain.
+ *
+ * @param config the configuration properties for this interceptor
+ * @throws NamingException if failed to initialize this interceptor
+ */
+ void init( Properties config ) throws NamingException;
+
+ /**
+ * Deinitialized this interceptor. This is invoked by directory service
+ * provider when this intercepter is unloaded from interceptor chain.
+ */
+ void destroy();
+
+ /**
+ * Process a particular invocation. You can pass control to
+ * <code>nextInterceptor</code> by invoking [EMAIL PROTECTED]
#invoke(RequestProcessor, Invocation)}.
+ *
+ * @param nextProcessor the next processor in the processor chain
+ * @param invocation the invocation to process
+ * @throws NamingException on failures while handling the invocation
+ */
+ void process( NextInterceptor nextProcessor, Request request )
+ throws NamingException;
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/Interceptor.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,307 @@
+package org.apache.ldap.server.jndi.request.interceptor;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.jndi.request.Request;
+
+/**
+ * Manages [EMAIL PROTECTED] Interceptor} stack. The first [EMAIL PROTECTED]
Interceptor} is
+ * invoked and then invocation chain starts.
+ *
+ * TODO imeplement me.
+ *
+ * @author The Apache Directory Project ([email protected])
+ * @author Trustin Lee ([EMAIL PROTECTED])
+ * @version $Rev$, $Date$
+ */
+public class InterceptorChain
+{
+ private static final Interceptor FINAL_PROCESSOR = new Interceptor()
+ {
+ public void init(Properties config) throws NamingException
+ {
+ // do nothing
+ }
+
+ public void destroy()
+ {
+ // do nothing
+ }
+
+ public void process(NextInterceptor nextProcessor, Request request)
+ throws NamingException
+ {
+ // do nothing
+ }
+ };
+
+ private final Map name2entry = new HashMap();
+ private Entry head = new Entry( null, null, "", FINAL_PROCESSOR );
+ private final Entry tail = head;
+
+ /**
+ * Create a new processor chain.
+ */
+ public InterceptorChain()
+ {
+ }
+
+ /**
+ * Returns the processor with the specified <code>name</code>.
+ *
+ * @return <code>null</code> if there is no processor with the specified
+ * <code>name</code>.
+ */
+ public Interceptor get( String name )
+ {
+ Entry e = ( Entry ) name2entry.get( name );
+ if( e == null )
+ {
+ return null;
+ }
+ return e.processor;
+ }
+
+ /**
+ * Adds the specified processor with the specified name at the beginning
+ * of this chain.
+ */
+ public synchronized void addFirst( String name,
+ Interceptor processor )
+ {
+ checkNewName( name );
+
+ Entry newEntry = new Entry( null, head, name, processor );
+ head.prevEntry = newEntry;
+ head = newEntry;
+ }
+
+ /**
+ * Adds the specified processor with the specified name at the end
+ * of this chain.
+ */
+ public synchronized void addLast( String name,
+ Interceptor processor )
+ {
+ checkNewName( name );
+
+ Entry newEntry = new Entry( tail.prevEntry, tail, name, processor );
+ tail.prevEntry.nextEntry = newEntry;
+ tail.prevEntry = newEntry;
+ }
+
+ /**
+ * Adds the specified processor with the specified name just before
+ * the processor whose name is <code>baseName</code> in this chain.
+ */
+ public synchronized void addBefore( String baseName,
+ String name,
+ Interceptor processor )
+ {
+ Entry baseEntry = checkOldName( baseName );
+ checkNewName( name );
+
+ Entry prevEntry = baseEntry.prevEntry;
+ Entry newEntry = new Entry( prevEntry, baseEntry, name, processor );
+ if( prevEntry == null )
+ {
+ head = newEntry;
+ }
+ else
+ {
+ prevEntry.nextEntry.prevEntry = newEntry;
+ prevEntry.nextEntry = newEntry;
+ }
+
+ name2entry.put( name, newEntry );
+ }
+
+ /**
+ * Adds the specified processor with the specified name just after
+ * the processor whose name is <code>baseName</code> in this chain.
+ */
+ public synchronized void addAfter( String baseName,
+ String name,
+ Interceptor processor )
+ {
+ Entry baseEntry = checkOldName( baseName );
+ checkNewName(name);
+
+ Entry nextEntry = baseEntry.nextEntry;
+ Entry newEntry = new Entry( baseEntry, nextEntry, name, processor );
+ if( nextEntry == null )
+ {
+ throw new IllegalStateException();
+ }
+ else
+ {
+ nextEntry.prevEntry.nextEntry = newEntry;
+ nextEntry.prevEntry = newEntry;
+ }
+
+ name2entry.put( name, newEntry );
+ }
+
+ /**
+ * Removes the processor with the specified name from this chain.
+ */
+ public synchronized void remove( String name )
+ {
+ Entry entry = checkOldName( name );
+ Entry prevEntry = entry.prevEntry;
+ Entry nextEntry = entry.nextEntry;
+ if( prevEntry == null )
+ {
+ nextEntry.prevEntry = null;
+ head = entry;
+ }
+ else
+ {
+ prevEntry.nextEntry = nextEntry;
+ nextEntry.prevEntry = prevEntry;
+ }
+ }
+
+ /**
+ * Removed all processors added to this chain.
+ */
+ public synchronized void clear()
+ {
+ tail.prevEntry = null;
+ tail.nextEntry = null;
+ head = tail;
+ }
+
+ private Entry checkOldName( String baseName )
+ {
+ Entry e = ( Entry ) name2entry.get( baseName );
+ if( e == null )
+ {
+ throw new IllegalArgumentException( "Unknown processor name:" +
+ baseName );
+ }
+ return e;
+ }
+
+ private void checkNewName( String name )
+ {
+ if( name2entry.containsKey( name ) )
+ {
+ throw new IllegalArgumentException(
+ "Other processor is using name '" + name + "'" );
+ }
+ }
+
+ /**
+ * Start invocation chain with the specified invocation.
+ * @throws NamingException if invocation failed
+ */
+ public void process( Request request ) throws NamingException
+ {
+ Entry head = this.head;
+ try
+ {
+ head.processor.process(
+ head.nextProcessor, request );
+ }
+ catch( NamingException ne )
+ {
+ throw ne;
+ }
+ catch( Throwable e )
+ {
+ throw new InterceptorException( head.processor, request,
+ "Unexpected exception.", e );
+ }
+ }
+
+ /**
+ * Returns the list of processors this chain contains in the order of
+ * evaluation.
+ */
+ public List getAll()
+ {
+ List list = new ArrayList();
+ Entry e = head;
+ do
+ {
+ list.add( e.processor );
+ e = e.nextEntry;
+ }
+ while( e != null );
+
+ return list;
+ }
+
+ /**
+ * Returns the list of processors this chain contains in the reversed
+ * order of evaluation.
+ */
+ public List getAllReversed()
+ {
+ List list = new ArrayList();
+ Entry e = tail;
+ do
+ {
+ list.add( e.processor );
+ e = e.prevEntry;
+ }
+ while( e != null );
+
+ return list;
+ }
+
+ private class Entry
+ {
+ private Entry prevEntry;
+ private Entry nextEntry;
+ private final String name;
+ private final Interceptor processor;
+ private final NextInterceptor nextProcessor;
+
+ private Entry( Entry prevEntry, Entry nextEntry,
+ String name, Interceptor processor )
+ {
+ if( processor == null )
+ {
+ throw new NullPointerException( "processor" );
+ }
+ if( name == null )
+ {
+ throw new NullPointerException( "name" );
+ }
+
+ this.prevEntry = prevEntry;
+ this.nextEntry = nextEntry;
+ this.name = name;
+ this.processor = processor;
+ this.nextProcessor = new NextInterceptor()
+ {
+ public void process(Request request)
+ throws NamingException {
+ Interceptor processor = Entry.this.nextEntry.processor;
+ try
+ {
+ processor.process(
+ Entry.this.nextEntry.nextProcessor, request );
+ }
+ catch( NamingException ne )
+ {
+ throw ne;
+ }
+ catch( Throwable e )
+ {
+ throw new InterceptorException( processor, request,
+ "Unexpected
exception.", e );
+ }
+ }
+ };
+ }
+ }
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorChain.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.ldap.server.jndi.request.interceptor;
+
+
+import org.apache.ldap.common.exception.LdapException;
+import org.apache.ldap.common.exception.LdapNamingException;
+import org.apache.ldap.common.message.ResultCodeEnum;
+import org.apache.ldap.server.jndi.request.Request;
+
+
+/**
+ * Exception thrown by an Interceptor while intercepting an Invocation.
+ * Interceptor failures caught from the method are bundled as
+ * InterceptorExceptions and rethrown.
+ *
+ * @author <a href="mailto:[email protected]">Apache Directory
Project</a>
+ * @version $Rev$
+ */
+public class InterceptorException extends LdapNamingException
+{
+ private static final long serialVersionUID = 3258690996517746233L;
+
+ /** The Invokation the Interceptor failed on */
+ private final Request request;
+ /** The Interceptor causing the failure */
+ private final Interceptor requestProcessor;
+
+
+ /**
+ * Creates an InterceptorException without a message.
+ *
+ * @param requestProcessor the Interceptor causing the failure
+ * @param invocation the Invocation the Interceptor failed on
+ */
+ public InterceptorException( Interceptor requestProcessor, Request request
)
+ {
+ super( ResultCodeEnum.OTHER );
+ this.request = request;
+ this.requestProcessor = requestProcessor;
+ }
+
+
+ /**
+ * Creates an InterceptorException with a custom message.
+ *
+ * @param requestProcessor the Interceptor causing the failure
+ * @param invocation the Invocation the Interceptor failed on
+ * @param explanation String explanation of why the Interceptor failed
+ */
+ public InterceptorException( Interceptor requestProcessor,
+ Request request, String explanation )
+ {
+ super( explanation, ResultCodeEnum.OTHER );
+ this.request = request;
+ this.requestProcessor = requestProcessor;
+ }
+
+
+ /**
+ * Creates an InterceptorException without a message.
+ *
+ * @param requestProcessor the Interceptor causing the failure
+ * @param invocation the Invocation the Interceptor failed on
+ * @param rootCause the root cause of this exception
+ */
+ public InterceptorException( Interceptor requestProcessor,
+ Request request, Throwable rootCause )
+ {
+ this( requestProcessor, request );
+ super.setRootCause( rootCause );
+ }
+
+ /**
+ * Creates an InterceptorException without a message.
+ *
+ * @param requestProcessor the Interceptor causing the failure
+ * @param invocation the Invocation the Interceptor failed on
+ * @param explanation String explanation of why the Interceptor failed
+ * @param rootCause the root cause of this exception
+ */
+ public InterceptorException( Interceptor requestProcessor,
+ Request request,
+ String explanation,
+ Throwable rootCause )
+ {
+ this( requestProcessor, request, explanation );
+ super.setRootCause( rootCause );
+ }
+
+ /**
+ * Gets the invovation object this exception is associated with.
+ *
+ * @return the invovation object this exception is associated with
+ */
+ public Request getRequest()
+ {
+ return request;
+ }
+
+
+ /**
+ * Gets the interceptor this exception is associated with.
+ *
+ * @return the interceptor this exception is associated with
+ */
+ public Interceptor getRequestProcessor()
+ {
+ return requestProcessor;
+ }
+
+
+ /**
+ * Will return the resultCode of the root cause if the root cause
+ * implements LdapException.
+ *
+ * @see org.apache.ldap.common.exception.LdapException#getResultCode()
+ */
+ public ResultCodeEnum getResultCode()
+ {
+ if ( getRootCause() != null && ( getRootCause() instanceof
LdapException ) )
+ {
+ return ( ( LdapException ) getRootCause() ).getResultCode();
+ }
+
+ return super.getResultCode();
+ }
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/InterceptorException.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision
Added:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java
URL:
http://svn.apache.org/viewcvs/directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java?view=auto&rev=158080
==============================================================================
---
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java
(added)
+++
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java
Fri Mar 18 07:24:21 2005
@@ -0,0 +1,9 @@
+package org.apache.ldap.server.jndi.request.interceptor;
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.server.jndi.request.Request;
+
+public interface NextInterceptor {
+ void process( Request request ) throws NamingException;
+}
Propchange:
directory/apacheds/branches/interceptor_revamp/core/src/main/java/org/apache/ldap/server/jndi/request/interceptor/NextInterceptor.java
------------------------------------------------------------------------------
svn:keywords = HeadURL Id LastChangedBy LastChangedDate LastChangedRevision