当前位置: 首页>>代码示例>>Java>>正文


Java LdapInvalidAttributeTypeException类代码示例

本文整理汇总了Java中org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException的典型用法代码示例。如果您正苦于以下问题:Java LdapInvalidAttributeTypeException类的具体用法?Java LdapInvalidAttributeTypeException怎么用?Java LdapInvalidAttributeTypeException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LdapInvalidAttributeTypeException类属于org.apache.directory.api.ldap.model.exception包,在下文中一共展示了LdapInvalidAttributeTypeException类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compare

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean compare( CompareOperationContext compareContext ) throws LdapException
{
    if ( IS_DEBUG )
    {
        LOG.debug( "Operation Context: {}", compareContext );
    }

    // Check that the requested AT exists
    // complain if we do not recognize the attribute being compared
    if ( !schemaManager.getAttributeTypeRegistry().contains( compareContext.getOid() ) )
    {
        throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_266, compareContext.getOid() ) );
    }

    boolean result = next( compareContext );

    return result;
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:22,代码来源:SchemaInterceptor.java

示例2: toEntry

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
/**
 * Convert a BasicAttributes or a AttributesImpl to an Entry
 *
 * @param attributes the BasicAttributes or AttributesImpl instance to convert
 * @param dn The Dn which is needed by the Entry
 * @return An instance of a Entry object
 * 
 * @throws LdapException If we get an invalid attribute
 */
public static Entry toEntry( Attributes attributes, Dn dn ) throws LdapException
{
    if ( attributes instanceof BasicAttributes )
    {
        try
        {
            Entry entry = new DefaultEntry( dn );

            for ( NamingEnumeration<? extends javax.naming.directory.Attribute> attrs = attributes.getAll(); attrs
                .hasMoreElements(); )
            {
                javax.naming.directory.Attribute attr = attrs.nextElement();

                Attribute entryAttribute = toApiAttribute( attr );

                if ( entryAttribute != null )
                {
                    entry.put( entryAttribute );
                }
            }

            return entry;
        }
        catch ( LdapException ne )
        {
            throw new LdapInvalidAttributeTypeException( ne.getMessage(), ne );
        }
    }
    else
    {
        return null;
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:43,代码来源:AttributeUtils.java

示例3: toServerEntry

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
/**
 * Convert a BasicAttributes or a AttributesImpl to a ServerEntry
 *
 * @param attributes the BasicAttributes or AttributesImpl instance to convert
 * @param registries The registries, needed ro build a ServerEntry
 * @param dn The Dn which is needed by the ServerEntry
 * @return An instance of a ServerEntry object
 * 
 * @throws LdapInvalidAttributeTypeException If we get an invalid attribute
 */
public static Entry toServerEntry( Attributes attributes, Dn dn, SchemaManager schemaManager )
    throws LdapInvalidAttributeTypeException
{
    if ( attributes instanceof BasicAttributes )
    {
        try
        {
            Entry entry = new DefaultEntry( schemaManager, dn );

            for ( NamingEnumeration<? extends javax.naming.directory.Attribute> attrs = attributes.getAll(); attrs
                .hasMoreElements(); )
            {
                javax.naming.directory.Attribute attr = attrs.nextElement();

                String attributeId = attr.getID();
                String id = SchemaUtils.stripOptions( attributeId );
                Set<String> options = SchemaUtils.getOptions( attributeId );
                // TODO : handle options.
                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id );
                Attribute serverAttribute = ServerEntryUtils.toServerAttribute( attr, attributeType );

                if ( serverAttribute != null )
                {
                    entry.put( serverAttribute );
                }
            }

            return entry;
        }
        catch ( LdapException ne )
        {
            throw new LdapInvalidAttributeTypeException( ne.getLocalizedMessage() );
        }
    }
    else
    {
        return null;
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:50,代码来源:ServerEntryUtils.java

示例4: toServerAttribute

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
/**
 * Convert a BasicAttribute or a AttributeImpl to a ServerAtribute
 *
 * @param attribute the BasicAttributes or AttributesImpl instance to convert
 * @param attributeType
 * @return An instance of a ServerEntry object
 * 
 * @throws InvalidAttributeIdentifierException If we had an incorrect attribute
 */
public static Attribute toServerAttribute( javax.naming.directory.Attribute attribute, AttributeType attributeType )
    throws LdapException
{
    if ( attribute == null )
    {
        return null;
    }

    try
    {
        Attribute serverAttribute = new DefaultAttribute( attributeType );

        for ( NamingEnumeration<?> values = attribute.getAll(); values.hasMoreElements(); )
        {
            Object value = values.nextElement();
            int nbAdded = 0;

            if ( value == null )
            {
                continue;
            }

            if ( serverAttribute.isHumanReadable() )
            {
                if ( value instanceof String )
                {
                    nbAdded = serverAttribute.add( ( String ) value );
                }
                else if ( value instanceof byte[] )
                {
                    nbAdded = serverAttribute.add( Strings.utf8ToString( ( byte[] ) value ) );
                }
                else
                {
                    throw new LdapInvalidAttributeTypeException();
                }
            }
            else
            {
                if ( value instanceof String )
                {
                    nbAdded = serverAttribute.add( Strings.getBytesUtf8( ( String ) value ) );
                }
                else if ( value instanceof byte[] )
                {
                    nbAdded = serverAttribute.add( ( byte[] ) value );
                }
                else
                {
                    throw new LdapInvalidAttributeTypeException();
                }
            }

            if ( nbAdded == 0 )
            {
                throw new LdapInvalidAttributeTypeException();
            }
        }

        return serverAttribute;
    }
    catch ( NamingException ne )
    {
        throw new LdapInvalidAttributeTypeException();
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:76,代码来源:ServerEntryUtils.java

示例5: toServerModification

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
public static List<Modification> toServerModification( Modification[] modifications,
    SchemaManager schemaManager ) throws LdapException
{
    if ( modifications != null )
    {
        List<Modification> modificationsList = new ArrayList<Modification>();

        for ( Modification modification : modifications )
        {
            String attributeId = modification.getAttribute().getUpId();
            String id = stripOptions( attributeId );
            modification.getAttribute().setUpId( id );
            Set<String> options = getOptions( attributeId );

            // -------------------------------------------------------------------
            // DIRSERVER-646 Fix: Replacing an unknown attribute with no values 
            // (deletion) causes an error
            // -------------------------------------------------------------------
            if ( !schemaManager.getAttributeTypeRegistry().contains( id )
                && modification.getAttribute().size() == 0
                && modification.getOperation() == ModificationOperation.REPLACE_ATTRIBUTE )
            {
                // The attributeType does not exist in the schema.
                // It's an error
                String message = I18n.err( I18n.ERR_467, id );
                throw new LdapInvalidAttributeTypeException( message );
            }
            else
            {
                // TODO : handle options
                AttributeType attributeType = null;
                try {
                	attributeType = schemaManager.lookupAttributeTypeRegistry( id );
                } catch (LdapNoSuchAttributeException e) {
                	attributeType = ApacheDSUtil.addAttributeToSchema(modification.getAttribute(), schemaManager);
                }
                modificationsList.add( toServerModification( modification, attributeType ) );
            }
        }

        return modificationsList;
    }
    else
    {
        return null;
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:48,代码来源:ServerEntryUtils.java

示例6: check

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException; //导入依赖的package包/类
/**
 * Check that all the attributes exist in the schema for this entry.
 *
 * We also check the syntaxes
 */
private void check( Dn dn, Entry entry ) throws LdapException
{
    // ---------------------------------------------------------------
    // First, make sure all attributes are valid schema defined attributes
    // ---------------------------------------------------------------

    for ( Attribute attribute : entry.getAttributes() )
    {
        AttributeType attributeType = attribute.getAttributeType();

        if ( !schemaManager.getAttributeTypeRegistry().contains( attributeType.getName() ) )
        {
            throw new LdapInvalidAttributeTypeException( I18n.err( I18n.ERR_275, attributeType.getName() ) );
        }
    }

    // We will check some elements :
    // 1) the entry must have all the MUST attributes of all its ObjectClass
    // 2) The SingleValued attributes must be SingleValued
    // 3) No attributes should be used if they are not part of MUST and MAY
    // 3-1) Except if the extensibleObject ObjectClass is used
    // 3-2) or if the AttributeType is COLLECTIVE
    // 4) We also check that for H-R attributes, we have a valid String in the values
    Attribute objectClassAttr = entry.get( OBJECT_CLASS_AT );

    // Protect the server against a null objectClassAttr
    // It can be the case if the user forgot to add it to the entry ...
    // In this case, we create an new one, empty
    if ( objectClassAttr == null )
    {
        objectClassAttr = new DefaultAttribute( OBJECT_CLASS_AT );
    }

    List<ObjectClass> ocs = new ArrayList<ObjectClass>();

    alterObjectClasses( objectClassAttr );

    // Now we can process the MUST and MAY attributes
    Set<String> must = getAllMust( objectClassAttr );
    Set<String> allowed = getAllAllowed( objectClassAttr, must );

    boolean hasExtensibleObject = getObjectClasses( objectClassAttr, ocs );

    // As we now have all the ObjectClasses updated, we have
    // to check that we don't have conflicting ObjectClasses
    assertObjectClasses( dn, ocs );

    assertRequiredAttributesPresent( dn, entry, must );
    assertNumberOfAttributeValuesValid( entry );

    if ( !hasExtensibleObject )
    {
        assertAllAttributesAllowed( dn, entry, allowed );
    }

    // Check the attributes values and transform them to String if necessary
    assertHumanReadable( entry );

    // Now check the syntaxes
    assertSyntaxes( entry );

    assertRdn( dn, entry );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:69,代码来源:SchemaInterceptor.java


注:本文中的org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeTypeException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。