You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2013/08/09 13:05:13 UTC

svn commit: r1512252 - in /directory/escimo/trunk: common/ common/src/main/java/org/apache/directory/scim/ common/src/main/java/org/apache/directory/scim/json/ ldap/src/main/java/org/apache/directory/scim/ldap/ ldap/src/main/java/org/apache/directory/s...

Author: kayyagari
Date: Fri Aug  9 11:05:12 2013
New Revision: 1512252

URL: http://svn.apache.org/r1512252
Log:
support for attribute handlers

Added:
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java
Modified:
    directory/escimo/trunk/common/pom.xml
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
    directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
    directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
    directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
    directory/escimo/trunk/server/pom.xml
    directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java

Modified: directory/escimo/trunk/common/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/pom.xml?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/common/pom.xml (original)
+++ directory/escimo/trunk/common/pom.xml Fri Aug  9 11:05:12 2013
@@ -29,6 +29,12 @@
     <name>eSCIMo common API</name>
 
    <dependencies>
+   <!-- for the lack of any API spec jar for jax-rs 2.0 including Wink server in common -->
+    <dependency>
+      <groupId>org.apache.wink</groupId>
+      <artifactId>wink-server</artifactId>
+      <version>${wink.version}</version>
+    </dependency>
     <dependency>
       <groupId>com.google.code.gson</groupId>
       <artifactId>gson</artifactId>

Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java?rev=1512252&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java (added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/AttributeHandler.java Fri Aug  9 11:05:12 2013
@@ -0,0 +1,34 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.directory.scim;
+
+import org.apache.directory.scim.schema.BaseType;
+
+
+/**
+ * TODO AttributeHandler.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface AttributeHandler
+{
+    void handle( BaseType bt, Object srcResource, RequestContext ctx );
+}

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/ProviderService.java Fri Aug  9 11:05:12 2013
@@ -26,5 +26,5 @@ public interface ProviderService 
 {
     void init() throws Exception;
     void stop();;
-    User getUser( String userId ) throws ResourceNotFoundException;
+    User getUser( RequestContext ctx, String userId ) throws ResourceNotFoundException;
 }

Added: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java?rev=1512252&view=auto
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java (added)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/RequestContext.java Fri Aug  9 11:05:12 2013
@@ -0,0 +1,54 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.directory.scim;
+
+/**
+ * TODO RequestContext.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class RequestContext
+{
+    private Object resourceConnection;
+    //private Uri
+    
+    private User user;
+
+    public Object getResourceConnection()
+    {
+        return resourceConnection;
+    }
+
+    public void setResourceConnection( Object resourceConnection )
+    {
+        this.resourceConnection = resourceConnection;
+    }
+
+    public User getUser()
+    {
+        return user;
+    }
+
+    public void setUser( User user )
+    {
+        this.user = user;
+    }
+    
+}

Modified: directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java (original)
+++ directory/escimo/trunk/common/src/main/java/org/apache/directory/scim/json/ResourceSerializer.java Fri Aug  9 11:05:12 2013
@@ -136,5 +136,9 @@ public class ResourceSerializer
         {
             parent.addProperty( at.getName(), ( Number ) obj );
         }
+        if ( obj instanceof Boolean )
+        {
+            parent.addProperty( at.getName(), ( Boolean ) obj );
+        }
     }
 }

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapResourceProvider.java Fri Aug  9 11:05:12 2013
@@ -60,7 +60,9 @@ import org.apache.directory.api.util.Str
 import org.apache.directory.ldap.client.api.LdapConnection;
 import org.apache.directory.ldap.client.api.LdapConnectionConfig;
 import org.apache.directory.ldap.client.api.LdapNetworkConnection;
+import org.apache.directory.scim.AttributeHandler;
 import org.apache.directory.scim.ComplexAttribute;
+import org.apache.directory.scim.RequestContext;
 import org.apache.directory.scim.MultiValAttribute;
 import org.apache.directory.scim.ProviderService;
 import org.apache.directory.scim.ResourceNotFoundException;
@@ -68,13 +70,13 @@ import org.apache.directory.scim.SimpleA
 import org.apache.directory.scim.SimpleAttributeGroup;
 import org.apache.directory.scim.User;
 import org.apache.directory.scim.json.ResourceSerializer;
-import org.apache.directory.scim.ldap.schema.BaseType;
 import org.apache.directory.scim.ldap.schema.ComplexType;
 import org.apache.directory.scim.ldap.schema.MultiValType;
 import org.apache.directory.scim.ldap.schema.SimpleType;
 import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
 import org.apache.directory.scim.ldap.schema.TypedType;
 import org.apache.directory.scim.ldap.schema.UserSchema;
+import org.apache.directory.scim.schema.BaseType;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -170,7 +172,7 @@ public class LdapResourceProvider implem
     }
 
 
-    public User getUser( String id ) throws ResourceNotFoundException
+    public User getUser( RequestContext ctx, String id ) throws ResourceNotFoundException
     {
         SimpleType st = ( SimpleType ) userSchema.getCoreAttribute( "id" );
         String userIdName = st.getMappedTo();
@@ -203,7 +205,7 @@ public class LdapResourceProvider implem
 
         try
         {
-            return toUser( entry );
+            return toUser( ctx, entry );
         }
         catch ( Exception e )
         {
@@ -212,12 +214,14 @@ public class LdapResourceProvider implem
     }
 
 
-    public User toUser( Entry entry ) throws Exception
+    public User toUser( RequestContext ctx, Entry entry ) throws Exception
     {
         Collection<BaseType> coreTypes = userSchema.getCoreAttributes();
 
         User user = new User();
 
+        ctx.setUser( user );
+        
         for ( BaseType bt : coreTypes )
         {
             if ( bt instanceof SimpleType )
@@ -229,7 +233,7 @@ public class LdapResourceProvider implem
                     continue;
                 }
 
-                SimpleAttribute at = getValueInto( st, entry );
+                SimpleAttribute at = getValueForSimpleType( st, entry, ctx );
                 if ( at != null )
                 {
                     user.addAttribute( bt.getUri(), at );
@@ -244,6 +248,15 @@ public class LdapResourceProvider implem
                     continue;
                 }
 
+                String atHandler = ct.getAtHandlerName();
+                
+                if( atHandler != null )
+                {
+                    AttributeHandler handler = userSchema.getHandler( atHandler );
+                    handler.handle( ct, entry, ctx );
+                    continue;
+                }
+
                 List<SimpleAttribute> lstAts = getValuesInto( ct.getAtGroup(), entry );
 
                 if ( !lstAts.isEmpty() )
@@ -261,6 +274,15 @@ public class LdapResourceProvider implem
                     continue;
                 }
 
+                String atHandler = bt.getAtHandlerName();
+                
+                if( atHandler != null )
+                {
+                    AttributeHandler handler = userSchema.getHandler( atHandler );
+                    handler.handle( bt, entry, ctx );
+                    continue;
+                }
+
                 List<TypedType> typedList = mt.getTypedList();
                 SimpleTypeGroup stg = mt.getStGroup();
 
@@ -411,7 +433,7 @@ public class LdapResourceProvider implem
 
             for ( SimpleType type : types )
             {
-                SimpleAttribute st = getValueInto( type, entry );
+                SimpleAttribute st = getValueForSimpleType( type, entry );
 
                 if ( st != null )
                 {
@@ -431,7 +453,23 @@ public class LdapResourceProvider implem
     }
 
 
-    public SimpleAttribute getValueInto( SimpleType st, Entry entry ) throws LdapException
+    public SimpleAttribute getValueForSimpleType( SimpleType st, Entry entry, RequestContext ctx ) throws LdapException
+    {
+        String atHandler = st.getAtHandlerName();
+        
+        if( atHandler != null )
+        {
+            AttributeHandler handler = userSchema.getHandler( atHandler );
+            handler.handle( st, entry, ctx );
+            return null;
+        }
+        else
+        {
+            return getValueForSimpleType( st, entry );
+        }
+    }
+    
+    public SimpleAttribute getValueForSimpleType( SimpleType st, Entry entry ) throws LdapException
     {
         String name = st.getName();
         Attribute at = entry.get( st.getMappedTo() );
@@ -522,17 +560,18 @@ public class LdapResourceProvider implem
     }
 
 
-    //    public List<SimpleAttribute> getValuesInto( List<SimpleType> lstTyps, Entry entry ) throws LdapException
-    //    {
-    //    }
-
+//    public List<SimpleAttribute> getValuesInto( SimpleTypeGroup stg, RequestContext ctx ) throws LdapException
+//    {
+//        
+//    }
+    
     public List<SimpleAttribute> getValuesInto( SimpleTypeGroup stg, Entry entry ) throws LdapException
     {
         List<SimpleAttribute> lstAts = new ArrayList<SimpleAttribute>();
 
         for ( SimpleType st : stg.getLstSTypes() )
         {
-            SimpleAttribute at = getValueInto( st, entry );
+            SimpleAttribute at = getValueForSimpleType( st, entry );
             if ( at != null )
             {
                 lstAts.add( at );
@@ -584,7 +623,7 @@ public class LdapResourceProvider implem
 
         System.out.println( entry );
         LdapResourceProvider lr = new LdapResourceProvider( c );
-        User user = lr.toUser( entry );
+        User user = lr.toUser( new RequestContext(), entry );
         System.out.println( user );
         System.out.println( ResourceSerializer.serialize( user ) );
         c.close();

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/LdapSchemaMapper.java Fri Aug  9 11:05:12 2013
@@ -25,6 +25,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -33,8 +34,8 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.schema.SchemaManager;
 import org.apache.directory.api.util.Strings;
 import org.apache.directory.ldap.client.api.LdapConnection;
+import org.apache.directory.scim.AttributeHandler;
 import org.apache.directory.scim.SchemaMapper;
-import org.apache.directory.scim.ldap.schema.BaseType;
 import org.apache.directory.scim.ldap.schema.ComplexType;
 import org.apache.directory.scim.ldap.schema.MultiValType;
 import org.apache.directory.scim.ldap.schema.ResourceSchema;
@@ -42,6 +43,7 @@ import org.apache.directory.scim.ldap.sc
 import org.apache.directory.scim.ldap.schema.SimpleTypeGroup;
 import org.apache.directory.scim.ldap.schema.TypedType;
 import org.apache.directory.scim.ldap.schema.UserSchema;
+import org.apache.directory.scim.schema.BaseType;
 import org.dom4j.Document;
 import org.dom4j.DocumentHelper;
 import org.dom4j.Element;
@@ -136,7 +138,10 @@ public class LdapSchemaMapper implements
             String baseDn = elmUser.attributeValue( "baseDn" );
             String filter = elmUser.attributeValue( "filter" );
 
+            Map<String, AttributeHandler> atHandlersMap = loadAtHandlers( root.element( "atHandlers" ) );
+            
             userSchema = new UserSchema( baseDn, filter );
+            userSchema.setAtHandlers( atHandlersMap );
 
             List<Element> lstSchema = root.elements( "schema" );
             List<Element> lstRef = elmUser.elements( "schemaRef" );
@@ -227,16 +232,32 @@ public class LdapSchemaMapper implements
 
             boolean show = getShowVal( elmComplex );
             
-            List<SimpleType> stList = new ArrayList<SimpleType>();
-
             Element atGrpElm = elmComplex.element( "at-group" );
             SimpleTypeGroup stg = parseAtGroup( atGrpElm, uri );
+            ComplexType ct = null;
             if ( stg != null )
             {
-                ComplexType ct = new ComplexType( uri, name, show, stg );
+                ct = new ComplexType( uri, name, show, stg );
+            }
+            
+            String handlerRef = elmComplex.attributeValue( "handlerRef" );
+            
+            if( Strings.isEmpty( handlerRef ) ) 
+            {
+                handlerRef = null;
+            }
+            
+            // if attribute handler is present then create the type
+            if( ( ct == null ) && ( handlerRef != null ) )
+            {
+                ct = new ComplexType( uri, name, show, null );
+            }
+            
+            if( ct != null )
+            {
+                ct.setAtHandlerName( handlerRef );
                 resourceSchema.addAttributeType( name, ct );
             }
-
         }
 
         // load multival-attributes
@@ -257,14 +278,15 @@ public class LdapSchemaMapper implements
 
             boolean showMultiVal = getShowVal( elmMultiVal );
             
+            MultiValType ct = null;
+            
             Element elmAtGroup = elmMultiVal.element( "at-group" );
             if ( elmAtGroup != null )
             {
                 SimpleTypeGroup stg = parseAtGroup( elmAtGroup, uri );
                 if ( stg != null )
                 {
-                    MultiValType ct = new MultiValType( uri, name, showMultiVal, stg, baseDn, filter );
-                    resourceSchema.addAttributeType( name, ct );
+                    ct = new MultiValType( uri, name, showMultiVal, stg, baseDn, filter );
                 }
 
             }
@@ -300,7 +322,24 @@ public class LdapSchemaMapper implements
                     lstTypes.add( tt );
                 }
 
-                MultiValType ct = new MultiValType( uri, name, showMultiVal, lstTypes, baseDn, filter );
+                ct = new MultiValType( uri, name, showMultiVal, lstTypes, baseDn, filter );
+            }
+            
+            String handlerRef = elmMultiVal.attributeValue( "handlerRef" );
+            
+            if( Strings.isEmpty( handlerRef ) ) 
+            {
+                handlerRef = null;
+            }
+
+            if( ( ct == null ) && ( handlerRef != null ) )
+            {
+                ct = new MultiValType( uri, name, showMultiVal, ( SimpleTypeGroup ) null, baseDn, filter );
+            }
+            
+            if( ct != null )
+            {
+                ct.setAtHandlerName( handlerRef );
                 resourceSchema.addAttributeType( name, ct );
             }
         }
@@ -355,22 +394,20 @@ public class LdapSchemaMapper implements
         }
 
         String mappedTo = el.attributeValue( "mappedTo" );
+        String handlerRef = el.attributeValue( "handlerRef" );
 
-        if ( Strings.isEmpty( mappedTo ) )
+        if ( Strings.isEmpty( mappedTo ) && Strings.isEmpty( handlerRef ) )
         {
-            LOG.debug( "No LDAP attribute was mapped to the SCIM attribute {}, skipping", name );
+            LOG.debug( "Neither LDAP attribute or a attribute handler was mapped to the SCIM attribute {}, skipping", name );
             return null;
         }
 
-        boolean show = true;
-
-        String showVal = el.attributeValue( "show" );
-        if ( !Strings.isEmpty( showVal ) )
-        {
-            show = Boolean.parseBoolean( showVal );
-        }
+        boolean show = getShowVal( el );
 
-        return new SimpleType( uri, name, show, mappedTo );
+        SimpleType st = new SimpleType( uri, name, show, mappedTo );
+        st.setAtHandlerName( handlerRef );
+        
+        return st;
     }
     
     private boolean getShowVal(Element el)
@@ -384,4 +421,41 @@ public class LdapSchemaMapper implements
         
         return Boolean.parseBoolean( showVal );
     }
+    
+    
+    private Map<String, AttributeHandler> loadAtHandlers(Element atHndlrRoot)
+    {
+        if( atHndlrRoot == null )
+        {
+            return Collections.EMPTY_MAP;
+        }
+        
+        Map<String, AttributeHandler> mapHandlers = new HashMap<String, AttributeHandler>();
+        
+        List<Element> elmHandlerList = atHndlrRoot.elements( "handler" );
+        
+        for( Element el : elmHandlerList )
+        {
+            String fqcn = el.attributeValue( "class" );
+            String name = el.attributeValue( "name" );
+            
+            if( Strings.isEmpty( name ) )
+            {
+                throw new IllegalStateException( "Name is missing in the handler element " + el.asXML() );
+            }
+            
+            try
+            {
+                AttributeHandler handler = (AttributeHandler ) Class.forName( fqcn ).newInstance();
+                mapHandlers.put( name, handler );
+            }
+            catch( Exception e )
+            {
+                throw new RuntimeException( "Failed to load the attribute handler " + fqcn, e );
+            }
+        }
+        
+        return mapHandlers;
+    }
+    
 }

Added: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java?rev=1512252&view=auto
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java (added)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/handlers/ActiveAttributeHandler.java Fri Aug  9 11:05:12 2013
@@ -0,0 +1,81 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.directory.scim.ldap.handlers;
+
+import org.apache.directory.api.ldap.model.constants.PasswordPolicySchemaConstants;
+import org.apache.directory.api.ldap.model.entry.Attribute;
+import org.apache.directory.api.ldap.model.entry.Entry;
+import org.apache.directory.api.ldap.model.exception.LdapException;
+import org.apache.directory.scim.AttributeHandler;
+import org.apache.directory.scim.RequestContext;
+import org.apache.directory.scim.SimpleAttribute;
+import org.apache.directory.scim.schema.BaseType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO ActiveAttributeHandler.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class ActiveAttributeHandler implements AttributeHandler
+{
+
+    private static final Logger LOG = LoggerFactory.getLogger( ActiveAttributeHandler.class );
+    
+    @Override
+    public void handle( BaseType bt, Object srcResource, RequestContext ctx )
+    {
+        if( !bt.getName().equals( "active" ) )
+        {
+            LOG.debug( "ActiveAttributeHandler can  only be called on the active attribute, invalid attribute name {}", bt.getName() );
+            return;
+        }
+        
+        Entry entry = ( Entry ) srcResource;
+        
+        Attribute lockAt = entry.get( PasswordPolicySchemaConstants.PWD_ACCOUNT_LOCKED_TIME_AT );
+        
+        SimpleAttribute st = null;
+        
+        if( lockAt != null )
+        {
+            try
+            {
+                if( "000001010000Z".equals( lockAt.getString() ) )
+                {
+                    st = new SimpleAttribute( bt.getName(), Boolean.FALSE );
+                }
+            }
+            catch( LdapException e )
+            {
+                LOG.warn( "Failed to get the value for the attribute {}", bt.getName(), e );
+            }
+        }
+        
+        if ( st == null )
+        {
+            st = new SimpleAttribute( bt.getName(), Boolean.TRUE );
+        }
+        
+        ctx.getUser().addAttribute( bt.getUri(), st );
+    }
+
+    }

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ComplexType.java Fri Aug  9 11:05:12 2013
@@ -22,6 +22,8 @@ package org.apache.directory.scim.ldap.s
 
 import java.util.List;
 
+import org.apache.directory.scim.schema.BaseType;
+
 
 /**
  * TODO SimpleType.

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/MultiValType.java Fri Aug  9 11:05:12 2013
@@ -22,6 +22,8 @@ package org.apache.directory.scim.ldap.s
 
 import java.util.List;
 
+import org.apache.directory.scim.schema.BaseType;
+
 
 /**
  * TODO SimpleType.

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/ResourceSchema.java Fri Aug  9 11:05:12 2013
@@ -27,6 +27,9 @@ import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.directory.scim.AttributeHandler;
+import org.apache.directory.scim.schema.BaseType;
+
 
 /**
  * 
@@ -44,6 +47,8 @@ public abstract class ResourceSchema
     private Map<String, BaseType> coreTypes = new LinkedHashMap<String, BaseType>();
     private Map<String, BaseType> extendedTypes = new LinkedHashMap<String, BaseType>();
 
+    private Map<String, AttributeHandler> atHandlers = new HashMap<String, AttributeHandler>();
+
 
     public ResourceSchema( String baseDn, String filter )
     {
@@ -80,6 +85,18 @@ public abstract class ResourceSchema
     }
 
 
+    public void addAttributeHandler( String name, AttributeHandler handler )
+    {
+        atHandlers.put( name, handler );
+    }
+
+
+    public AttributeHandler getHandler( String name )
+    {
+        return atHandlers.get( name );
+    }
+
+
     public Collection<BaseType> getCoreAttributes()
     {
         return coreTypes.values();
@@ -92,6 +109,12 @@ public abstract class ResourceSchema
     }
 
 
+    public void setAtHandlers( Map<String, AttributeHandler> atHandlers )
+    {
+        this.atHandlers = atHandlers;
+    }
+
+
     /**
      * @return the baseDn
      */

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/SimpleType.java Fri Aug  9 11:05:12 2013
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.scim.ldap.schema;
 
+import org.apache.directory.scim.schema.BaseType;
+
 
 /**
  * TODO SimpleType.

Modified: directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java (original)
+++ directory/escimo/trunk/ldap/src/main/java/org/apache/directory/scim/ldap/schema/TypedType.java Fri Aug  9 11:05:12 2013
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.scim.ldap.schema;
 
+import org.apache.directory.scim.schema.BaseType;
+
 
 /**
  * TODO SimpleType.

Modified: directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml (original)
+++ directory/escimo/trunk/ldap/src/main/resources/escimo-ldap-mapping.xml Fri Aug  9 11:05:12 2013
@@ -11,7 +11,7 @@
         <attribute name="preferredLanguage" mappedTo="preferredLanguage" />
         <attribute name="locale" mappedTo="" />
         <attribute name="timezone" mappedTo="" />
-        <attribute name="active" mappedTo="" />
+        <attribute name="active" handlerRef="activeHandler" />
         <attribute name="password" show="false" mappedTo="userPassword" />
 
         <complex-attribute name="name">
@@ -108,4 +108,9 @@
     <groupType basedDn="ou=system" filter="(objectClass = inetOrgPerson)">
         <schemaRef id="group" />
     </groupType>
+ 
+    <atHandlers>
+        <handler name="activeHandler"
+            class="org.apache.directory.scim.ldap.handlers.ActiveAttributeHandler" />
+    </atHandlers>
 </entities>
\ No newline at end of file

Modified: directory/escimo/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/pom.xml?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/server/pom.xml (original)
+++ directory/escimo/trunk/server/pom.xml Fri Aug  9 11:05:12 2013
@@ -24,12 +24,6 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.wink</groupId>
-            <artifactId>wink-server</artifactId>
-            <version>${wink.version}</version>
-        </dependency>
-
-        <dependency>
             <groupId>${project.groupId}</groupId>
             <artifactId>escimo-common</artifactId>
             <version>${project.version}</version>

Modified: directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java
URL: http://svn.apache.org/viewvc/directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java?rev=1512252&r1=1512251&r2=1512252&view=diff
==============================================================================
--- directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java (original)
+++ directory/escimo/trunk/server/src/main/java/org/apache/directory/scim/rest/UserService.java Fri Aug  9 11:05:12 2013
@@ -29,6 +29,7 @@ import javax.ws.rs.core.Response.Status;
 import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.core.Response.ResponseBuilder;
 
+import org.apache.directory.scim.RequestContext;
 import org.apache.directory.scim.ProviderService;
 import org.apache.directory.scim.ResourceNotFoundException;
 import org.apache.directory.scim.User;
@@ -42,21 +43,20 @@ import org.apache.directory.scim.json.Re
 public class UserService
 {
 
-    @Context
-    UriInfo uriInfo;
-    
     private ProviderService provider = ServerInitializer.getProvider();
     
     @GET
     @Produces({MediaType.APPLICATION_JSON})
     @Path("{id}")
-    public Response getUser( @PathParam("id") String userId )
+    public Response getUser( @PathParam("id") String userId, @Context UriInfo uriInfo )
     {
         ResponseBuilder rb = null;
         
         try
         {
-            User user = provider.getUser( userId );
+            RequestContext ctx = new RequestContext();
+            
+            User user = provider.getUser( ctx, userId );
             String json = ResourceSerializer.serialize( user );
             rb = Response.ok( json, MediaType.APPLICATION_JSON );
         }