org.apache.directory.api.ldap.codec.api.LdapApiService Java Examples
The following examples show how to use
org.apache.directory.api.ldap.codec.api.LdapApiService.
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: BindResponseFactory.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Encode the BindResponse message to a PDU. * <br> * BindResponse : * <pre> * 0x61 L1 * | * +--> LdapResult * [+--0x87 LL serverSaslCreds] * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the BindResponse to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); BindResponse bindResponse = ( ( BindResponse ) message ); // The serverSASL creds, if any byte[] serverSaslCreds = bindResponse.getServerSaslCreds(); if ( serverSaslCreds != null ) { BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.SERVER_SASL_CREDENTIAL_TAG, serverSaslCreds ); } // The LDAPResult part encodeLdapResultReverse( buffer, bindResponse.getLdapResult() ); // The BindResponse Tag BerValue.encodeSequence( buffer, LdapCodecConstants.BIND_RESPONSE_TAG, start ); }
Example #2
Source File: JndiUtils.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Convert some LDAP API controls to JNDI controls * @param codec The LDAP API service to use * @param controls The controls to convert * @return Array of JNDI control * @throws EncoderException If the conversion failed * @deprecated We don't use JNDI anymore */ @Deprecated public static javax.naming.ldap.Control[] toJndiControls( LdapApiService codec, Control... controls ) throws EncoderException { if ( controls != null ) { javax.naming.ldap.Control[] jndiControls = new javax.naming.ldap.Control[controls.length]; int i = 0; for ( Control control : controls ) { jndiControls[i++] = toJndiControl( codec, control ); } return jndiControls; } else { return null; } }
Example #3
Source File: SearchResultReferenceFactory.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Encode the SearchResultReference message to a PDU. * <br> * SearchResultReference : * <pre> * 0x73 LL * 0x04 LL reference * [0x04 LL reference]* * </pre> * * @param buffer The buffer where to put the PDU * @param message the SearchResultReference to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); SearchResultReference searchResultReference = ( SearchResultReference ) message; // The referrals, if any Referral referral = searchResultReference.getReferral(); if ( referral != null ) { // Each referral encodeReferralUrls( buffer, referral.getLdapUrls().iterator() ); } // The SearchResultEntry tag BerValue.encodeSequence( buffer, LdapCodecConstants.SEARCH_RESULT_REFERENCE_TAG, start ); }
Example #4
Source File: LdapNetworkConnection.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Creates a new LdapNetworkConnection instance * * @param config The configuration to use * @param ldapApiService The LDAP API Service to use */ public LdapNetworkConnection( LdapConnectionConfig config, LdapApiService ldapApiService ) { super( ldapApiService ); this.config = config; if ( config.getBinaryAttributeDetector() == null ) { config.setBinaryAttributeDetector( new DefaultConfigurableBinaryAttributeDetector() ); } this.timeout = config.getTimeout(); }
Example #5
Source File: ExtendedRequestFactory.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Encode the ExtendedRequest message to a PDU. * <br> * ExtendedRequest : * <pre> * 0x77 L1 * | * +--> 0x80 LL abcd requestName * [+--> 0x81 LL abcd requestValue] * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the DeleteResponse to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); ExtendedRequest extendedRequest = ( ExtendedRequest ) message; // The responseValue, if any ExtendedOperationFactory factory = codec.getExtendedRequestFactories(). get( extendedRequest.getRequestName() ); if ( factory != null ) { factory.encodeValue( buffer, extendedRequest ); if ( buffer.getPos() > start ) { BerValue.encodeSequence( buffer, ( byte ) LdapCodecConstants.EXTENDED_REQUEST_VALUE_TAG, start ); } } // The responseName, if any if ( !Strings.isEmpty( extendedRequest.getRequestName() ) ) { BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.EXTENDED_REQUEST_NAME_TAG, extendedRequest.getRequestName() ); } // The sequence BerValue.encodeSequence( buffer, LdapCodecConstants.EXTENDED_REQUEST_TAG, start ); }
Example #6
Source File: StandaloneLdapApiService.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Loads an extended request from its FQCN * * @param extendedRequestFQCN The extended operations to load * @throws Exception If the extended operations cannot be loaded */ private void loadExtendedRequest( String extendedRequestFQCN ) throws Exception { if ( getExtendedRequestFactories().containsKey( extendedRequestFQCN ) ) { if ( LOG.isDebugEnabled() ) { LOG.debug( I18n.msg( I18n.MSG_06005_EXTENDED_OP_FACTORY_ALREADY_LOADED, extendedRequestFQCN ) ); } return; } Class<?>[] types = new Class<?>[] { LdapApiService.class }; // note, trimming whitespace doesn't hurt as it is a class name and // helps DI containers that use xml config as xml ignores whitespace @SuppressWarnings("unchecked") Class<? extends ExtendedOperationFactory> clazz = ( Class<? extends ExtendedOperationFactory> ) Class .forName( extendedRequestFQCN.trim() ); Constructor<?> constructor = clazz.getConstructor( types ); ExtendedOperationFactory factory = ( ExtendedOperationFactory ) constructor .newInstance( this ); getExtendedRequestFactories().put( factory.getOid(), factory ); if ( LOG.isInfoEnabled() ) { LOG.info( I18n.msg( I18n.MSG_06001_REGISTERED_EXTENDED_OP_FACTORY, factory.getOid() ) ); } }
Example #7
Source File: ModifyDnRequestFactory.java From directory-ldap-api with Apache License 2.0 | 5 votes |
/** * Encode the ModifyDnRequest message to a PDU. * <br> * ModifyDNRequest : * <pre> * 0x6C LL * 0x04 LL entry * 0x04 LL newRDN * 0x01 0x01 deleteOldRDN * [0x80 LL newSuperior] * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the ModifyRequest to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); ModifyDnRequest modifyDnRequest = ( ModifyDnRequest ) message; if ( modifyDnRequest.getNewSuperior() != null ) { // Encode the new superior BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.MODIFY_DN_REQUEST_NEW_SUPERIOR_TAG, Strings.getBytesUtf8( modifyDnRequest.getNewSuperior().getName() ) ); } // The deleteOldRdn flag BerValue.encodeBoolean( buffer, modifyDnRequest.getDeleteOldRdn() ); // The new RDN BerValue.encodeOctetString( buffer, modifyDnRequest.getNewRdn().getName() ); // The entry DN BerValue.encodeOctetString( buffer, modifyDnRequest.getName().getName() ); // The ModifyDnRequest tag BerValue.encodeSequence( buffer, LdapCodecConstants.MODIFY_DN_REQUEST_TAG, start ); }
Example #8
Source File: ApiLdapCodecCoreOsgiTest.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Test public void testLookupLdapApiService() { ServiceReference<LdapApiService> serviceReference = context.getServiceReference( LdapApiService.class ); Object service = context.getService( serviceReference ); assertNotNull( service ); assertTrue( service instanceof LdapApiService ); }
Example #9
Source File: LdapProtocolCodecActivator.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Override public LdapApiService addingService( ServiceReference<LdapApiService> reference ) { LdapApiService ldapApiService = bundleContext.getService( reference ); LdapProtocolCodecFactory factory = new LdapProtocolCodecFactory( ldapApiService ); registration = bundleContext.registerService( LdapProtocolCodecFactory.class.getName(), factory, null ); ldapApiService.registerProtocolCodecFactory( factory ); return ldapApiService; }
Example #10
Source File: ExtrasBundleActivator.java From directory-ldap-api with Apache License 2.0 | 5 votes |
@Override public LdapApiService addingService( ServiceReference<LdapApiService> reference ) { LdapApiService ldapApiService = context.getService( reference ); StockCodecFactoryUtil.loadStockControls( ldapApiService ); ExtrasCodecFactoryUtil.loadExtrasControls( ldapApiService ); ExtrasCodecFactoryUtil.loadExtrasExtendedOperations( ldapApiService ); ExtrasCodecFactoryUtil.loadExtrasIntermediateResponses( ldapApiService ); return ldapApiService; }
Example #11
Source File: LdapProtocolCodecActivator.java From directory-ldap-api with Apache License 2.0 | 4 votes |
@Override public void modifiedService( ServiceReference<LdapApiService> reference, LdapApiService service ) { // Do nothing ATM }
Example #12
Source File: ExtendedResponseFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Encode the ExtendedResponse message to a PDU. * <br> * ExtendedResponse : * <pre> * 0x78 L1 * | * +--> LdapResult * [+--> 0x8A LL abcd responseName] * [+--> 0x8B LL abcd responseValue] * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the ExtendedResponse to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); ExtendedResponse extendedResponse = ( ExtendedResponse ) message; // The responseValue, if any ExtendedOperationFactory factory = codec.getExtendedResponseFactories(). get( extendedResponse.getResponseName() ); if ( factory != null ) { factory.encodeValue( buffer, extendedResponse ); if ( buffer.getPos() > start ) { BerValue.encodeSequence( buffer, ( byte ) LdapCodecConstants.EXTENDED_RESPONSE_VALUE_TAG, start ); } } else { byte[] responseValue = ( ( OpaqueExtendedResponse ) extendedResponse ).getResponseValue(); if ( !Strings.isEmpty( responseValue ) ) { BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.EXTENDED_RESPONSE_VALUE_TAG, responseValue ); } } // The responseName, if any if ( !Strings.isEmpty( extendedResponse.getResponseName() ) ) { BerValue.encodeOctetString( buffer, ( byte ) LdapCodecConstants.EXTENDED_RESPONSE_NAME_TAG, extendedResponse.getResponseName() ); } // The LDAPResult part encodeLdapResultReverse( buffer, extendedResponse.getLdapResult() ); // The sequence BerValue.encodeSequence( buffer, LdapCodecConstants.EXTENDED_RESPONSE_TAG, start ); }
Example #13
Source File: LdapConnectionConfig.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return the ldapApiService */ public LdapApiService getLdapApiService() { return ldapApiService; }
Example #14
Source File: InMemoryDirectoryServiceFactory.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public LdapApiService getLdapCodecService() { return wrapped.getLdapCodecService(); }
Example #15
Source File: Dsmlv2Grammar.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return The LDAP codec service. */ public LdapApiService getLdapCodecService() { return codec; }
Example #16
Source File: SearchResultEntryFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Encode the SearchResultEntry message to a PDU. * <br> * SearchResultEntry : * <pre> * 0x64 LL * 0x04 LL objectName * 0x30 LL attributes * 0x30 LL partialAttributeList * 0x04 LL type * 0x31 LL vals * 0x04 LL attributeValue * ... * 0x04 LL attributeValue * ... * 0x30 LL partialAttributeList * 0x04 LL type * 0x31 LL vals * 0x04 LL attributeValue * ... * 0x04 LL attributeValue * </pre> * * @param buffer The buffer where to put the PDU * @param message the SearchResultEntry to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); SearchResultEntry searchResultEntry = ( SearchResultEntry ) message; // The partial attribute list Entry entry = searchResultEntry.getEntry(); // The attributes, recursively, if we have any if ( ( entry != null ) && ( entry.size() != 0 ) ) { encodeAttributes( buffer, entry.iterator() ); } // The attributes sequence BerValue.encodeSequence( buffer, start ); // The objectName BerValue.encodeOctetString( buffer, searchResultEntry.getObjectName().getName() ); // The SearchResultEntry tag BerValue.encodeSequence( buffer, LdapCodecConstants.SEARCH_RESULT_ENTRY_TAG, start ); }
Example #17
Source File: AbstractPasswordPolicyResponder.java From directory-ldap-api with Apache License 2.0 | 4 votes |
protected AbstractPasswordPolicyResponder( LdapApiService ldapApiService ) { this.passwordPolicyResponseControl = new PasswordPolicyResponseImpl(); }
Example #18
Source File: PasswordPolicyResponderImpl.java From directory-ldap-api with Apache License 2.0 | 4 votes |
PasswordPolicyResponderImpl( LdapApiService ldapApiService ) { super( ldapApiService ); }
Example #19
Source File: LdapConnectionConfig.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @param ldapApiService the ldapApiService to set */ public void setLdapApiService( LdapApiService ldapApiService ) { this.ldapApiService = ldapApiService; }
Example #20
Source File: AbstractLdapConnection.java From directory-ldap-api with Apache License 2.0 | 4 votes |
protected AbstractLdapConnection( LdapApiService codec ) { messageId = new AtomicInteger( 0 ); this.codec = codec; }
Example #21
Source File: DefaultLdapConnectionFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public LdapApiService getLdapApiService() { return apiService; }
Example #22
Source File: AbstractTest.java From directory-ldap-api with Apache License 2.0 | 4 votes |
public LdapApiService getCodec() { return codec; }
Example #23
Source File: AbstractDsmlMessageDecorator.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return The codec to use to encode or decode this message */ public LdapApiService getCodecService() { return codec; }
Example #24
Source File: StandaloneLdapApiService.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Creates a new instance of StandaloneLdapApiService. * * @param requestControls The list of request controls to store * @param responseControls The list of response controls to store * @param extendedOperations The list of extended operations to store * @param intermediateResponses The list of intermediate responsess to store * @throws Exception If we had an issue with one of the two lists */ public StandaloneLdapApiService( List<String> requestControls, List<String> responseControls, List<String> extendedOperations, List<String> intermediateResponses ) throws Exception { StockCodecFactoryUtil.loadStockControls( this ); ExtrasCodecFactoryUtil.loadExtrasControls( this ); ExtrasCodecFactoryUtil.loadExtrasExtendedOperations( this ); ExtrasCodecFactoryUtil.loadExtrasIntermediateResponses( this ); // Load the controls loadControls( requestControls, getRequestControlFactories() ); loadControls( responseControls, getResponseControlFactories() ); // Load the extended operations loadExtendedOperations( extendedOperations ); // Load the extended operations loadIntermediateResponse( intermediateResponses ); if ( getProtocolCodecFactory() == null ) { try { @SuppressWarnings("unchecked") Class<? extends ProtocolCodecFactory> clazz = ( Class<? extends ProtocolCodecFactory> ) Class.forName( DEFAULT_PROTOCOL_CODEC_FACTORY ); Constructor<? extends ProtocolCodecFactory> constructor = clazz.getConstructor( LdapApiService.class ); if ( constructor != null ) { setProtocolCodecFactory( constructor.newInstance( this ) ); } else { setProtocolCodecFactory( clazz.newInstance() ); } } catch ( Exception cause ) { throw new RuntimeException( I18n.err( I18n.ERR_06000_FAILED_TO_LOAD_DEFAULT_CODEC_FACTORY ), cause ); } } }
Example #25
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 ); }
Example #26
Source File: SearchRequestFactory.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Encode the SearchRequest message to a PDU. * <br> * SearchRequest : * <pre> * 0x63 LL * 0x04 LL baseObject * 0x0A 01 scope * 0x0A 01 derefAliases * 0x02 0N sizeLimit * 0x02 0N timeLimit * 0x01 0x01 typesOnly * filter.encode() * 0x30 LL attributeDescriptionList * 0x04 LL attributeDescription * ... * 0x04 LL attributeDescription * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param message the ModifyRequest to encode */ @Override public void encodeReverse( LdapApiService codec, Asn1Buffer buffer, Message message ) { int start = buffer.getPos(); SearchRequest searchRequest = ( SearchRequest ) message; // The attributes, if any List<String> attributes = searchRequest.getAttributes(); if ( ( attributes != null ) && ( !attributes.isEmpty() ) ) { for ( int i = attributes.size(); i > 0; i-- ) { BerValue.encodeOctetString( buffer, attributes.get( i - 1 ) ); } } // The attributes sequence BerValue.encodeSequence( buffer, start ); // The filter encodeFilter( buffer, searchRequest.getFilter() ); // The typesOnly BerValue.encodeBoolean( buffer, searchRequest.getTypesOnly() ); // The timeLimit BerValue.encodeInteger( buffer, searchRequest.getTimeLimit() ); // The sizeLimit BerValue.encodeInteger( buffer, searchRequest.getSizeLimit() ); // The derefAliases BerValue.encodeEnumerated( buffer, searchRequest.getDerefAliases().getValue() ); // The scope BerValue.encodeEnumerated( buffer, searchRequest.getScope().getScope() ); // The base object BerValue.encodeOctetString( buffer, Strings.getBytesUtf8( searchRequest.getBase().getName() ) ); // The SearchRequest tag BerValue.encodeSequence( buffer, LdapCodecConstants.SEARCH_REQUEST_TAG, start ); }
Example #27
Source File: ErrorResponse.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return The LdapApiService instance */ public LdapApiService getCodecService() { throw new IllegalArgumentException( I18n.err( I18n.ERR_03044_SHOULD_NOT_BE_A_DECORATOR ) ); }
Example #28
Source File: DsmlControl.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return The LDAP codec service. */ public LdapApiService getCodecService() { return codec; }
Example #29
Source File: ResponseFactory.java From directory-ldap-api with Apache License 2.0 | 3 votes |
/** * Encode the Response message to a PDU. * <br> * Response : * <pre> * 0x<tag> L1 * | * +--> LdapResult * </pre> * * @param codec The LdapApiService instance * @param buffer The buffer where to put the PDU * @param tag The message tag * @param message the Response to encode */ protected void encodeReverse( LdapApiService codec, Asn1Buffer buffer, byte tag, Message message ) { int start = buffer.getPos(); // The LDAPResult part encodeLdapResultReverse( buffer, ( ( ResultResponse ) message ).getLdapResult() ); // The BindResponse Tag BerValue.encodeSequence( buffer, tag, start ); }
Example #30
Source File: LdapResultDsml.java From directory-ldap-api with Apache License 2.0 | 3 votes |
/** * Creates a new instance of LdapResultDsml. * * @param codec The LDAP Service to use * @param result the LdapResult to decorate * @param message the associated message */ public LdapResultDsml( LdapApiService codec, LdapResult result, Message message ) { this.codec = codec; this.result = result; this.message = message; }