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
021package org.apache.directory.shared.ldap.model.schema.normalizers;
022
023
024import org.apache.directory.shared.ldap.model.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 */
032public interface NameComponentNormalizer
033{
034    /**
035     * Checks to see if an attribute name/oid is defined.
036     * 
037     * @param id
038     *            the name/oid of the attribute to see if it is defined
039     * @return true if it is, false otherwise
040     */
041    boolean isDefined( String id );
042
043    /**
044     * Normalizes the attribute name/alias to use the OID for it instead.
045     * 
046     * @param attributeName the name or OID of the attributeType
047     * @return the OID of the attributeType if it is recognized
048     * @throws LdapException if the attributeName is not recognized as a valid alias
049     */
050    String normalizeName( String attributeName ) throws LdapException;
051
052    /**
053     * Normalizes an attribute's value given the name of the attribute - short
054     * names like 'cn' as well as 'commonName' should work here.
055     * 
056     * @param attributeName
057     *            the name of the attribute
058     * @param value
059     *            the value of the attribute to normalize
060     * @return the normalized value
061     * @throws LdapException
062     *             if there is a recognition problem or a syntax issue
063     */
064    Object normalizeByName( String attributeName, String value ) throws LdapException;
065
066
067    /**
068     * Normalizes an attribute's value given the name of the attribute - short
069     * names like 'cn' as well as 'commonName' should work here.
070     * 
071     * @param attributeName
072     *            the name of the attribute
073     * @param value
074     *            the value of the attribute to normalize
075     * @return the normalized value
076     * @throws LdapException
077     *             if there is a recognition problem or a syntax issue
078     */
079    Object normalizeByName( String attributeName, byte[] value ) throws LdapException;
080
081
082    /**
083     * Normalizes an attribute's value given the OID of the attribute.
084     * 
085     * @param attributeOid
086     *            the OID of the attribute
087     * @param value
088     *            the value of the attribute to normalize
089     * @return the normalized value
090     * @throws LdapException
091     *             if there is a recognition problem or a syntax issue
092     */
093    Object normalizeByOid( String attributeOid, String value ) throws LdapException;
094
095
096    /**
097     * Normalizes an attribute's value given the OID of the attribute.
098     * 
099     * @param attributeOid
100     *            the OID of the attribute
101     * @param value
102     *            the value of the attribute to normalize
103     * @return the normalized value
104     * @throws LdapException
105     *             if there is a recognition problem or a syntax issue
106     */
107    Object normalizeByOid( String attributeOid, byte[] value ) throws LdapException;
108}