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


Java LdapInvalidAttributeValueException类代码示例

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


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

示例1: DefaultAttribute

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Create a new instance of a schema aware Attribute, without value.
 * 
 * @param upId the ID for the added attributeType
 * @param attributeType the added AttributeType
 */
public DefaultAttribute( String upId, AttributeType attributeType )
{
    if ( attributeType == null )
    {
        String message = I18n.err( I18n.ERR_04460_ATTRIBUTE_TYPE_NULL_NOT_ALLOWED );
        LOG.error( message );
        throw new IllegalArgumentException( message );
    }

    try
    {
        apply( attributeType );
    }
    catch ( LdapInvalidAttributeValueException liave )
    {
        // Do nothing, it can't happen, there is no value
    }

    setUpId( upId, attributeType );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:DefaultAttribute.java

示例2: createStringValue

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
private Value createStringValue( AttributeType attributeType, String value )
{
    Value newValue;

    if ( attributeType != null )
    {
        try
        {
            newValue = new Value( attributeType, value );
        }
        catch ( LdapInvalidAttributeValueException iae )
        {
            return null;
        }
    }
    else
    {
        newValue = new Value( value );
    }

    return newValue;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:23,代码来源:DefaultAttribute.java

示例3: createBinaryValue

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
private Value createBinaryValue( AttributeType attributeType, byte[] value )
    throws LdapInvalidAttributeValueException
{
    Value binaryValue;

    if ( attributeType != null )
    {
        binaryValue = new Value( attributeType, value );
    }
    else
    {
        binaryValue = new Value( value );
    }

    return binaryValue;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:17,代码来源:DefaultAttribute.java

示例4: isValid

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Uses the syntaxChecker associated with the attributeType to check if the
 * value is valid.
 * 
 * @param syntaxChecker the SyntaxChecker to use to validate the value
 * @return <code>true</code> if the value is valid
 * @exception LdapInvalidAttributeValueException if the value cannot be validated
 */
public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException
{
    if ( syntaxChecker == null )
    {
        String message = I18n.err( I18n.ERR_04139_NULL_SYNTAX_CHECKER, toString() );
        LOG.error( message );
        throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
    }

    // No attributeType, or it's in relaxed mode
    if ( isHR )
    {
        // We need to prepare the String in this case
        return syntaxChecker.isValidSyntax( getValue() );
    }
    else
    {
        return syntaxChecker.isValidSyntax( bytes );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:Value.java

示例5: anonymize

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type)
 */
@Override
public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute )
{
    Attribute result = new DefaultAttribute( attribute.getAttributeType() );

    for ( Value value : attribute )
    {
        byte[] bytesValue = value.getBytes();
        byte[] newValue = computeNewValue( bytesValue );
        
        try
        {
            result.add( newValue );
            Value anonValue = new Value( attribute.getAttributeType(), newValue );
            valueMap.put( ( Value ) value, anonValue );
            valueSet.add( anonValue );
        }
        catch ( LdapInvalidAttributeValueException e )
        {
            throw new RuntimeException( "Error while anonymizing the value" + value );
        }
    }

    return result;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:BinaryAnonymizer.java

示例6: testGetNormalizedValue

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Test the getNormValue method
 */
@Test
public void testGetNormalizedValue() throws LdapInvalidAttributeValueException
{
    AttributeType attribute = EntryUtils.getIA5StringAttributeType();

    Value sv = new Value( attribute, (String)null );

    assertTrue( sv.isSchemaAware() );
    assertNull( sv.getValue() );
    assertTrue( sv.isSchemaAware() );

    sv = new Value( attribute, "" );
    assertTrue( sv.isSchemaAware() );
    assertEquals( 0, sv.compareTo( "  " ) );
    assertTrue( sv.isSchemaAware() );

    sv = new Value( attribute, "TEST" );
    assertTrue( sv.isSchemaAware() );
    assertEquals( 0, sv.compareTo( " test " ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:24,代码来源:StringValueAttributeTypeTest.java

示例7: testIsValid

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Test the isValid method
 * 
 * The SyntaxChecker does not accept values longer than 5 chars.
 */
@Test
public void testIsValid() throws LdapInvalidAttributeValueException
{
    AttributeType attribute = EntryUtils.getIA5StringAttributeType();

    new Value( attribute, (String)null );
    new Value( attribute, "" );
    new Value( attribute, "TEST" );

    try
    {
        new Value( attribute, "testlong" );
        fail();
    }
    catch ( LdapInvalidAttributeValueException liave )
    {
        assertTrue( true );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:StringValueAttributeTypeTest.java

示例8: testHashCode

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Tests to make sure the hashCode method is working properly.
 * @throws Exception on errors
 */
@Test
public void testHashCode() throws LdapInvalidAttributeValueException
{
    AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
    Value v0 = new Value( at1, "Alex" );
    Value v1 = new Value( at1, "ALEX" );
    Value v2 = new Value( at1, "alex" );

    assertEquals( v0.hashCode(), v1.hashCode() );
    assertEquals( v0.hashCode(), v2.hashCode() );
    assertEquals( v1.hashCode(), v2.hashCode() );

    assertEquals( v0, v1 );
    assertEquals( v0, v2 );
    assertEquals( v1, v2 );

    Value v3 = new Value( at1, "Timber" );

    assertNotSame( v0.hashCode(), v3.hashCode() );

    Value v4 = new Value( at, "Alex" );

    assertNotSame( v0.hashCode(), v4.hashCode() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:StringValueAttributeTypeTest.java

示例9: testCompareTo

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Test the compareTo method
 */
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException
{
    AttributeType at1 = EntryUtils.getCaseIgnoringAttributeNoNumbersType();
    Value v0 = new Value( at1, "Alex" );
    Value v1 = new Value( at1, "ALEX" );

    assertEquals( 0, v0.compareTo( v1 ) );
    assertEquals( 0, v1.compareTo( v0 ) );

    Value v2 = new Value( at1, (String)null );

    assertEquals( 1, v0.compareTo( v2 ) );
    assertEquals( -1, v2.compareTo( v0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:StringValueAttributeTypeTest.java

示例10: testIsValid

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Test the isValid method
 * 
 * The SyntaxChecker does not accept values longer than 5 chars.
 */
@Test
public void testIsValid() throws LdapInvalidAttributeValueException
{
    AttributeType attribute = EntryUtils.getBytesAttributeType();

    new Value( attribute, ( byte[] ) null );
    new Value( attribute, Strings.EMPTY_BYTES );
    new Value( attribute, new byte[]
        { 0x01, 0x02 } );

    try
    {
        new Value( attribute, new byte[]
            { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 } );
        fail();
    }
    catch ( LdapInvalidAttributeValueException liave )
    {
        assertTrue( true );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:BinaryValueAttributeTypeTest.java

示例11: testHashCode

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Tests to make sure the hashCode method is working properly.
 * @throws Exception on errors
 */
@Test
public void testHashCode() throws LdapInvalidAttributeValueException
{
    AttributeType attribute = EntryUtils.getBytesAttributeType();
    Value v0 = new Value( attribute, new byte[]
        { 0x01, 0x02 } );
    Value v1 = new Value( attribute, new byte[]
        { ( byte ) 0x81, ( byte ) 0x82 } );
    Value v2 = new Value( attribute, new byte[]
        { 0x01, 0x02 } );
    assertNotSame( v0.hashCode(), v1.hashCode() );
    assertNotSame( v1.hashCode(), v2.hashCode() );
    assertEquals( v0.hashCode(), v2.hashCode() );
    assertNotSame( v0, v1 );
    assertEquals( v0, v2 );
    assertNotSame( v1, v2 );

    Value v3 = new Value( attribute, new byte[]
        { 0x01, 0x03 } );
    assertFalse( v3.equals( v0 ) );
    assertFalse( v3.equals( v1 ) );
    assertFalse( v3.equals( v2 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:BinaryValueAttributeTypeTest.java

示例12: testCompareTo

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
/**
 * Test the compareTo method
 */
@Test
public void testCompareTo() throws LdapInvalidAttributeValueException
{
    AttributeType at1 = EntryUtils.getBytesAttributeType();
    Value v0 = new Value( at1, BYTES1 );
    Value v1 = new Value( at1, BYTES1 );

    assertEquals( 0, v0.compareTo( v1 ) );
    assertEquals( 0, v1.compareTo( v0 ) );

    Value v2 = new Value( at1, ( byte[] ) null );

    assertEquals( 1, v0.compareTo( v2 ) );
    assertEquals( -1, v2.compareTo( v0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:19,代码来源:BinaryValueAttributeTypeTest.java

示例13: assertAttributeNotContains

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
protected void assertAttributeNotContains(Entry entry, String attrName, String expectedValue, MatchingRule<String> matchingRule) throws LdapInvalidAttributeValueException, SchemaException {
	String dn = entry.getDn().toString();
	Attribute ldapAttribute = entry.get(attrName);
	if (ldapAttribute == null) {
		return;
	} else {
		Iterator<Value<?>> iterator = ldapAttribute.iterator();
		while (iterator.hasNext()) {
			Value<?> value = iterator.next();
			if (matchingRule == null) {
				if (expectedValue.equals(value.getString())) {
					AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it");
				}
			} else {
				if (matchingRule.match(expectedValue, value.getString())) {
					AssertJUnit.fail("Attribute "+attrName+" in "+dn+" contains value " + expectedValue + ", but it should not have it");
				}
			}
		}
	}
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:22,代码来源:AbstractLdapTest.java

示例14: getDn

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
@Override
public String getDn(Entry entry) {
	// distinguishedName attribute provides better DN format (some kind of Microsoft-cannonical form).
	// The usual entry DN will be formatted in the same way as it was in the request. Therefore if
	// name hint is used with midPoint, the normal DN will be all lowercase. This may break some things,
	// e.g. it may interfere with names in older shadows.
	// So use distinguishedName attribute if available.
	Attribute distinguishedNameAttr = entry.get(AdConstants.ATTRIBUTE_DISTINGUISHED_NAME_NAME);
	if (distinguishedNameAttr != null) {
		try {
			return distinguishedNameAttr.getString();
		} catch (LdapInvalidAttributeValueException e) {
			LOG.warn("Error getting sting value from {0}, falling back to entry DN: {1}", 
					distinguishedNameAttr, e.getMessage(), e);
			return super.getDn(entry);
		}
	}
	return super.getDn(entry);
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:20,代码来源:AdSchemaTranslator.java

示例15: processEntryBeforeCreate

import org.apache.directory.api.ldap.model.exception.LdapInvalidAttributeValueException; //导入依赖的package包/类
private void processEntryBeforeCreate(Entry entry) {
	for(final org.apache.directory.api.ldap.model.entry.Attribute attribute: entry.getAttributes()) {
		Value<?> val = attribute.get();
		if (val instanceof GuardedStringValue) {
			attribute.remove(val);
			((GuardedStringValue)val).getGuardedStringValue().access(new GuardedString.Accessor() {
				@Override
				public void access(char[] clearChars) {
					try {
						attribute.add(new String(clearChars));
					} catch (LdapInvalidAttributeValueException e) {
						throw new InvalidAttributeValueException(e.getMessage(), e);
					}
				}
			});
		}
	}
	
}
 
开发者ID:Evolveum,项目名称:connector-ldap,代码行数:20,代码来源:AbstractLdapConnector.java


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