View Javadoc

1   /**
2    * Copyright 2005-2013 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.ldap;
17  
18  import org.kuali.rice.kim.api.identity.name.EntityName;
19  import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
20  import org.springframework.ldap.core.ContextMapper;
21  import org.springframework.ldap.core.DirContextOperations;
22  
23  /**
24   * 
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class EntityNamePrincipalNameMapper extends BaseMapper<EntityNamePrincipalName> {
28  
29      private ContextMapper defaultNameMapper;
30      
31      @Override
32      EntityNamePrincipalName mapDtoFromContext(DirContextOperations context) {
33          EntityNamePrincipalName.Builder builder = mapBuilderFromContext(context);
34          return builder != null ? builder.build() : null;
35      }
36      
37      EntityNamePrincipalName.Builder mapBuilderFromContext(DirContextOperations context) {
38          final EntityNamePrincipalName.Builder person = EntityNamePrincipalName.Builder.create();
39          person.setDefaultName((EntityName.Builder) getDefaultNameMapper().mapFromContext(context));
40          person.setPrincipalName(context.getStringAttribute(getConstants().getKimLdapNameProperty()));
41          return person;
42      }
43  
44      /**
45       * Gets the value of defaultNameMapper
46       *
47       * @return the value of defaultNameMapper
48       */
49      public final ContextMapper getDefaultNameMapper() {
50          return this.defaultNameMapper;
51      }
52  
53      /**
54       * Sets the value of defaultNameMapper
55       *
56       * @param argDefaultNameMapper Value to assign to this.defaultNameMapper
57       */
58      public final void setDefaultNameMapper(final ContextMapper argDefaultNameMapper) {
59          this.defaultNameMapper = argDefaultNameMapper;
60      }
61  }