commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mario Ivankovits <ma...@ops.co.at>
Subject Re: [vfs] providing smb credentials somewhere other than the URI
Date Mon, 06 Jun 2005 14:14:56 GMT
Philippe Poulard wrote:
> what about using attributes as we talk in another post ?
>
> moreover, user/pwd are attributes which name should be normalized
> Map map = new HashMap();
> // 2 attributes that are consumed by VFS
> map.put( "org.apache.commons.vfs.User", user );
> map.put( "org.apache.commons.vfs.Password", password );
> // 1 attribute consumed by the XML:DB scheme
> map.put( "org.apache.commons.vfs.provider.xmldb.ResourceType", 
> "XMLResource" );
> // 1 attribute consumed by the XML:DB provider
> map.put( "org.foo.xmldbdriver.Cluster", "myCluster" );
>
> then create the file as you suggested previously :
> FileObject.createFile( map );
username/password aren't file level attributes. A server might present 
you a different set of files depending on the user you used for "login".
We already have a logic to pass down such filesystem attributes using 
the *ConfigBuilder classes.
They provide type-safety and in-code documentation of all possible 
options depending on the scheme e.g. HttpFileSystemConfigBuilder

BTW I dont like the idea of having just key/value pairs of strings where 
no one knows which keys are possible and what the value means.

The configBuilder accepts an instance of FileSystemOptions where these 
options are stored then.

FileSystemOptions opts = new FileSystemOptions();
HttpFileSystemConfigBuilder.getInstance().setProxyHost(opts, "proxy");
FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);

FileObject fo = VFS.getInstance().resolveFile("any/file", opts);

Depending on which FileProvider is needet during resolveFile the 
Filesystem will pick its configuration ...
> just a problem to solve : how to deal with a scheme that may contain 
> itself as a scheme, if attributes are used, which one is the target ?
> foo:foo:///path/to/file!/path/to/file
... see above.

To just processs strings of key/value entries, say to configure a 
filesystem in an ant task one can use the 
DelegatingFileSystemOptionsBuilder e.g.
delegate.setConfigString(fso, "http", "proxyPort", "8080");

Reflection will be used to check if the parameters are valid. So we have 
a fail-fast on configuration errors.


Ciao,
Mario


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message