Java Code Examples for org.apache.directory.api.ldap.model.message.ResultCodeEnum#INVALID_CREDENTIALS

The following examples show how to use org.apache.directory.api.ldap.model.message.ResultCodeEnum#INVALID_CREDENTIALS . 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: InitSaslBind.java    From directory-ldap-api with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void action( LdapMessageContainer<BindRequest> container ) throws DecoderException
{
    BindRequest bindRequestMessage = container.getMessage();
    TLV tlv = container.getCurrentTLV();

    // We will check that the sasl is not null
    if ( tlv.getLength() == 0 )
    {
        String msg = I18n.err( I18n.ERR_05116_SASL_CREDS_CANT_BE_NULL );
        LOG.error( msg );

        BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() );

        throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS,
            bindRequestMessage.getDn(), null );
    }

    bindRequestMessage.setSimple( false );

    if ( LOG.isDebugEnabled() )
    {
        LOG.debug( I18n.msg( I18n.MSG_05115_SASL_CREDS_CREATED ) );
    }
}
 
Example 2
Source File: BindRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 6 votes vote down vote up
/**
 * Send back an INVALID-CREDENTIAL error message to the user. If we have an exception as a third argument, then send back the associated message to the
 * client.
 */
private void sendInvalidCredentials(LdapSession ldapSession, BindRequest bindRequest, Exception e) {
    LdapResult result = bindRequest.getResultResponse().getLdapResult();

    String message = "";

    if (e != null) {
        message = ResultCodeEnum.INVALID_CREDENTIALS + ": " + e.getLocalizedMessage();
    } else {
        message = ResultCodeEnum.INVALID_CREDENTIALS.toString();
    }

    LOG.error(message);
    result.setResultCode(ResultCodeEnum.INVALID_CREDENTIALS);
    result.setDiagnosticMessage(message);

    // Reinitialize the state to Anonymous and clear the sasl properties
    ldapSession.clearSaslProperties();
    ldapSession.setAnonymous();

    // Write back the error response
    ldapSession.getIoSession().write(bindRequest.getResultResponse());
}
 
Example 3
Source File: BindRequestHandler.java    From MyVirtualDirectory with Apache License 2.0 5 votes vote down vote up
/**
 * Send back an INVALID-CREDENTIAL error message to the user. If we have an exception
 * as a third argument, then send back the associated message to the client. 
 */
private void sendInvalidCredentials( LdapSession ldapSession, BindRequest bindRequest, Exception e )
{
    LdapResult result = bindRequest.getResultResponse().getLdapResult();

    String message = "";

    if ( e != null )
    {
        message = ResultCodeEnum.INVALID_CREDENTIALS + ": " + e.getLocalizedMessage();
    }
    else
    {
        message = ResultCodeEnum.INVALID_CREDENTIALS.toString();
    }

    LOG.error( message );
    result.setResultCode( ResultCodeEnum.INVALID_CREDENTIALS );
    result.setDiagnosticMessage( message );

    // Reinitialize the state to Anonymous and clear the sasl properties
    ldapSession.clearSaslProperties();
    ldapSession.setAnonymous();

    // Write back the error response
    ldapSession.getIoSession().write( bindRequest.getResultResponse() );
}
 
Example 4
Source File: LdapAuthenticationException.java    From directory-ldap-api with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of LdapAuthenticationException.
 */
public LdapAuthenticationException()
{
    super( ResultCodeEnum.INVALID_CREDENTIALS, null );
}
 
Example 5
Source File: LdapAuthenticationException.java    From directory-ldap-api with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance of LdapAuthenticationException.
 *
 * @param message The exception message
 */
public LdapAuthenticationException( String message )
{
    super( ResultCodeEnum.INVALID_CREDENTIALS, message );
}