Java Code Examples for org.apache.directory.api.ldap.model.message.BindRequest#getDn()
The following examples show how to use
org.apache.directory.api.ldap.model.message.BindRequest#getDn() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InitSaslBind.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void action( LdapMessageContainer<BindRequest> 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_05116_SASL_CREDS_CANT_BE_NULL ); LOG.error( msg ); BindResponseImpl response = new BindResponseImpl( bindRequestMessage.getMessageId() ); throw new ResponseCarryingException( msg, response, ResultCodeEnum.INVALID_CREDENTIALS, bindRequestMessage.getDn(), null ); } bindRequestMessage.setSimple( false ); if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_05115_SASL_CREDS_CREATED ) ); } }
Example 2
Source File: BindRequestDsml.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * {@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; }
Example 3
Source File: BindRequestFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Encode the BindRequest message to a PDU. * <br> * BindRequest : * <pre> * 0x60 LL * 0x02 LL version 0x80 LL simple * 0x04 LL name / * authentication.encode() * \ 0x83 LL 0x04 LL mechanism [0x04 LL credential] * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the BindRequest to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); BindRequest bindMessage = ( BindRequest ) message; // The authentication if ( bindMessage.isSimple() ) { // Simple authentication BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.BIND_REQUEST_SIMPLE_TAG, bindMessage.getCredentials() ); } else { // SASL Bind // The credentials, if any if ( !Strings.isEmpty( bindMessage.getCredentials() ) ) { BerValue.encodeOctetString( buffer, bindMessage.getCredentials() ); } // The mechanism BerValue.encodeOctetString( buffer, bindMessage.getSaslMechanism() ); // The SASL tag BerValue.encodeSequence( buffer, ( byte ) LdapCodecConstants.BIND_REQUEST_SASL_TAG, start ); } // The name Dn dn = bindMessage.getDn(); if ( !Dn.isNullOrEmpty( dn ) ) { // A DN has been provided BerValue.encodeOctetString( buffer, dn.getName() ); } else { // No DN has been provided, let's use the name as a string instead BerValue.encodeOctetString( buffer, bindMessage.getName() ); } // The version (LDAP V3 only) BerValue.encodeInteger( buffer, 3 ); // The BindRequest Tag BerValue.encodeSequence( buffer, LdapCodecConstants.BIND_REQUEST_TAG, start ); }