• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BindRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: setVersion3

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

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


示例17: setSaslMechanism

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

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


示例18: setMessageId

import org.apache.directory.api.ldap.model.message.BindRequest; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindRequest setMessageId( int messageId )
{
    super.setMessageId( messageId );

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


示例19: testRequestWith1Control

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

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

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

    BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
    Map<String, Control> controls = abandonRequest.getControls();

    assertEquals( 1, abandonRequest.getControls().size() );

    Control control = controls.get( "1.2.840.113556.1.4.643" );

    assertNotNull( control );
    assertTrue( control.isCritical() );
    assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
    assertEquals( "Some text", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:33,代码来源:AuthRequestTest.java


示例20: testRequestWith1ControlBase64Value

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

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

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

    BindRequest abandonRequest = ( BindRequest ) parser.getBatchRequest().getCurrentRequest();
    Map<String, Control> controls = abandonRequest.getControls();

    assertEquals( 1, abandonRequest.getControls().size() );

    Control control = controls.get( "1.2.840.113556.1.4.643" );

    assertNotNull( control );
    assertTrue( control.isCritical() );
    assertEquals( "1.2.840.113556.1.4.643", control.getOid() );
    assertEquals( "DSMLv2.0 rocks!!", Strings.utf8ToString( ( ( DsmlControl<?> ) control ).getValue() ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:AuthRequestTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CurrentInstance类代码示例发布时间:2022-05-23
下一篇:
Java GetApplicationAttemptsRequestPBImpl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap