本文整理汇总了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() );
}
示例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() );
}
示例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() );
}
示例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() );
}
示例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" ) );
}
示例6: computeLength
import org.apache.directory.api.ldap.model.message.BindResponse; //导入依赖的package包/类
/**
* Compute the BindResponse length
* <br>
* BindResponse :
* <pre>
* 0x61 L1
* |
* +--> LdapResult
* +--> [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;
}
示例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() ) );
}
示例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() );
}
示例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() ) );
}
示例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() );
}
示例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() );
}
示例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();
}
}
示例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();
}
}
示例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() );
}
}
示例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;
}