View Javadoc

1   /*
2    * Copyright 2010 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.springframework.ldap.core.ContextMapper;
19  import org.springframework.ldap.core.DirContextOperations;
20  import org.springframework.ldap.core.support.AbstractContextMapper;
21  
22  import org.kuali.rice.kim.api.identity.name.EntityName;
23  import org.kuali.rice.kim.api.identity.principal.EntityNamePrincipalName;
24  import org.kuali.rice.kim.util.Constants;
25  
26  /**
27   * 
28   * @author Kuali Rice Team (rice.collab@kuali.org)
29   */
30  public class EntityNamePrincipalNameMapper extends AbstractContextMapper {
31      private Constants constants;
32  
33      private ContextMapper defaultNameMapper;
34      
35      public EntityNamePrincipalName mapFromContext(DirContextOperations context) {
36          return ((EntityNamePrincipalName.Builder) doMapFromContext(context)).build();
37      }
38      
39      public Object doMapFromContext(DirContextOperations context) {
40          final EntityNamePrincipalName.Builder person = EntityNamePrincipalName.Builder.create();
41          person.setDefaultName((EntityName.Builder) getDefaultNameMapper().mapFromContext(context));
42          person.setPrincipalName(context.getStringAttribute(getConstants().getKimLdapNameProperty()));
43          return person;
44      }
45      
46      /**
47       * Gets the value of constants
48       *
49       * @return the value of constants
50       */
51      public final Constants getConstants() {
52          return this.constants;
53      }
54  
55      /**
56       * Sets the value of constants
57       *
58       * @param argConstants Value to assign to this.constants
59       */
60      public final void setConstants(final Constants argConstants) {
61          this.constants = argConstants;
62      }
63  
64  
65      /**
66       * Gets the value of defaultNameMapper
67       *
68       * @return the value of defaultNameMapper
69       */
70      public final ContextMapper getDefaultNameMapper() {
71          return this.defaultNameMapper;
72      }
73  
74      /**
75       * Sets the value of defaultNameMapper
76       *
77       * @param argDefaultNameMapper Value to assign to this.defaultNameMapper
78       */
79      public final void setDefaultNameMapper(final ContextMapper argDefaultNameMapper) {
80          this.defaultNameMapper = argDefaultNameMapper;
81      }
82  }