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


Java BindRequest类代码示例

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


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

示例1: testRequestWithPrincipal

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * Test parsing of a request with the principal attribute
 */
@Test
public void testRequestWithPrincipal()
{
    Dsmlv2Parser parser = null;
    try
    {
        parser = newParser();

        parser.setInput( AuthRequestTest.class.getResource( "request_with_principal_attribute.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    BindRequest bindRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();

    assertEquals( "CN=Bob Rush,OU=Dev,DC=Example,DC=COM", bindRequest.getName() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:AuthRequestTest.java

示例2: testRequestWithRequestId

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * Test parsing of a request with the (optional) requestID attribute
 */
@Test
public void testRequestWithRequestId()
{
    Dsmlv2Parser parser = null;
    try
    {
        parser = newParser();

        parser.setInput( AuthRequestTest.class.getResource( "request_with_requestID_attribute.xml" ).openStream(),
            "UTF-8" );

        parser.parse();
    }
    catch ( Exception e )
    {
        fail( e.getMessage() );
    }

    BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();

    assertEquals( 456, abandonRequest.getMessageId() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:26,代码来源:AuthRequestTest.java

示例3: bindAsync

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindFuture bindAsync( String name, String credentials ) throws LdapException
{
    LOG.debug( "Bind request : {}", name );

    // The password must not be empty or null
    if ( Strings.isEmpty( credentials ) && Strings.isNotEmpty( name ) )
    {
        LOG.debug( "The password is missing" );
        throw new LdapAuthenticationException( "The password is missing" );
    }

    // Create the BindRequest
    BindRequest bindRequest = createBindRequest( name, Strings.getBytesUtf8( credentials ) );

    return bindAsync( bindRequest );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:21,代码来源:LdapNetworkConnection.java

示例4: authenticateConnection

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
private PasswordWarning authenticateConnection( final LdapConnection connection,
    final Dn userDn, final char[] password ) throws PasswordException
{
    return passwordPolicyResponder.process(
        new PasswordPolicyOperation()
        {
            @Override
            public ResultResponse process() throws LdapException
            {
                MemoryClearingBuffer passwordBuffer = MemoryClearingBuffer.newInstance( password );
                try
                {
                    BindRequest bindRequest = new BindRequestImpl()
                        .setDn( userDn )
                        .setCredentials( passwordBuffer.getBytes() )
                        .addControl( passwordPolicyRequestControl );

                    return connection.bind( bindRequest );
                }
                finally
                {
                    passwordBuffer.clear();
                }
            }
        } );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:27,代码来源:LdapConnectionTemplate.java

示例5: action

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

    // Get the Value and store it in the BindRequest
    TLV tlv = container.getCurrentTLV();

    // We have to handle the special case of a 0 length name
    if ( tlv.getLength() == 0 )
    {
        bindRequestMessage.setName( "" );
    }
    else
    {
        byte[] nameBytes = tlv.getValue().getData();
        String nameStr = Strings.utf8ToString( nameBytes );
        bindRequestMessage.setName( nameStr );
    }

    if ( IS_DEBUG )
    {
        LOG.debug( " The Bind name is {}", bindRequestMessage.getName() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:StoreName.java

示例6: action

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

    // We have to handle the special case of a 0 length
    // mechanism
    if ( tlv.getLength() == 0 )
    {
        bindRequestMessage.setSaslMechanism( "" );
    }
    else
    {
        bindRequestMessage.setSaslMechanism( Strings.utf8ToString( tlv.getValue().getData() ) );
    }

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

    if ( IS_DEBUG )
    {
        LOG.debug( "The mechanism is : {}", bindRequestMessage.getSaslMechanism() );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:StoreSaslMechanism.java

示例7: 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

示例8: action

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void action( LdapMessageContainer<BindRequestDecorator> container ) throws DecoderException
{
    // Create the BindRequest LdapMessage instance and store it in the container
    BindRequest internalBindRequest = new BindRequestImpl();
    internalBindRequest.setMessageId( container.getMessageId() );
    BindRequestDecorator bindRequest = new BindRequestDecorator(
        container.getLdapCodecService(), internalBindRequest );
    container.setMessage( bindRequest );

    // We will check that the request is not null
    TLV tlv = container.getCurrentTLV();

    if ( tlv.getLength() == 0 )
    {
        String msg = I18n.err( I18n.ERR_04077 );
        LOG.error( msg );

        // This will generate a PROTOCOL_ERROR
        throw new DecoderException( msg );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:25,代码来源:InitBindRequest.java

示例9: sendAuthMethNotSupported

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * Send back an AUTH-METH-NOT-SUPPORTED error message to the client
 */
private void sendAuthMethNotSupported( LdapSession ldapSession, BindRequest bindRequest )
{
    // First, r-einit the state to Anonymous, and clear the
    // saslProperty map
    ldapSession.clearSaslProperties();
    ldapSession.setAnonymous();

    // And send the response to the client
    LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
    bindResult.setResultCode( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED );
    bindResult.setDiagnosticMessage( ResultCodeEnum.AUTH_METHOD_NOT_SUPPORTED.toString() + ": "
        + bindRequest.getSaslMechanism() + " is not a supported mechanism." );

    // Write back the error
    ldapSession.getIoSession().write( bindRequest.getResultResponse() );
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:20,代码来源:BindRequestHandler.java

示例10: handle

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * Deal with a received BindRequest
 * 
 * @param ldapSession The current session
 * @param bindRequest The received BindRequest
 * @throws Exception If the authentication cannot be handled
 */
public void handle( LdapSession ldapSession, BindRequest bindRequest ) throws Exception
{
    LOG.debug( "Received: {}", bindRequest );

    // Guard clause:  LDAP version 3
    if ( !bindRequest.getVersion3() )
    {
        LOG.error( I18n.err( I18n.ERR_162 ) );
        LdapResult bindResult = bindRequest.getResultResponse().getLdapResult();
        bindResult.setResultCode( ResultCodeEnum.PROTOCOL_ERROR );
        bindResult.setDiagnosticMessage( I18n.err( I18n.ERR_163 ) );
        ldapSession.getIoSession().write( bindRequest.getResultResponse() );
        return;
    }

    // Deal with the two kinds of authentication : Simple and SASL
    if ( bindRequest.isSimple() )
    {
        handleSimpleAuth( ldapSession, bindRequest );
    }
    else
    {
        handleSaslAuth( ldapSession, bindRequest );
    }
}
 
开发者ID:TremoloSecurity,项目名称:MyVirtualDirectory,代码行数:33,代码来源:BindRequestHandler.java

示例11: toDsml

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Element toDsml( Element root )
{
    Element element = super.toDsml( root );

    BindRequest request = getDecorated();

    // Principal
    Dn dn = request.getDn();

    if ( !Dn.isNullOrEmpty( dn ) )
    {
        // A DN has been provided

        element.addAttribute( "principal", dn.getName() );
    }
    else
    {
        // No DN has been provided, let's use the name as a string instead

        String name = request.getName();

        element.addAttribute( "principal", name );
    }

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

示例12: setSimple

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindRequest setSimple( boolean isSimple )
{
    getDecorated().setSimple( isSimple );

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

示例13: setCredentials

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindRequest setCredentials( String credentials )
{
    getDecorated().setCredentials( credentials );

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

示例14: setName

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindRequest setName( String name )
{
    getDecorated().setName( name );

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

示例15: setDn

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindRequest setDn( Dn dn )
{
    getDecorated().setDn( dn );

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


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