You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Maxim Solodovnik <so...@gmail.com> on 2015/02/24 17:09:12 UTC

[DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Hello All,

recently I have proposed the patch to reduce copy/paste while implementing
custom IAuthenticationStrategy.

Actually this interface have 2 methods which are not correlate to each other
String[] load();
void save(final String username, final String password);

in fact this is getter and setter but with different signatures
The change I would like to propose is to replace (in Wicket7)
void save(final String username, final String password);
with
void save(final String... credentials);

this will allow to easily store additional credentials (like domain) and
will not introduce the code break since previous calls will work as expected

What do you think?

-- 
WBR
Maxim aka solomax

Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Tobias Soloschenko <to...@googlemail.com>.
I thought to take a HashMap, because in the save method you could read the keys - but if the load method also returns String[] and the order of credentials is well known varags might be ok.

kind regards

Tobias

> Am 25.02.2015 um 05:14 schrieb Maxim Solodovnik <so...@gmail.com>:
> 
> Actually load() method return String[] (actually with arbitrary number of
> elements and arbitrary order) so I see no issue here, You read parameters
> in the same order as you wright them.
> Map<String,String> will make things worst IMHO since the order will not be
> the same
> 
> On Wed, Feb 25, 2015 at 4:16 AM, Tobias Soloschenko <
> tobiassoloschenko@googlemail.com> wrote:
> 
>> Hi Maxim,
>> 
>> I think this isn't a good idea because the order in which the arguments
>> are added to the save method is important - and what if you want to let one
>> argument away? Then the rest would not used for their purpose.
>> 
>> Instead I would add another method save method that takes a Map with key
>> value pairs (key are used to identify the values)
>> map.put("username","tom");
>> map.put("password","secret);
>> map.put("host","127.0.0.1");
>> 
>> the save method could be invoked internally with
>> #save(map.get("username"),map.get("password"));
>> 
>> Another way:
>> 
>> Oracle uses system properties - (http://docs.oracle.com/
>> javase/7/docs/api/java/net/doc-files/net-properties.html)
>> System.setProperty("org.apache.auth.username","tom");
>> System.setProperty("org.apache.auth.password","secret");
>> the save method could be invoked internally with
>> #save(System.getProperty("org.apache.auth.username"),System.
>> getProperty("org.apache.auth.username"));
>> 
>> kind regards
>> 
>> Tobias
>> 
>> Am 24.02.15 um 17:09 schrieb Maxim Solodovnik:
>> 
>> Hello All,
>>> 
>>> recently I have proposed the patch to reduce copy/paste while implementing
>>> custom IAuthenticationStrategy.
>>> 
>>> Actually this interface have 2 methods which are not correlate to each
>>> other
>>> String[] load();
>>> void save(final String username, final String password);
>>> 
>>> in fact this is getter and setter but with different signatures
>>> The change I would like to propose is to replace (in Wicket7)
>>> void save(final String username, final String password);
>>> with
>>> void save(final String... credentials);
>>> 
>>> this will allow to easily store additional credentials (like domain) and
>>> will not introduce the code break since previous calls will work as
>>> expected
>>> 
>>> What do you think?
> 
> 
> -- 
> WBR
> Maxim aka solomax

Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Maxim Solodovnik <so...@gmail.com>.
Actually load() method return String[] (actually with arbitrary number of
elements and arbitrary order) so I see no issue here, You read parameters
in the same order as you wright them.
Map<String,String> will make things worst IMHO since the order will not be
the same

On Wed, Feb 25, 2015 at 4:16 AM, Tobias Soloschenko <
tobiassoloschenko@googlemail.com> wrote:

> Hi Maxim,
>
> I think this isn't a good idea because the order in which the arguments
> are added to the save method is important - and what if you want to let one
> argument away? Then the rest would not used for their purpose.
>
> Instead I would add another method save method that takes a Map with key
> value pairs (key are used to identify the values)
> map.put("username","tom");
> map.put("password","secret);
> map.put("host","127.0.0.1");
>
> the save method could be invoked internally with
> #save(map.get("username"),map.get("password"));
>
> Another way:
>
> Oracle uses system properties - (http://docs.oracle.com/
> javase/7/docs/api/java/net/doc-files/net-properties.html)
> System.setProperty("org.apache.auth.username","tom");
> System.setProperty("org.apache.auth.password","secret");
> the save method could be invoked internally with
> #save(System.getProperty("org.apache.auth.username"),System.
> getProperty("org.apache.auth.username"));
>
> kind regards
>
> Tobias
>
> Am 24.02.15 um 17:09 schrieb Maxim Solodovnik:
>
>  Hello All,
>>
>> recently I have proposed the patch to reduce copy/paste while implementing
>> custom IAuthenticationStrategy.
>>
>> Actually this interface have 2 methods which are not correlate to each
>> other
>> String[] load();
>> void save(final String username, final String password);
>>
>> in fact this is getter and setter but with different signatures
>> The change I would like to propose is to replace (in Wicket7)
>> void save(final String username, final String password);
>> with
>> void save(final String... credentials);
>>
>> this will allow to easily store additional credentials (like domain) and
>> will not introduce the code break since previous calls will work as
>> expected
>>
>> What do you think?
>>
>>
>


-- 
WBR
Maxim aka solomax

Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Tobias Soloschenko <to...@googlemail.com>.
Hi Maxim,

I think this isn't a good idea because the order in which the arguments 
are added to the save method is important - and what if you want to let 
one argument away? Then the rest would not used for their purpose.

Instead I would add another method save method that takes a Map with key 
value pairs (key are used to identify the values)
map.put("username","tom");
map.put("password","secret);
map.put("host","127.0.0.1");

the save method could be invoked internally with 
#save(map.get("username"),map.get("password"));

Another way:

Oracle uses system properties - 
(http://docs.oracle.com/javase/7/docs/api/java/net/doc-files/net-properties.html)
System.setProperty("org.apache.auth.username","tom");
System.setProperty("org.apache.auth.password","secret");
the save method could be invoked internally with 
#save(System.getProperty("org.apache.auth.username"),System.getProperty("org.apache.auth.username"));

kind regards

Tobias

Am 24.02.15 um 17:09 schrieb Maxim Solodovnik:
> Hello All,
>
> recently I have proposed the patch to reduce copy/paste while implementing
> custom IAuthenticationStrategy.
>
> Actually this interface have 2 methods which are not correlate to each other
> String[] load();
> void save(final String username, final String password);
>
> in fact this is getter and setter but with different signatures
> The change I would like to propose is to replace (in Wicket7)
> void save(final String username, final String password);
> with
> void save(final String... credentials);
>
> this will allow to easily store additional credentials (like domain) and
> will not introduce the code break since previous calls will work as expected
>
> What do you think?
>


Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Martin Grigorov <mg...@apache.org>.
On Wed, Feb 25, 2015 at 11:13 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> >> In the patch for Wicket 7.x in WICKET-5823 you added a new method to the
> >> API, instead of replacing the old one. Having several #save() methods
> >> didn't look OK to me.
>
> sorry for that, I was afraid to break all existing code (wasn't aware
> varargs param will not be API break)
>
> #save(String, String...) is OK for me, should I create new pull request?
>

Sure!
I'll wait for some more opinions before merging it though.


>
> On Wed, Feb 25, 2015 at 3:00 PM, Martin Grigorov <mg...@apache.org>
> wrote:
>
> > Hi Maxim,
> >
> > On Tue, Feb 24, 2015 at 6:09 PM, Maxim Solodovnik <so...@gmail.com>
> > wrote:
> >
> > > Hello All,
> > >
> > > recently I have proposed the patch to reduce copy/paste while
> > implementing
> > > custom IAuthenticationStrategy.
> > >
> >
> > https://issues.apache.org/jira/browse/WICKET-5823
> >
> >
> > >
> > > Actually this interface have 2 methods which are not correlate to each
> > > other
> > > String[] load();
> > > void save(final String username, final String password);
> > >
> > > in fact this is getter and setter but with different signatures
> > > The change I would like to propose is to replace (in Wicket7)
> > > void save(final String username, final String password);
> > > with
> > > void save(final String... credentials);
> > >
> > > this will allow to easily store additional credentials (like domain)
> and
> > > will not introduce the code break since previous calls will work as
> > > expected
> > >
> > > What do you think?
> > >
> >
> > Replacing #save(String, String) with #save(String, String, String...)
> looks
> > better to me.
> > This way it guarantees that the username and password are still provided.
> > Or maybe with #save(String, String...) - if only one thing will be saved
> > (e.g. a token?!).
> > #save(String...) suggests that it is possible to save nothing. I don't
> see
> > a use case for this.
> >
> > In the patch for Wicket 7.x in WICKET-5823 you added a new method to the
> > API, instead of replacing the old one. Having several #save() methods
> > didn't look OK to me.
> >
> >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>

Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Maxim Solodovnik <so...@gmail.com>.
>> In the patch for Wicket 7.x in WICKET-5823 you added a new method to the
>> API, instead of replacing the old one. Having several #save() methods
>> didn't look OK to me.

sorry for that, I was afraid to break all existing code (wasn't aware
varargs param will not be API break)

#save(String, String...) is OK for me, should I create new pull request?

On Wed, Feb 25, 2015 at 3:00 PM, Martin Grigorov <mg...@apache.org>
wrote:

> Hi Maxim,
>
> On Tue, Feb 24, 2015 at 6:09 PM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Hello All,
> >
> > recently I have proposed the patch to reduce copy/paste while
> implementing
> > custom IAuthenticationStrategy.
> >
>
> https://issues.apache.org/jira/browse/WICKET-5823
>
>
> >
> > Actually this interface have 2 methods which are not correlate to each
> > other
> > String[] load();
> > void save(final String username, final String password);
> >
> > in fact this is getter and setter but with different signatures
> > The change I would like to propose is to replace (in Wicket7)
> > void save(final String username, final String password);
> > with
> > void save(final String... credentials);
> >
> > this will allow to easily store additional credentials (like domain) and
> > will not introduce the code break since previous calls will work as
> > expected
> >
> > What do you think?
> >
>
> Replacing #save(String, String) with #save(String, String, String...) looks
> better to me.
> This way it guarantees that the username and password are still provided.
> Or maybe with #save(String, String...) - if only one thing will be saved
> (e.g. a token?!).
> #save(String...) suggests that it is possible to save nothing. I don't see
> a use case for this.
>
> In the patch for Wicket 7.x in WICKET-5823 you added a new method to the
> API, instead of replacing the old one. Having several #save() methods
> didn't look OK to me.
>
>
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: [DISCUSSION] WICKET-5823 IAuthenticationStrategy methods

Posted by Martin Grigorov <mg...@apache.org>.
Hi Maxim,

On Tue, Feb 24, 2015 at 6:09 PM, Maxim Solodovnik <so...@gmail.com>
wrote:

> Hello All,
>
> recently I have proposed the patch to reduce copy/paste while implementing
> custom IAuthenticationStrategy.
>

https://issues.apache.org/jira/browse/WICKET-5823


>
> Actually this interface have 2 methods which are not correlate to each
> other
> String[] load();
> void save(final String username, final String password);
>
> in fact this is getter and setter but with different signatures
> The change I would like to propose is to replace (in Wicket7)
> void save(final String username, final String password);
> with
> void save(final String... credentials);
>
> this will allow to easily store additional credentials (like domain) and
> will not introduce the code break since previous calls will work as
> expected
>
> What do you think?
>

Replacing #save(String, String) with #save(String, String, String...) looks
better to me.
This way it guarantees that the username and password are still provided.
Or maybe with #save(String, String...) - if only one thing will be saved
(e.g. a token?!).
#save(String...) suggests that it is possible to save nothing. I don't see
a use case for this.

In the patch for Wicket 7.x in WICKET-5823 you added a new method to the
API, instead of replacing the old one. Having several #save() methods
didn't look OK to me.


>
> --
> WBR
> Maxim aka solomax
>