You are viewing a plain text version of this content. The canonical link for it is here.
Posted to api@directory.apache.org by Shawn McKinney <sm...@apache.org> on 2021/06/23 20:04:31 UTC

Migration to 2.0 API has moved onto something a bit more relaxing

Onto the next problem…

As described back in April on this ML:

[Relax Control and password policies](http://mail-archives.apache.org/mod_mbox/directory-api/202104.mbox/%3CECC48E64-6CF9-40B7-8BC4-FCE60E40684E%40apache.org%3E)

I added support to use the Relax Control to the fortress core code base.

Moving onto 2.x API this control this code is now broken.

Specifically, I get this error when adding the control to an ldap request:

```
: ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12 
2021-06-23 14:36:023 WARN  LdapNetworkConnection:2478 - org.apache.directory.api.asn1.EncoderException: ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12
org.apache.mina.filter.codec.ProtocolEncoderException: org.apache.directory.api.asn1.EncoderException: ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12
```

Revisiting this example:
http://directory.apache.org/api/internal-design-guide/13-controls.html

I noticed that the decorator and factory classes weren’t implemented in my solution.  Actually, as I recall, I did add them, but realized they weren’t needed (with 1.x) and so I removed them.

I’ve since readded them:

1. [RelaxControlFactory](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlFactory.java)
2. [RelaxControlDecorator](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlDecorator.java)

To the existing two:

3. [RelaxControl](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControl.java)

4. [RelaxControlImpl](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlImpl.java)

During the readding of the decorator and factory, I also noticed that the example implentation referenced above does not match its associated interfaces, i.e. has changed since 1.x.  

So, I hacked a bit more to get my code to compile knowing that it's probably not right and guess what -- it isn’t.

Same error as above.  

Any help getting past this one is appreciated.

Still poking around 2.0 codebase to find viable example (for 2.0), and will keep looking.

Thanks

—
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Emmanuel Lécharny <el...@gmail.com>.

On 24/06/2021 15:57, Shawn McKinney wrote:
> interfaces should describe a type and hence have methods

Does RelaxControl extends  Control ?

-- 
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecharny@busit.com https://www.busit.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: [RESOLVED] Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Shawn McKinney <sm...@apache.org>.
> On Jun 24, 2021, at 2:15 PM, Stefan Seelmann <ma...@stefan-seelmann.de> wrote:
> 
> Looks good. The OSGi import/export definitions were missing, I added
> them. They are required by Studio because it's based on Eclipse.
> 
> https://github.com/apache/directory-ldap-api/commit/7406985321280d745cc2baf0ef017e9108ce3dfb
> 

Nice catch Stefan and thanks for letting me know.

—
Shawn
---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: [RESOLVED] Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Stefan Seelmann <ma...@stefan-seelmann.de>.
On 6/24/21 7:42 PM, Shawn McKinney wrote:
> Changes pushed into api for the new control:
> 
> https://github.com/apache/directory-ldap-api/commit/100002353c1487412b0c7e0d36a68297ab713dd0
> 
> Let me know if there’s anything I missed / got wrong.
> 
> I’ve left the control in fortress for now, until the 2.0.3 release is out.
> 
> That resolves this issue, thanks for the help.
Looks good. The OSGi import/export definitions were missing, I added
them. They are required by Studio because it's based on Eclipse.

https://github.com/apache/directory-ldap-api/commit/7406985321280d745cc2baf0ef017e9108ce3dfb


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


[RESOLVED] Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Shawn McKinney <sm...@apache.org>.
Changes pushed into api for the new control:

https://github.com/apache/directory-ldap-api/commit/100002353c1487412b0c7e0d36a68297ab713dd0

Let me know if there’s anything I missed / got wrong.

I’ve left the control in fortress for now, until the 2.0.3 release is out.

That resolves this issue, thanks for the help.

—
Shawn
---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Shawn McKinney <sm...@apache.org>.

> On Jun 24, 2021, at 10:11 AM, Emmanuel Lécharny <el...@gmail.com> wrote:
> 
> 
> On 24/06/2021 15:57, Shawn McKinney wrote:
>> interfaces should describe a type and hence have methods
> 
> Whatever.
> 
> There is a suppressions.xml file in src/checkstyle that list the classes that are to be ignred. here is its content:
> 

The answer to your earlier question, ‘yes’, it extends Control:

```
public interface RelaxControl extends Control
{
  String OID = "1.3.6.1.4.1.4203.666.5.12";

  String getOID();
}
```

As you can see, I worked around the check styles problem by adding a trivial method, getOID to the interface.

So, I’ll not add it to the suppressions list, as most of its checks are fine.  But, thanks for letting me know. (I knew there must be one somewhere)


> <suppressions>
>    <!-- Control inferfaces that don't declare any new method -->
>    <suppress files="org.apache.directory.api.ldap.extras.extended" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.ad" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.permissiveModify" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.ppolicy" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.changeNotifications" checks="InterfaceIsType" />
> </suppressions>
> 
> Add the RelaxControl in this file :
> 
> <suppressions>
>    <!-- Control inferfaces that don't declare any new method -->
>    <suppress files="org.apache.directory.api.ldap.extras.extended" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.ad" checks="InterfaceIsType" />
>    <suppress files="org.apache.directory.api.ldap.extras.controls.relax" checks="InterfaceIsType" />
> ...
> </suppressions>


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Emmanuel Lécharny <el...@gmail.com>.

On 24/06/2021 15:57, Shawn McKinney wrote:
> interfaces should describe a type and hence have methods

Whatever.

There is a suppressions.xml file in src/checkstyle that list the classes 
that are to be ignred. here is its content:

<suppressions>
     <!-- Control inferfaces that don't declare any new method -->
     <suppress files="org.apache.directory.api.ldap.extras.extended" 
checks="InterfaceIsType" />
     <suppress files="org.apache.directory.api.ldap.extras.controls.ad" 
checks="InterfaceIsType" />
     <suppress 
files="org.apache.directory.api.ldap.extras.controls.permissiveModify" 
checks="InterfaceIsType" />
     <suppress 
files="org.apache.directory.api.ldap.extras.controls.ppolicy" 
checks="InterfaceIsType" />
     <suppress 
files="org.apache.directory.api.ldap.extras.controls.changeNotifications" checks="InterfaceIsType" 
/>
</suppressions>

Add the RelaxControl in this file :

<suppressions>
     <!-- Control inferfaces that don't declare any new method -->
     <suppress files="org.apache.directory.api.ldap.extras.extended" 
checks="InterfaceIsType" />
     <suppress files="org.apache.directory.api.ldap.extras.controls.ad" 
checks="InterfaceIsType" />
     <suppress 
files="org.apache.directory.api.ldap.extras.controls.relax" 
checks="InterfaceIsType" />
...
</suppressions>

-- 
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecharny@busit.com https://www.busit.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Shawn McKinney <sm...@apache.org>.
> On Jun 23, 2021, at 11:30 PM, Emmanuel Lécharny <el...@gmail.com> wrote:
> 
> On 24/06/2021 06:25, Stefan Seelmann wrote:
>> On 6/24/21 4:10 AM, Shawn McKinney wrote:
>>> The debugger tells me that api request controls are loaded in [StockCodecFactoryUtil](https://github.com/apache/directory-ldap-api/blob/master/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/StockCodecFactoryUtil.java)
>>> 
>>> So, I added my RelaxControl into the api code space, and added this blurb to StockCodecFactoryUtil class:
>>> 
>>> ```
>>> ControlFactory<RelaxControl> relaxControlFactory = new RelaxControlFactory( apiService );
>>> requestControlFactories.put( relaxControlFactory.getOid(), relaxControlFactory );
>>> ```
>>> 
>>> Once registered the control is found by the runtime and things become … well Relaxed ;-)
>> I'm not sure if the control should be placed into api-ldap-codec-core or
>> better api-ldap-extras-codec (there's a ExtrasCodecFactoryUtil to
>> register controls) which contains, well, non-core control. Feel free to
>> commit it, then we can include it in the next release.
> 
> Definitively in extra-codec.
> 

OK, moving into these packages:

1. directory-ldap-api/ldap/extras/codec/src/main/java/org/apache/directory/api/ldap/extras/controls/relax_impl:

RelaxControlFactory.java
	
2. directory-ldap-api/ldap/extras/codec-api/src/main/java/org/apache/directory/api/ldap/extras/controls:

RelaxControl.java
RelaxControlImpl.java

3. Registering control here:
ExtrasCodecFactoryUtil.java

> 
>> The other option, if you don't want to add it to the LDAP API, is to
>> register it in Fortress. You can get a handle to the registries via
>> LdapNetworkConnection.getCodecService().registerRequestControl(). 
> 
> Indeed.  But I think it better fits the extra-codec part of the API, as it's not related to Fortress (it's a LDAP draft).
> 

Will do, but have two problems to work out:

1. Checkstyle plugin flags the RelaxControl interface and fails compilation:

[INFO] --- maven-checkstyle-plugin:3.1.2:check (validate) @ api-ldap-extras-codec-api ---
[INFO] There is 1 error reported by Checkstyle 8.42 with directory-checks.xml ruleset.
[ERROR] src/main/java/org/apache/directory/api/ldap/extras/controls/relax/RelaxControl.java:[35,1] (design) InterfaceIsType: interfaces should describe a type and hence have methods.

FWICT, other controls do it the same way.  That is, no public methods, only a constant.

How do I get past this?

2. Need a way for this control to work in fortress before the next api release.  So, maybe I have it in both places for now?  Still thinking about this one.

—
Shawn


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Emmanuel Lécharny <el...@gmail.com>.

On 24/06/2021 06:25, Stefan Seelmann wrote:
> On 6/24/21 4:10 AM, Shawn McKinney wrote:
>> The debugger tells me that api request controls are loaded in [StockCodecFactoryUtil](https://github.com/apache/directory-ldap-api/blob/master/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/StockCodecFactoryUtil.java)
>>
>> So, I added my RelaxControl into the api code space, and added this blurb to StockCodecFactoryUtil class:
>>
>> ```
>> ControlFactory<RelaxControl> relaxControlFactory = new RelaxControlFactory( apiService );
>> requestControlFactories.put( relaxControlFactory.getOid(), relaxControlFactory );
>> ```
>>
>> Once registered the control is found by the runtime and things become … well Relaxed ;-)
> 
> I'm not sure if the control should be placed into api-ldap-codec-core or
> better api-ldap-extras-codec (there's a ExtrasCodecFactoryUtil to
> register controls) which contains, well, non-core control. Feel free to
> commit it, then we can include it in the next release.

Definitively in extra-codec.


> 
> The other option, if you don't want to add it to the LDAP API, is to
> register it in Fortress. You can get a handle to the registries via
> LdapNetworkConnection.getCodecService().registerRequestControl(). 

Indeed.  But I think it better fits the extra-codec part of the API, as 
it's not related to Fortress (it's a LDAP draft).


-- 
*Emmanuel Lécharny - CTO* 205 Promenade des Anglais – 06200 NICE
T. +33 (0)4 89 97 36 50
P. +33 (0)6 08 33 32 61
emmanuel.lecharny@busit.com https://www.busit.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Stefan Seelmann <ma...@stefan-seelmann.de>.
On 6/24/21 4:10 AM, Shawn McKinney wrote:
> The debugger tells me that api request controls are loaded in [StockCodecFactoryUtil](https://github.com/apache/directory-ldap-api/blob/master/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/StockCodecFactoryUtil.java)
> 
> So, I added my RelaxControl into the api code space, and added this blurb to StockCodecFactoryUtil class:
> 
> ```
> ControlFactory<RelaxControl> relaxControlFactory = new RelaxControlFactory( apiService );
> requestControlFactories.put( relaxControlFactory.getOid(), relaxControlFactory );
> ```
> 
> Once registered the control is found by the runtime and things become … well Relaxed ;-)

I'm not sure if the control should be placed into api-ldap-codec-core or
better api-ldap-extras-codec (there's a ExtrasCodecFactoryUtil to
register controls) which contains, well, non-core control. Feel free to
commit it, then we can include it in the next release.

The other option, if you don't want to add it to the LDAP API, is to
register it in Fortress. You can get a handle to the registries via
LdapNetworkConnection.getCodecService().registerRequestControl().

Kind Regards,
Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org


Re: Migration to 2.0 API has moved onto something a bit more relaxing

Posted by Shawn McKinney <sm...@apache.org>.
The debugger tells me that api request controls are loaded in [StockCodecFactoryUtil](https://github.com/apache/directory-ldap-api/blob/master/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/StockCodecFactoryUtil.java)

So, I added my RelaxControl into the api code space, and added this blurb to StockCodecFactoryUtil class:

```
ControlFactory<RelaxControl> relaxControlFactory = new RelaxControlFactory( apiService );
requestControlFactories.put( relaxControlFactory.getOid(), relaxControlFactory );
```

Once registered the control is found by the runtime and things become … well Relaxed ;-)

—
Shawn

> On Jun 23, 2021, at 3:04 PM, Shawn McKinney <sm...@apache.org> wrote:
> 
> Onto the next problem…
> 
> As described back in April on this ML:
> 
> [Relax Control and password policies](http://mail-archives.apache.org/mod_mbox/directory-api/202104.mbox/%3CECC48E64-6CF9-40B7-8BC4-FCE60E40684E%40apache.org%3E)
> 
> I added support to use the Relax Control to the fortress core code base.
> 
> Moving onto 2.x API this control this code is now broken.
> 
> Specifically, I get this error when adding the control to an ldap request:
> 
> ```
> : ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12 
> 2021-06-23 14:36:023 WARN  LdapNetworkConnection:2478 - org.apache.directory.api.asn1.EncoderException: ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12
> org.apache.mina.filter.codec.ProtocolEncoderException: org.apache.directory.api.asn1.EncoderException: ERR_08002_CANNOT_FIND_CONTROL_FACTORY failed to find a control factory for control OID: 1.3.6.1.4.1.4203.666.5.12
> ```
> 
> Revisiting this example:
> http://directory.apache.org/api/internal-design-guide/13-controls.html
> 
> I noticed that the decorator and factory classes weren’t implemented in my solution.  Actually, as I recall, I did add them, but realized they weren’t needed (with 1.x) and so I removed them.
> 
> I’ve since readded them:
> 
> 1. [RelaxControlFactory](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlFactory.java)
> 2. [RelaxControlDecorator](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlDecorator.java)
> 
> To the existing two:
> 
> 3. [RelaxControl](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControl.java)
> 
> 4. [RelaxControlImpl](https://github.com/apache/directory-fortress-core/blob/FC-238/src/main/java/org/apache/directory/fortress/core/ldap/RelaxControlImpl.java)
> 
> During the readding of the decorator and factory, I also noticed that the example implentation referenced above does not match its associated interfaces, i.e. has changed since 1.x.  
> 
> So, I hacked a bit more to get my code to compile knowing that it's probably not right and guess what -- it isn’t.
> 
> Same error as above.  
> 
> Any help getting past this one is appreciated.
> 
> Still poking around 2.0 codebase to find viable example (for 2.0), and will keep looking.
> 
> Thanks
> 
> —
> Shawn
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: api-unsubscribe@directory.apache.org
For additional commands, e-mail: api-help@directory.apache.org