This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Adding a Proxy user in VW
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
One of the things you have to deal with when building an HTTP aware application is proxy user settings. VW has a settings tool within the environment for setting and managing proxy settings - the trouble is, it's not necessarily set up for simple reuse within a free standing application. Fortunately, it's not terribly difficult to set up programmatically (building a simple UI to go with this code is left as an exercise for the reader). First off, you need to define a network user:
user := NetUser new.
user fullName: 'First Last'.
user username: 'username'.
user password: 'password'.
user savePassword: true.
Now that you have a user, you'll need to actually add that user to the system registry. If your application is single user, you can go ahead and make that user the default user. If it's not single user, you'll need a way to switch users, and just toggle which one is the default. Here's how to set a user up as the default user:
Now you've got a user defined, and registered with the system. But what about setting the proxy server, and enabling proxy usage? Here's how you define a proxy server and hand it the appropriate user:
That will set your application up to use a proxy server, with the appropriate user. To disable proxy usage without getting rid of the settings, all you need to do is toggle the httpUseProxy setting. That's pretty much it; it's not hard to do. This code is what BottomFeeder uses to set up proxy services.