Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7793D10BAE for ; Fri, 9 Aug 2013 11:05:37 +0000 (UTC) Received: (qmail 68988 invoked by uid 500); 9 Aug 2013 11:05:37 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 68953 invoked by uid 500); 9 Aug 2013 11:05:37 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 68946 invoked by uid 99); 9 Aug 2013 11:05:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Aug 2013 11:05:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 09 Aug 2013 11:05:34 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 20A2023889E0; Fri, 9 Aug 2013 11:05:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Fri, 09 Aug 2013 11:05:13 -0000 To: commits@directory.apache.org From: kayyagari@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130809110514.20A2023889E0@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 @@ eSCIMo common API + + + org.apache.wink + wink-server + ${wink.version} + com.google.code.gson gson 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 Apache Directory Project + */ +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 Apache Directory Project + */ +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 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 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 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 getValuesInto( List lstTyps, Entry entry ) throws LdapException - // { - // } - +// public List getValuesInto( SimpleTypeGroup stg, RequestContext ctx ) throws LdapException +// { +// +// } + public List getValuesInto( SimpleTypeGroup stg, Entry entry ) throws LdapException { List lstAts = new ArrayList(); 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 atHandlersMap = loadAtHandlers( root.element( "atHandlers" ) ); + userSchema = new UserSchema( baseDn, filter ); + userSchema.setAtHandlers( atHandlersMap ); List lstSchema = root.elements( "schema" ); List lstRef = elmUser.elements( "schemaRef" ); @@ -227,16 +232,32 @@ public class LdapSchemaMapper implements boolean show = getShowVal( elmComplex ); - List stList = new ArrayList(); - 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 loadAtHandlers(Element atHndlrRoot) + { + if( atHndlrRoot == null ) + { + return Collections.EMPTY_MAP; + } + + Map mapHandlers = new HashMap(); + + List 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 Apache Directory Project + */ +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 coreTypes = new LinkedHashMap(); private Map extendedTypes = new LinkedHashMap(); + private Map atHandlers = new HashMap(); + 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 getCoreAttributes() { return coreTypes.values(); @@ -92,6 +109,12 @@ public abstract class ResourceSchema } + public void setAtHandlers( Map 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 @@ - + @@ -108,4 +108,9 @@ + + + + \ 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 @@ - org.apache.wink - wink-server - ${wink.version} - - - ${project.groupId} escimo-common ${project.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 ); }