eclipse / ecf

ECF project repository
7 stars 14 forks source link

Adding Preferences for Request Header #105

Closed JavaJoeS closed 5 months ago

JavaJoeS commented 5 months ago

This modification will allow subsequent Request header values to be set. An example might be to access LDAP. In a customized corporate environment where PKI is used, the UrlConnection provider gets activated to check if there is an LDAP. The first param is the name of the domain that is looked at, the second is the method in the LDAP that is checked. The default in a non customized env the code is unused.

eclipse-ecf-bot commented 5 months ago

Can one of the admins verify this patch?

scottslewis commented 5 months ago

Hi @JavaJoeS. First thanks for this contribution. I'm curious about what the use case is for this addition. Also, currently Eclipse does not use the UrlConnection provider (rather it uses the JRE httpclient provider), and I noticed that your addition was only to the UrlConnection provider...is that intentional?

Another question: As parts of ECF filetransfer are used by consumers that are not eclipse, the use/dependency of Eclipse preferences page classes may need to be moved to another plugin.

In any event, let's start with discussing the use case that's driving this addition (e.g. is it intended for p2/Eclipse or for some other use case of your own).

JavaJoeS commented 5 months ago

@scottslewis I have additional code changes that I would like to add, including to the JRE http client. My initial PR is a start, simple, non intrusive, but a valid preference, that would be used in an LDAP environment using PKI. Have a look see at my PKI solution that can be found in marketplace, search PKI. Ultimately my changes will provide an SSLContext so that connections can be https authenticated by either client,server, or client.server. So far my PKI marketplace App works like a champ! Please approve my workflow so I can champion a win. THank you very much for any help.

JavaJoeS commented 5 months ago

@eclipse-ecf-bot Please approve..

JavaJoeS commented 5 months ago

@scottslewis @alblue @lemmy Hi Folks, I will close this PR, and pull a new one with more meaningful updates. Thank you very much for looking.

scottslewis commented 5 months ago

Hi @JavaJoeS.

After some refreshing of my memory I've realized that the ECF filetransfer API already has support for adding custom request headers.

In this entry point method:

org.eclipse.ecf.provider.filetransfer.retrieve.AbstractRetrieveFileTransfer.sendRetrieveRequest(IFileID, IFileTransferListener, Map)

The final parameter (optional) is a Map. If this map has the key org.eclipse.ecf.filetransfer.IRetrieveFileTransferOptions.REQUEST_HEADERS and a Map<String,String> value for that key, then all of the name->value pairs in the map will be added to the request before it is sent.

For the URLConnection provider, the method org.eclipse.ecf.provider.filetransfer.retrieve.UrlConnectionRetrieveFileTransfer.setRequestHeaderValues() calls the method org.eclipse.ecf.provider.filetransfer.retrieve.UrlConnectionRetrieveFileTransfer.setRequestHeaderValuesFromOptions() and this method adds all of the name value pairs from the REQUEST_HEADERS map.

Other providers (e.g. the javahttpclient provider used now by Eclipse) also has similar setRequestHeaderValues() and setRequestHeaderValuesFromOptions methods.

I'm not clear on whether your PKS plugin uses the ECF filetransfer API directly or if you were intending that p2/Eclipse would just inherit these headers via your class changes (and preferences addition). Since ECF isn't currently responsible for any Eclipse preferences it may be better to move the preferences to some existing category rather than introduce two new ones for ECF, but this can be discussed. The two preferences that you've defined in your pr...would it make sense to combine those with any of the other Eclipse preferences?

JavaJoeS commented 5 months ago

@scottslewis I looked at the code you referenced and you are spot on. No need for the PR im suggesting. I will close it out. However, I do wanna make some mods to support my PKI plugin. I do want ECF and all of p2/Eclipse to be able to use my PKI plugin. I think I can do it very overtly by add optional plugin and a single line of java code strategically placed!