}
/* No protection */static AttributeType getBytesAttributeType()
{
AttributeType attributeType = new AttributeType( "1.2" );
LdapSyntax syntax = new LdapSyntax( "1.2.1", "", true );
syntax.setSyntaxChecker( new SyntaxChecker( "1.2.1" )
{
public boolean isValidSyntax( Object value )
{
return ( value == null ) || ( ( ( byte[] ) value ).length < 5 );
}
} );
MatchingRule matchingRule = new MatchingRule( "1.2.2" );
matchingRule.setSyntax( syntax );
matchingRule.setLdapComparator( new ByteArrayComparator( "1.2.2" ) );
matchingRule.setNormalizer( new Normalizer( "1.1.1" )
{
public Value<?> normalize( Value<?> value ) throws LdapException
{
if ( !value.isHumanReadable() )
{
byte[] val = value.getBytes();
// each byte will be changed to be > 0, and spaces will be trimmed
byte[] newVal = new byte[val.length];
int i = 0;
for ( byte b : val )
{
newVal[i++] = ( byte ) ( b & 0x007F );
}
return new BinaryValue( Strings.trim( newVal ) );
}
throw new IllegalStateException();
}
public String normalize( String value ) throws LdapException
{
throw new IllegalStateException();
}
} );
attributeType.setEquality( matchingRule );
attributeType.setSyntax( syntax );
return attributeType;
}