Return-Path: Delivered-To: apmail-incubator-directory-cvs-archive@www.apache.org Received: (qmail 84563 invoked from network); 26 Oct 2004 04:37:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 26 Oct 2004 04:37:24 -0000 Received: (qmail 73075 invoked by uid 500); 26 Oct 2004 04:37:23 -0000 Delivered-To: apmail-incubator-directory-cvs-archive@incubator.apache.org Received: (qmail 73024 invoked by uid 500); 26 Oct 2004 04:37:22 -0000 Mailing-List: contact directory-cvs-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: directory-dev@incubator.apache.org Delivered-To: mailing list directory-cvs@incubator.apache.org Received: (qmail 73010 invoked by uid 99); 26 Oct 2004 04:37:22 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 25 Oct 2004 21:37:22 -0700 Received: (qmail 84482 invoked by uid 65534); 26 Oct 2004 04:37:21 -0000 Date: 26 Oct 2004 04:37:21 -0000 Message-ID: <20041026043721.84476.qmail@minotaur.apache.org> From: akarasulu@apache.org To: directory-cvs@incubator.apache.org Subject: svn commit: rev 55568 - in incubator/directory/eve/trunk/backend/core: . src/java/org/apache/eve/jndi src/java/org/apache/eve/jndi/ibs src/test/org/apache/eve/jndi X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Author: akarasulu Date: Mon Oct 25 21:37:18 2004 New Revision: 55568 Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java incubator/directory/eve/trunk/backend/core/src/test/org/apache/eve/jndi/AbstractJndiTest.java - copied unchanged from rev 55540, incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/AbstractJndiTest.java Removed: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/AbstractJndiTest.java Modified: incubator/directory/eve/trunk/backend/core/project.properties incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java Log: this is in the wrong place Modified: incubator/directory/eve/trunk/backend/core/project.properties ============================================================================== --- incubator/directory/eve/trunk/backend/core/project.properties (original) +++ incubator/directory/eve/trunk/backend/core/project.properties Mon Oct 25 21:37:18 2004 @@ -1,4 +1,4 @@ -maven.junit.fork=yes +maven.junit.fork=no maven.javadoc.private=true maven.javadoc.overview=src/java/org/apache/eve/schema/overview.html Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java ============================================================================== --- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java (original) +++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/EveContextFactory.java Mon Oct 25 21:37:18 2004 @@ -14,7 +14,6 @@ import org.apache.eve.RootNexus; import org.apache.eve.SystemPartition; -import org.apache.eve.exception.EveInterceptorException; import org.apache.eve.jndi.ibs.EveExceptionService; import org.apache.eve.db.*; import org.apache.eve.db.jdbm.JdbmDatabase; @@ -187,12 +186,28 @@ RootNexus root = new RootNexus( system ); provider = new EveJndiProvider( root ); + /* + * Create and add the Eve Exception service interceptor to both the + * before and onError interceptor chains. + */ InvocationStateEnum[] state = new InvocationStateEnum[]{ InvocationStateEnum.PREINVOCATION, InvocationStateEnum.FAILUREHANDLING }; - EveExceptionService interceptor = new EveExceptionService( root ); + Interceptor interceptor = new EveExceptionService( root ); provider.addInterceptor( interceptor, state ); + + /* + * Create and add the Eve operational attribute managment service + * interceptor to both the before and after interceptor chains. + */ + state = new InvocationStateEnum[]{ + InvocationStateEnum.PREINVOCATION, + InvocationStateEnum.FAILUREHANDLING + }; + interceptor = new EveExceptionService( root ); + provider.addInterceptor( interceptor, state ); + } Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java ============================================================================== --- (empty file) +++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/jndi/ibs/OperationalAttributeService.java Mon Oct 25 21:37:18 2004 @@ -0,0 +1,100 @@ +/* + * 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.eve.jndi.ibs; + + +import javax.naming.Name; +import javax.naming.NamingException; +import javax.naming.Context; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; + +import org.apache.eve.jndi.BaseInterceptor; +import org.apache.eve.jndi.Invocation; +import org.apache.eve.jndi.InvocationStateEnum; +import org.apache.eve.schema.AttributeTypeRegistry; +import org.apache.ldap.common.schema.AttributeType; +import org.apache.ldap.common.util.DateUtils; + + +/** + * An interceptor based service which manages the creation and modification of + * operational attributes as operations are performed. + * + * @author Apache Directory Project + * @version $Rev$ + */ +public class OperationalAttributeService extends BaseInterceptor +{ + /** the default user principal or DN */ + private final String DEFAULT_PRINCIPAL = "cn=admin,ou=system"; + /** the global attributeType registry of the schema subsystem */ + private final AttributeTypeRegistry registry; + +// /** the root nexus of the system */ +// private final RootNexus nexus; +// +// +// /** +// * Creates the operational attribute management service interceptor. +// * +// * @param nexus the root nexus of the system +// */ +// public OperationalAttributeService( RootNexus nexus ) +// { +// this.nexus = nexus; +// } + + /** + * Creates the operational attribute management service interceptor. + * + * @param registry the attributeType registry of the schema subsystem + */ + public OperationalAttributeService( AttributeTypeRegistry registry) + { + this.registry = registry; + } + + + /** + * Adds extra operational attributes to the entry before it is added. + * + * @todo add mechanism to find the identity of the caller so we can + * properly set the owner/modifier of the entry + * + * @see BaseInterceptor#add(String, Name, Attributes) + */ + protected void add( String upName, Name normName, Attributes entry ) throws NamingException + { + Invocation invocation = getInvocation(); + Context ctx = ( ( Context ) invocation.getContextStack().peek() ); + String principal = ( String ) ctx.getEnvironment().get( + Context.SECURITY_PRINCIPAL ); + + if ( invocation.getState() == InvocationStateEnum.PREINVOCATION ) + { + BasicAttribute attribute = new BasicAttribute( "creatorsName" ); + principal = principal == null ? DEFAULT_PRINCIPAL : principal; + attribute.add( principal ); + entry.put( attribute ); + + attribute = new BasicAttribute( "createTimestamp" ); + attribute.add( DateUtils.getGeneralizedTime( System.currentTimeMillis() ) ); + entry.put( attribute ); + } + } +}