001    /*
002     *  Licensed to the Apache Software Foundation (ASF) under one
003     *  or more contributor license agreements.  See the NOTICE file
004     *  distributed with this work for additional information
005     *  regarding copyright ownership.  The ASF licenses this file
006     *  to you under the Apache License, Version 2.0 (the
007     *  "License"); you may not use this file except in compliance
008     *  with the License.  You may obtain a copy of the License at
009     *  
010     *    http://www.apache.org/licenses/LICENSE-2.0
011     *  
012     *  Unless required by applicable law or agreed to in writing,
013     *  software distributed under the License is distributed on an
014     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015     *  KIND, either express or implied.  See the License for the
016     *  specific language governing permissions and limitations
017     *  under the License. 
018     *  
019     */
020    
021    package org.apache.directory.shared.ldap.name;
022    
023    
024    import org.apache.directory.shared.ldap.exception.LdapException;
025    
026    
027    /**
028     * Normalizers of ldap name component attributes and their values.
029     * 
030     * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
031     * @version $Revision: 923524 $
032     */
033    public interface NameComponentNormalizer
034    {
035        /**
036         * Checks to see if an attribute name/oid is defined.
037         * 
038         * @param id
039         *            the name/oid of the attribute to see if it is defined
040         * @return true if it is, false otherwise
041         */
042        boolean isDefined( String id );
043    
044        /**
045         * Normalizes the attribute name/alias to use the OID for it instead.
046         * 
047         * @param attributeName the name or OID of the attributeType
048         * @return the OID of the attributeType if it is recognized
049         * @throws LdapException if the attributeName is not recognized as a valid alias
050         */
051        String normalizeName( String attributeName ) throws LdapException;
052    
053        /**
054         * Normalizes an attribute's value given the name of the attribute - short
055         * names like 'cn' as well as 'commonName' should work here.
056         * 
057         * @param attributeName
058         *            the name of the attribute
059         * @param value
060         *            the value of the attribute to normalize
061         * @return the normalized value
062         * @throws LdapException
063         *             if there is a recognition problem or a syntax issue
064         */
065        Object normalizeByName( String attributeName, String value ) throws LdapException;
066    
067    
068        /**
069         * Normalizes an attribute's value given the name of the attribute - short
070         * names like 'cn' as well as 'commonName' should work here.
071         * 
072         * @param attributeName
073         *            the name of the attribute
074         * @param value
075         *            the value of the attribute to normalize
076         * @return the normalized value
077         * @throws LdapException
078         *             if there is a recognition problem or a syntax issue
079         */
080        Object normalizeByName( String attributeName, byte[] value ) throws LdapException;
081    
082    
083        /**
084         * Normalizes an attribute's value given the OID of the attribute.
085         * 
086         * @param attributeOid
087         *            the OID of the attribute
088         * @param value
089         *            the value of the attribute to normalize
090         * @return the normalized value
091         * @throws LdapException
092         *             if there is a recognition problem or a syntax issue
093         */
094        Object normalizeByOid( String attributeOid, String value ) throws LdapException;
095    
096    
097        /**
098         * Normalizes an attribute's value given the OID of the attribute.
099         * 
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, byte[] value ) throws LdapException;
109    }