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


Java BindResponse类代码示例

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


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

示例1: testResponseWithRequestId

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a Response with the (optional) requestID attribute
 */
@Test
public void testResponseWithRequestId()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput(
            AuthResponseTest.class.getResource( "response_with_requestID_attribute.xml" ).openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

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

示例2: testResponseWithResultCode

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with Result Code
 */
@Test
public void testResponseWithResultCode()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_result_code.xml" ).openStream(),
            "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = bindResponse.getLdapResult();

    assertEquals( ResultCodeEnum.PROTOCOL_ERROR, ldapResult.getResultCode() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:AuthResponseTest.java

示例3: testResponseWithErrorMessage

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with Error Message
 */
@Test
public void testResponseWithErrorMessage()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_error_message.xml" ).openStream(),
            "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = bindResponse.getLdapResult();

    assertEquals( "Unrecognized extended operation EXTENSION_OID: 1.2.6.1.4.1.18060.1.1.1.100.2", ldapResult
        .getDiagnosticMessage() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:29,代码来源:AuthResponseTest.java

示例4: testResponseWithEmptyErrorMessage

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with Empty Error Message
 */
@Test
public void testResponseWithEmptyErrorMessage()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput(
            AuthResponseTest.class.getResource( "response_with_empty_error_message.xml" ).openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = bindResponse.getLdapResult();

    assertNull( ldapResult.getDiagnosticMessage() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:AuthResponseTest.java

示例5: testResponseWithMatchedDNAttribute

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with MatchedDN attribute
 */
@Test
public void testResponseWithMatchedDNAttribute()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput(
            AuthResponseTest.class.getResource( "response_with_matchedDN_attribute.xml" ).openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = bindResponse.getLdapResult();

    assertTrue( ldapResult.getMatchedDn().equals( "cn=Bob Rush,ou=Dev,dc=Example,dc=COM" ) );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:28,代码来源:AuthResponseTest.java

示例6: computeLength

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Compute the BindResponse length 
 * <br>
 * BindResponse : 
 * <pre>
 * 0x61 L1 
 *   | 
 *   +--&gt; LdapResult
 *   +--&gt; [serverSaslCreds] 
 *   
 * L1 = Length(LdapResult) [ + Length(serverSaslCreds) ] 
 * Length(BindResponse) = Length(0x61) + Length(L1) + L1
 * </pre>
 */
@Override
public int computeLength()
{
    BindResponse bindResponse = getDecorated();
    int ldapResultLength = ( ( LdapResultDecorator ) getLdapResult() ).computeLength();

    bindResponseLength = ldapResultLength;

    byte[] serverSaslCreds = bindResponse.getServerSaslCreds();

    if ( serverSaslCreds != null )
    {
        bindResponseLength += 1 + TLV.getNbBytes( serverSaslCreds.length ) + serverSaslCreds.length;
    }

    return 1 + TLV.getNbBytes( bindResponseLength ) + bindResponseLength;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:32,代码来源:BindResponseDecorator.java

示例7: testResponseWith1Control

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with a (optional) Control element
 */
@Test
public void testResponseWith1Control()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_1_control.xml" ).openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = bindResponse.getControls();

    assertEquals( 1, bindResponse.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,代码来源:AuthResponseTest.java

示例8: testResponseWith1ControlEmptyValue

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with a (optional) Control element with empty value
 */
@Test
public void testResponseWith1ControlEmptyValue()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_1_control_empty_value.xml" )
            .openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = bindResponse.getControls();

    assertEquals( 1, bindResponse.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() );
    assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:AuthResponseTest.java

示例9: testResponseWith2Controls

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with 2 (optional) Control elements
 */
@Test
public void testResponseWith2Controls()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser
            .setInput( AuthResponseTest.class.getResource( "response_with_2_controls.xml" ).openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = bindResponse.getControls();

    assertEquals( 2, bindResponse.getControls().size() );

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

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

示例10: testResponseWith3ControlsWithoutValue

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with 3 (optional) Control elements without value
 */
@Test
public void testResponseWith3ControlsWithoutValue()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_3_controls_without_value.xml" )
            .openStream(), "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();
    Map<String, Control> controls = bindResponse.getControls();

    assertEquals( 3, bindResponse.getControls().size() );

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

    assertNotNull( control );
    assertTrue( control.isCritical() );
    assertEquals( "1.2.840.113556.1.4.456", control.getOid() );
    assertFalse( ( ( DsmlControl<?> ) control ).hasValue() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:34,代码来源:AuthResponseTest.java

示例11: testResponseWith1EmptyReferral

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a response with an empty Referral
 */
@Test
public void testResponseWith1EmptyReferral()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( AuthResponseTest.class.getResource( "response_with_1_empty_referral.xml" ).openStream(),
            "UTF-8" );

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

    BindResponse bindResponse = ( BindResponse ) parser.getBatchResponse().getCurrentResponse();

    LdapResult ldapResult = bindResponse.getLdapResult();

    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();

    assertEquals( 0, referrals.size() );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:30,代码来源:AuthResponseTest.java

示例12: testResponseWith1AuthResponse

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a Response with the 1 AuthResponse
 */
@Test
public void testResponseWith1AuthResponse()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( BatchResponseTest.class.getResource( "response_with_1_AuthResponse.xml" ).openStream(),
            "UTF-8" );

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

    BatchResponseDsml batchResponse = parser.getBatchResponse();

    assertEquals( 1, batchResponse.getResponses().size() );

    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();

    if ( response instanceof BindResponse )
    {
        assertTrue( true );
    }
    else
    {
        fail();
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:BatchResponseTest.java

示例13: testResponseWith2AuthResponse

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * Test parsing of a Response with the 2 AuthResponse
 */
@Test
public void testResponseWith2AuthResponse()
{
    Dsmlv2ResponseParser parser = null;
    try
    {
        parser = new Dsmlv2ResponseParser( getCodec() );

        parser.setInput( BatchResponseTest.class.getResource( "response_with_2_AuthResponse.xml" ).openStream(),
            "UTF-8" );

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

    BatchResponseDsml batchResponse = parser.getBatchResponse();

    assertEquals( 2, batchResponse.getResponses().size() );

    DsmlDecorator<? extends Response> response = batchResponse.getCurrentResponse();

    if ( response instanceof BindResponse )
    {
        assertTrue( true );
    }
    else
    {
        fail();
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:37,代码来源:BatchResponseTest.java

示例14: bind

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的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

示例15: bind

import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public BindResponse bind( BindRequest bindRequest ) throws LdapException
{
    BindResponse response = connection.bind( bindRequest );
    bindCalled = true;
    return response;
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:11,代码来源:MonitoringLdapConnection.java


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