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


Java BindRequest.setSimple方法代码示例

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


在下文中一共展示了BindRequest.setSimple方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: action

import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<BindRequestDecorator> 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_04079 );
        LOG.error( msg );

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

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

    bindRequestMessage.setSimple( false );

    if ( IS_DEBUG )
    {
        LOG.debug( "The SaslCredential has been created" );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:InitSaslBind.java

示例2: bind

import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
 * Binds to the ldap server
 * 
 * @param messageId the message Id
 * @throws LdapException If we had an issue while binding
 * @throws EncoderException If we had an issue while encoding the request
 * @throws DecoderException If we had an issue while decoding the request
 * @throws IOException If we had an issue while transmitting the request or re ceiving the response
 */
protected void bind( int messageId ) throws LdapException, EncoderException, DecoderException, IOException
{
    if ( ( connection != null ) && connection.isAuthenticated() )
    {
        return;
    }

    if ( connection == null )
    {
        throw new IOException( I18n.err( I18n.ERR_03101_MISSING_CONNECTION_TO ) );
    }

    BindRequest bindRequest = new BindRequestImpl();
    bindRequest.setSimple( true );
    bindRequest.setCredentials( Strings.getBytesUtf8( password ) );
    bindRequest.setName( user );
    bindRequest.setVersion3( true );
    bindRequest.setMessageId( messageId );

    BindResponse bindResponse = connection.bind( bindRequest );

    if ( bindResponse.getLdapResult().getResultCode() != ResultCodeEnum.SUCCESS )
    {
        LOG.warn( "Error : {}", bindResponse.getLdapResult().getDiagnosticMessage() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:36,代码来源:Dsmlv2Engine.java

示例3: createBindRequest

import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
 * Create a complete BindRequest ready to be sent.
 *
 * @param name The DN to bind with
 * @param credentials The user's password
 * @param saslMechanism The SASL mechanism to use
 * @param controls The controls to send
 * @return The created BindRequest
 * @throws LdapException If the creation failed
 */
protected BindRequest createBindRequest( String name, byte[] credentials, String saslMechanism, Control... controls )
    throws LdapException
{
    // Set the new messageId
    BindRequest bindRequest = new BindRequestImpl();

    // Set the version
    bindRequest.setVersion3( true );

    // Set the name
    bindRequest.setName( name );

    // Set the credentials
    if ( Strings.isEmpty( saslMechanism ) )
    {
        // Simple bind
        bindRequest.setSimple( true );
        bindRequest.setCredentials( credentials );
    }
    else
    {
        // SASL bind
        bindRequest.setSimple( false );
        bindRequest.setCredentials( credentials );
        bindRequest.setSaslMechanism( saslMechanism );
    }

    // Add the controls
    if ( ( controls != null ) && ( controls.length != 0 ) )
    {
        bindRequest.addAllControls( controls );
    }

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

示例4: action

import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
{
    BindRequest bindRequestMessage = container.getMessage();
    TLV tlv = container.getCurrentTLV();

    // Allocate the Authentication Object
    bindRequestMessage.setSimple( true );

    // We have to handle the special case of a 0 length simple
    if ( tlv.getLength() == 0 )
    {
        bindRequestMessage.setCredentials( Strings.EMPTY_BYTES );
    }
    else
    {
        bindRequestMessage.setCredentials( tlv.getValue().getData() );
    }

    // We can have an END transition
    container.setGrammarEndAllowed( true );

    if ( IS_DEBUG )
    {
        LOG.debug( "The simple authentication is : {}", Strings.dumpBytes( bindRequestMessage
            .getCredentials() ) );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:31,代码来源:StoreSimpleAuth.java

示例5: testEncodeBindRequestPerf

import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
 * Test the decoding of a BindRequest with Simple authentication and no
 * controls
 */
@Test
@Ignore
public void testEncodeBindRequestPerf() throws Exception
{
    Dn dn = new Dn( "uid=akarasulu,dc=example,dc=com" );
    int nbLoops = 1000000;
    long t0 = System.currentTimeMillis();

    for ( int i = 0; i < nbLoops; i++ )
    {
        // Check the decoded BindRequest
        BindRequest bindRequest = new BindRequestImpl();
        bindRequest.setMessageId( 1 );

        bindRequest.setSimple( true );
        bindRequest.setDn( dn );
        bindRequest.setCredentials( Strings.getBytesUtf8( "password" ) );
        Control control = new OpaqueControl( "2.16.840.1.113730.3.4.2" );

        bindRequest.addControl( control );

        // Check the encoding
        try
        {
            encoder.encodeMessage( bindRequest );
        }
        catch ( EncoderException ee )
        {
            ee.printStackTrace();
            fail( ee.getMessage() );
        }
    }

    long t1 = System.currentTimeMillis();
    System.out.println( "BindRequest testEncodeBindRequestPerf, " + nbLoops + " loops, Delta = " + ( t1 - t0 ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:41,代码来源:BindRequestPerfTest.java


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