本文整理汇总了Java中org.apache.directory.api.ldap.model.message.BindRequest.setCredentials方法的典型用法代码示例。如果您正苦于以下问题:Java BindRequest.setCredentials方法的具体用法?Java BindRequest.setCredentials怎么用?Java BindRequest.setCredentials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.directory.api.ldap.model.message.BindRequest
的用法示例。
在下文中一共展示了BindRequest.setCredentials方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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() );
}
}
示例2: bind
import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void bind( Dn name ) throws LdapException
{
byte[] credBytes = Strings.EMPTY_BYTES;
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setDn( name );
bindRequest.setCredentials( credBytes );
BindResponse bindResponse = bind( bindRequest );
processResponse( bindResponse );
}
示例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;
}
示例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();
// Get the Value and store it in the BindRequest
TLV tlv = container.getCurrentTLV();
// We have to handle the special case of a 0 length
// credentials
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 credentials are : {}", Strings.dumpBytes( bindRequestMessage
.getCredentials() ) );
}
}
示例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();
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() ) );
}
}
示例6: 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 ) );
}
示例7: bind
import org.apache.directory.api.ldap.model.message.BindRequest; //导入方法依赖的package包/类
/**
* Calls the PoolMgr to perform an LDAP bind for a user/password combination. This function is valid
* if and only if the user entity is a member of the USERS data set.
*
* @param connection connection to ldap server.
* @param szUserDn contains the LDAP dn to the user entry in String format.
* @param password contains the password in clear text.
* @return bindResponse contains the result of the operation.
* @throws LdapException in the event of LDAP error.
*/
protected BindResponse bind( LdapConnection connection, String szUserDn, String password ) throws LdapException
{
COUNTERS.incrementBind();
Dn userDn = new Dn( szUserDn );
BindRequest bindReq = new BindRequestImpl();
bindReq.setDn( userDn );
bindReq.setCredentials( password );
bindReq.addControl( PP_REQ_CTRL );
return connection.bind( bindReq );
}