View Javadoc
1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    https://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  
21  package org.apache.directory.api.ldap.model.schema.normalizers;
22  
23  
24  import org.apache.directory.api.ldap.model.exception.LdapException;
25  import org.apache.directory.api.ldap.model.schema.AttributeType;
26  
27  
28  /**
29   * Normalizers of ldap name component attributes and their values.
30   * 
31   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
32   */
33  public interface NameComponentNormalizer
34  {
35      /**
36       * Checks to see if an attribute name/oid is defined.
37       * 
38       * @param id
39       *            the name/oid of the attribute to see if it is defined
40       * @return true if it is, false otherwise
41       */
42      boolean isDefined( String id );
43  
44  
45      /**
46       * Normalizes the attribute name/alias to use the OID for it instead.
47       * 
48       * @param attributeName the name or OID of the attributeType
49       * @return the OID of the attributeType if it is recognized
50       * @throws LdapException if the attributeName is not recognized as a valid alias
51       */
52      String normalizeName( String attributeName ) throws LdapException;
53  
54  
55      /**
56       * Normalizes an attribute's value given the name of the attribute - short
57       * names like 'cn' as well as 'commonName' should work here.
58       * 
59       * @param attributeName
60       *            the name of the attribute
61       * @param value
62       *            the value of the attribute to normalize
63       * @return the normalized value
64       * @throws LdapException
65       *             if there is a recognition problem or a syntax issue
66       */
67      Object normalizeByName( String attributeName, String value ) throws LdapException;
68  
69  
70      /**
71       * Normalizes an attribute's value given the name of the attribute - short
72       * names like 'cn' as well as 'commonName' should work here.
73       * 
74       * @param attributeType the attributeType
75       * @param value the value of the attribute to normalize
76       * @return the normalized value
77       * @throws LdapException if there is a recognition problem or a syntax issue
78       */
79      Object normalizeByName( AttributeType attributeType, String value ) throws LdapException;
80  
81  
82      /**
83       * Normalizes an attribute's value given the name of the attribute - short
84       * names like 'cn' as well as 'commonName' should work here.
85       * 
86       * @param attributeName
87       *            the name of the attribute
88       * @param value
89       *            the value of the attribute to normalize
90       * @return the normalized value
91       * @throws LdapException
92       *             if there is a recognition problem or a syntax issue
93       */
94      Object normalizeByName( String attributeName, byte[] value ) throws LdapException;
95  
96  
97      /**
98       * Normalizes an attribute's value given the OID of the attribute.
99       * 
100      * @param attributeOid
101      *            the OID of the attribute
102      * @param value
103      *            the value of the attribute to normalize
104      * @return the normalized value
105      * @throws LdapException
106      *             if there is a recognition problem or a syntax issue
107      */
108     Object normalizeByOid( String attributeOid, String value ) throws LdapException;
109 
110 
111     /**
112      * Normalizes an attribute's value given the OID of the attribute.
113      * 
114      * @param attributeOid
115      *            the OID of the attribute
116      * @param value
117      *            the value of the attribute to normalize
118      * @return the normalized value
119      * @throws LdapException
120      *             if there is a recognition problem or a syntax issue
121      */
122     Object normalizeByOid( String attributeOid, byte[] value ) throws LdapException;
123 }