Java Code Examples for org.apache.directory.api.util.Strings#isIA5String()

The following examples show how to use org.apache.directory.api.util.Strings#isIA5String() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NormalizerSyntaxChecker.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, "null" ) );
        }
        
        return true;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    boolean result = Strings.isIA5String( strValue );

    if ( LOG.isDebugEnabled() )
    {
        if ( result )
        {
            LOG.debug( I18n.msg( I18n.MSG_13701_SYNTAX_VALID, value ) );
        }
        else
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
    }
    
    return result;
}
 
Example 2
Source File: ComparatorSyntaxChecker.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, "null" ) );
        }
        
        return true;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    boolean result = Strings.isIA5String( strValue );

    if ( LOG.isDebugEnabled() )
    {
        if ( result )
        {
            LOG.debug( I18n.msg( I18n.MSG_13701_SYNTAX_VALID, value ) );
        }
        else
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
    }

    return result;
}
 
Example 3
Source File: OtherMailboxSyntaxChecker.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, "null" ) );
        }
        
        return false;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    if ( strValue.length() == 0 )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }

    // Search for the '$' separator
    int dollar = strValue.indexOf( '$' );

    if ( dollar == -1 )
    {
        // No '$' => error
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }

    String mailboxType = strValue.substring( 0, dollar );

    String mailbox = ( dollar < strValue.length() - 1 )
        ? strValue.substring( dollar + 1 ) : "";

    // The mailbox should not contains a '$'
    if ( mailbox.indexOf( '$' ) != -1 )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }

    // Check that the mailboxType is a PrintableString
    if ( !Strings.isPrintableString( mailboxType ) )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
        
        return false;
    }

    // Check that the mailbox is an IA5String
    boolean result = Strings.isIA5String( mailbox );

    if ( LOG.isDebugEnabled() )
    {
        if ( result )
        {
            LOG.debug( I18n.msg( I18n.MSG_13701_SYNTAX_VALID, value ) );
        }
        else
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
    }

    return result;
}
 
Example 4
Source File: Ia5StringSyntaxChecker.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean isValidSyntax( Object value )
{
    String strValue;

    if ( value == null )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, "null" ) );
        }
        
        return true;
    }

    if ( value instanceof String )
    {
        strValue = ( String ) value;
    }
    else if ( value instanceof byte[] )
    {
        strValue = Strings.utf8ToString( ( byte[] ) value );
    }
    else
    {
        strValue = value.toString();
    }

    boolean result = Strings.isIA5String( strValue );

    if ( result )
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.msg( I18n.MSG_13701_SYNTAX_VALID, value ) );
        }
    }
    else
    {
        if ( LOG.isDebugEnabled() )
        {
            LOG.debug( I18n.err( I18n.ERR_13210_SYNTAX_INVALID, value ) );
        }
    }

    return result;
}