Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 207521 - [api] add ability to not save passwords in TaskRepository to keyring
Summary: [api] add ability to not save passwords in TaskRepository to keyring
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 2.2   Edit
Assignee: Steffen Pingel CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 200634
  Show dependency tree
 
Reported: 2007-10-25 18:44 EDT by Steffen Pingel CLA
Modified: 2007-11-07 15:15 EST (History)
3 users (show)

See Also:


Attachments
mylyn/context/zip (8.37 KB, application/octet-stream)
2007-10-25 19:57 EDT, Steffen Pingel CLA
no flags Details
patch (26.60 KB, patch)
2007-10-25 20:32 EDT, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (11.85 KB, application/octet-stream)
2007-10-25 20:32 EDT, Steffen Pingel CLA
no flags Details
use enum for make authentication (55.20 KB, text/plain)
2007-10-29 22:07 EDT, Steffen Pingel CLA
no flags Details
mylyn/context/zip (19.66 KB, application/octet-stream)
2007-10-29 22:09 EDT, Steffen Pingel CLA
no flags Details
use enum for authentication type (57.70 KB, patch)
2007-10-30 04:41 EDT, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (27.97 KB, application/octet-stream)
2007-10-30 04:41 EDT, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Steffen Pingel CLA 2007-10-25 18:44:27 EDT
Add API to set flags for saving passwords.
Comment 1 Steffen Pingel CLA 2007-10-25 19:57:06 EDT
Created attachment 81217 [details]
mylyn/context/zip
Comment 2 Steffen Pingel CLA 2007-10-25 20:32:42 EDT
Created attachment 81219 [details]
patch

The patch adds support in TaskRepository to store passwords without saving to the key ring. It also adds checkboxes to the repository settings page to select if passwords should be saved.

The implementation adds a generic method to TaskRepository that allows to set and retrieve credentials for different types of authentication (repository (default), http, proxy). The authentication type is a string. I have cleaned up some of the code duplication in that class but it should be reviewed for 3.0.

Rob, please review and apply.

The repository settings page is currently lacking a warning that storing passwords is potentially dangerous. This could be displayed in the dialog header when Save Password is selected to avoid cluttering the UI further.
Comment 3 Steffen Pingel CLA 2007-10-25 20:32:44 EDT
Created attachment 81220 [details]
mylyn/context/zip
Comment 4 Eugene Kuleshov CLA 2007-10-25 21:21:57 EDT
Isn't 3 separate settings for saving passwords is too much or I am missing something? I think it complicates UI even more then per-repository timeouts that been considered too complicated (and in my humble opinion timeouts are more critical then this).
Comment 5 Steffen Pingel CLA 2007-10-25 21:33:31 EDT
I agree that having three check boxes is not optimal. The reason I added all three is that there is scenario where a I have less valuable passwords for proxies or http authentication than for the repository. I would want to save those but enter the one for the repository once per session. 

At some point the check boxes could be replaced by a separate UI in the preferences for managing passwords. I suggest to go with the current solution and improve when have more resources.
Comment 6 Robert Elves CLA 2007-10-25 21:35:25 EDT
The TaskRepository refactoring and unit tests look great.  Patch applied.  Lets iterate on the repository settings page ui.  I agree with Eugene's observation regarding number of save password options. We should also consider switching the presentation order to:   Save Password [X]   (we may still have space for a short warning label right after that as well).
Comment 7 Eugene Kuleshov CLA 2007-10-25 22:17:05 EDT
Few more random comments on the changes:

- @deprecated should have some description what to use instead
- values for standard properties (including should "save password") should came from single place in IRepositoryConstants and not from constants in TaskRepository class
- Why the following method are public api? I don't see them used anywhere outside TaskRepository
  getUserName(String authType) 
  getPassword(String authType) 
  setCredentials(String authType, String username, String password)
Comment 8 Steffen Pingel CLA 2007-10-25 22:26:27 EDT
 (In reply to comment #7)
> - @deprecated should have some description what to use instead

IMHO, the deprecated fields shouldn't have been API in the first place. The alternative is to not use them.

> - values for standard properties (including should "save password") should came
> from single place in IRepositoryConstants and not from constants in
> TaskRepository class

Sounds like a good idea. Please file a bug report for that.

> - Why the following method are public api? I don't see them used anywhere
> outside TaskRepository
> getUserName(String authType)
> getPassword(String authType)
> setCredentials(String authType, String username, String password)

The patch is part of a larger set of patches that I split up to ease the review process. Please see the sibling bugs and parent bug of this report for details.
Comment 9 Eugene Kuleshov CLA 2007-10-25 23:54:31 EDT
(In reply to comment #8)
> > - @deprecated should have some description what to use instead
> IMHO, the deprecated fields shouldn't have been API in the first place. The
> alternative is to not use them.

So, that is what you should put into the deprecation text

> > - values for standard properties (including should "save password") should
> came
> > from single place in IRepositoryConstants and not from constants in
> > TaskRepository class
> Sounds like a good idea. Please file a bug report for that.

I am really surprised with such response. My comments are related to the api changes in a scope of the currently *open* bug.

> > - Why the following method are public api? I don't see them used anywhere
> > outside TaskRepository
> > getUserName(String authType)
> > getPassword(String authType)
> > setCredentials(String authType, String username, String password)
> The patch is part of a larger set of patches that I split up to ease the review
> process. Please see the sibling bugs and parent bug of this report for details.

I don't know about other patches, but for example there are 3 shortcuts to the getUserName() method. Are you planning to expose non standard authTypes or what?
Comment 10 Steffen Pingel CLA 2007-10-26 00:21:14 EDT
 (In reply to comment #9)
> (In reply to comment #8)
> > > - @deprecated should have some description what to use instead
> > IMHO, the deprecated fields shouldn't have been API in the first place. The
> > alternative is to not use them.
> 
> So, that is what you should put into the deprecation text

Okay.

> I am really surprised with such response. My comments are related to the api
> changes in a scope of the currently *open* bug.

Sorry, I didn't realize IRepositoryConstants exists already. I thought you were suggesting a larger refactoring to extract all default values from TaskRepository. Currently the only default value defined in IRepositoryConstants seems to be the kind whereas other defaults such as time zone or charset are defined in TaskRepository which is the example I followed in the patch. 

> > > - Why the following method are public api? I don't see them used anywhere
> > > outside TaskRepository
> > > getUserName(String authType)
> > > getPassword(String authType)
> > > setCredentials(String authType, String username, String password)
> > The patch is part of a larger set of patches that I split up to ease the
> review
> > process. Please see the sibling bugs and parent bug of this report for
> details.
> 
> I don't know about other patches, but for example there are 3 shortcuts to the
> getUserName() method. Are you planning to expose non standard authTypes or what?

Not sure what you mean. I want to avoid code duplication that is why I added these methods. I would like to remove other methods to retrieve credentials for 3.0.

Comment 11 Eugene Kuleshov CLA 2007-10-26 01:37:36 EDT
(In reply to comment #10)
> Not sure what you mean. I want to avoid code duplication that is why I added
> these methods. I would like to remove other methods to retrieve credentials for
> 3.0.

-1. It is basically issue about arbitrary attributes vs. strongly typed access. While I am usually in a favor of arbitrary attributes, in this case I prefer strongly typed methods, because this stuff is stored into the keyring and it is better to control what user can store in there.
Comment 12 Steffen Pingel CLA 2007-10-26 02:24:32 EDT
Not sure if you understand the new API. It only exposes the key prefix, nothing else.
Comment 13 Eugene Kuleshov CLA 2007-10-26 02:33:25 EDT
(In reply to comment #12)
> Not sure if you understand the new API. It only exposes the key prefix, nothing
> else.

Exactly. It should be exposing Enum and not String-based prefixes, or leave the current methods alone. I'd suggest to keep the current methods, because this change don't bring anything besides pure aestetic, but it will affect integrators.
Comment 14 Steffen Pingel CLA 2007-10-26 03:28:27 EDT
 (In reply to comment #13)
> Exactly. It should be exposing Enum and not String-based prefixes, or leave the
> current methods alone. I'd suggest to keep the current methods, because this
> change don't bring anything besides pure aestetic, but it will affect
> integrators.

The reason I did not choose an enum type is that it can not be extended by integrators and it will keep us from adding new authentication types (e.g. for socks proxies) without breaking backwards compatibility. 

The API is used by TaskRepositoryLocationUi for storing and retrieving credentials using the string prefix which is provided by the caller (connector). If we know for certain that no additional authentication types will be added in the future and that connectors will never require more than the three provided types DEFAULT, HTTP and PROXY I'll consider making the authentication type an enum. 
Comment 15 Eugene Kuleshov CLA 2007-10-26 04:11:06 EDT
(In reply to comment #14)
> The reason I did not choose an enum type is that it can not be extended by
> integrators and it will keep us from adding new authentication types (e.g. for
> socks proxies) without breaking backwards compatibility.

Is there a use case or driver for extending that? socks proxy is a bad example because I don't think that someone would have both socks and http proxy, so that setting is meant to be saved under proxy password for any proxy type.

> The API is used by TaskRepositoryLocationUi for storing and retrieving
> credentials using the string prefix which is provided by the caller (connector).
> If we know for certain that no additional authentication types will be added in
> the future and that connectors will never require more than the three provided
> types DEFAULT, HTTP and PROXY I'll consider making the authentication type an
> enum.

See my previous comment about changing api without new use cases.
Comment 16 Steffen Pingel CLA 2007-10-26 04:23:23 EDT
Another point is that the TaskRepository API is String based, allows access to arbitrary attributes and the new methods are consistent with that. 

Rob, Mik, other opinions about restricing the authentication types to the ones currently supported by using an enum type?
Comment 17 Eugene Kuleshov CLA 2007-10-26 05:02:17 EDT
 (In reply to comment #16)
> Another point is that the TaskRepository API is String based, allows access to
> arbitrary attributes and the new methods are consistent with that.

That api is ok because it is not storing stuff to the keyring.
Comment 18 Steffen Pingel CLA 2007-10-29 22:07:14 EDT
Created attachment 81542 [details]
use enum for make authentication
Comment 19 Steffen Pingel CLA 2007-10-29 22:09:26 EDT
Created attachment 81543 [details]
mylyn/context/zip
Comment 20 Eugene Kuleshov CLA 2007-10-29 22:27:41 EDT
(In reply to comment #18)
> Created an attachment (id=81542)
> use enum for make authentication

Steffen, once again, do you have some use case for which existing api is not sufficient? What is the reason to change it besides pure aestetics?
Comment 21 Steffen Pingel CLA 2007-10-30 01:36:49 EDT
(In reply to comment #20)
> (In reply to comment #18)
> > Created an attachment (id=81542) [details]
> > use enum for make authentication
> 
> Steffen, once again, do you have some use case for which existing api is not
> sufficient? What is the reason to change it besides pure aestetics?

The current API is inconsistent, duplicates code, difficult to extend, has race conditions and not easy to test. My patches reduces the number of methods on TaskRepository significantly, keeps the functionality and addresses the issues mentioned in the previous sentence. See bug 200634 for a use case.
Comment 22 Eugene Kuleshov CLA 2007-10-30 02:15:05 EDT
(In reply to comment #21)
> The current API is inconsistent, duplicates code, difficult to extend, 

I still don't hear about need to extend. However I do see that your changes are about to break support for non-web connectors (including mail and rmi-based connectors) and I think that web credentials should not be part of the TaskRepository api.

> has race conditions and not easy to test

would you please elaborate about the race conditions? also I don't see how changing methods that store stuff into the same place is easier to test. can you please explain?

> My patches reduces the number of methods on TaskRepository significantly, 
> keeps the functionality and addresses the issues mentioned in the previous sentence. 

strangely it feels like number of methods just doubled and I still don't see how racing conditions are addressed

> See bug 200634 for a use case.

Unless I missed something, that bug don't add new auth types, so old methods should be sufficient.
Comment 23 Steffen Pingel CLA 2007-10-30 02:39:54 EDT
 (In reply to comment #22)
> > The current API is inconsistent, duplicates code, difficult to extend,
> 
> I still don't hear about need to extend. 

The API was extended to set a flag wether the password should be stored.

> However I do see that your changes are
> about to break support for non-web connectors (including mail and rmi-based
> connectors) and I think that web credentials should not be part of the
> TaskRepository api.

Credential handling is part of the TaskRepository API. The naming is not perfect but consistent with other classes in the web core plugin. Sharing the credentials classes between the web core plug-in and tasks framework 

> > has race conditions and not easy to test
> 
> would you please elaborate about the race conditions? 

Credentials can not be retrieved as a consistent pair due to getUserName() and getPassword() being two separate methods.

> also I don't see how
> changing methods that store stuff into the same place is easier to test. can you
> please explain?

Instead of duplicating test cases three times for exactly the same logic (storing a username/password) pair the test logic can now be implemented once.

> strangely it feels like number of methods just doubled and I still don't see how
> racing conditions are addressed

I haven't addressed all race conditions in TaskRepository, yet, but that should be done at some point. I added a comment to the methods that I plan to deprecate and then remove.

Eugene, what is the point of this discussion?
Comment 24 Eugene Kuleshov CLA 2007-10-30 03:20:32 EDT
(In reply to comment #23)
> > However I do see that your changes are
> > about to break support for non-web connectors (including mail and rmi-based
> > connectors) and I think that web credentials should not be part of the
> > TaskRepository api.
> 
> Credential handling is part of the TaskRepository API. The naming is not perfect
> but consistent with other classes in the web core plugin. Sharing the
> credentials classes between the web core plug-in and tasks framework

It shouldn't be, because it is specific only to http stuff. So, I'd say turn it other way around - create factory the would make credential instance from the TaskRepository, but don't couple those two together.

> Instead of duplicating test cases three times for exactly the same logic
> (storing a username/password) pair the test logic can now be implemented once.

Can't you just write a selector method in your test case that will encapsulate logic for calling the right metods?

> Eugene, what is the point of this discussion?

I still don't getting the point in these api changes. A smaller api stuff been kicked out in a past... 
Also I do believe that getUserName() is less obscure then getAuthSomething(someEnumType), besides, it is a valid use case to allow to set user an password independent from each other (i.e. set the user name in repo settings and only enter password upon connect).
Comment 25 Steffen Pingel CLA 2007-10-30 03:45:43 EDT
I deem that the API changes proposed in the patches are sensible for reasons outlined in previous comments. I am open to discuss better approaches but I will wait for other opinions before continuing this discussion.

 (In reply to comment #24)
> It shouldn't be, because it is specific only to http stuff. So, I'd say turn it
> other way around - create factory the would make credential instance from the
> TaskRepository, but don't couple those two together.

That sounds like a more generic approach that could be worth investigating. So far I have not seen a need for more than username/password credentials but there could certainly be other use-cases. Please file a bug report and provide more details about the proposed API so we can consider this for 3.0. 

> > Eugene, what is the point of this discussion?
> 
> I still don't getting the point in these api changes. A smaller api stuff been
> kicked out in a past...

Thank you for clarifying. I understand your frustration. What I don't understand is how these endless arguments help the project or you.
Comment 26 Steffen Pingel CLA 2007-10-30 04:41:09 EDT
Created attachment 81553 [details]
use enum for authentication type

The patch uses an enum to determine the authentication type. My assumption that additional enum constants can not be added without breaking binary compatibility was not correct. This can be extended on the framework level in the future but now restricts integrators to the pre-defined authentication types.
Comment 27 Steffen Pingel CLA 2007-10-30 04:41:14 EDT
Created attachment 81554 [details]
mylyn/context/zip
Comment 28 Eugene Kuleshov CLA 2007-10-30 12:32:19 EDT
(In reply to comment #25)
> That sounds like a more generic approach that could be worth investigating. So
> far I have not seen a need for more than username/password credentials but there
> could certainly be other use-cases. Please file a bug report and provide more
> details about the proposed API so we can consider this for 3.0.

The api is already in. Please don't break the use cases that api support.
Comment 29 Mik Kersten CLA 2007-11-01 21:33:20 EDT
(In reply to comment #24)
> I still don't getting the point in these api changes. A smaller api stuff been kicked out in a past...

I understand your frustration with bug 199818, but we have dedicated a large amount of discussion time to figuring that out and its simply not a straightforward change.  I think this one was quite straightforward even though it turned out involved.  Frankly I'm not sure if this feature was important enough but we took it seriously because it is security related.  If there are other places where there were straightforward API changes that should have been applied before this one please email me with them so that I can review our prioritization process.
Comment 30 Eugene Kuleshov CLA 2007-11-02 00:56:01 EDT
Mik, my objection was not to the feature but to the way it been implemented. From the patch I've seen that api changes wasn't needed and functionality could have been implmented on the old api. 

Also please pay some attention about my comment on breaking support of the non http-based connectors.
Comment 31 Steffen Pingel CLA 2007-11-02 01:11:49 EDT
(In reply to comment #30)
> Mik, my objection was not to the feature but to the way it been implemented.
> From the patch I've seen that api changes wasn't needed and functionality could
> have been implmented on the old api. 

Implementing new API early and deprecating old API will give integrators more time to migrate. 

> Also please pay some attention about my comment on breaking support of the non
> http-based connectors.

Could you please post a test case that demonstrates how the new API breaks non-http based connectors?
Comment 32 Steffen Pingel CLA 2007-11-05 14:03:25 EST
Committed slightly modified patch to CVS.
Comment 33 Eugene Kuleshov CLA 2007-11-06 01:26:29 EST
Guys, why no one responded to my concerns about coupling TaskRepository class with web-specific stuff? Namely the WebCredentials class, which is imply something related to "web". I haven't looked at the code in deep details, and at least this credential class is purely named (should have no "web" in it).

Also, while you are on those changes, and actually changing the public api, it would make sense to not stop half way and make auth extendable, for example, take into the account use cases when authorization not need any user name/password, but require a private key to be specified.
Comment 34 Steffen Pingel CLA 2007-11-06 12:59:10 EST
I chose the name WebCredentials to avoid a name clash with the Credentials class that is part of HttpClient and often used in the same classes. Are there any other suggestions for naming that class?

Supporting certificate authentication has certainly come up as a use-case. It is out of scope of this bug report to provide an extensive authentication API and not a priority for 2.2. Still I want to make sure that the changes made to the authentication API are stable and enable extendability for future releases.  Eugene, it would be very helpful if you opened a new bug report and listed your requirements so we can ensure that the current API meet those requirements before it is frozen for 2.2.
Comment 35 Steffen Pingel CLA 2007-11-07 15:15:33 EST
Let's discuss the remaining issues on bug 208935.