Provides per-resource login credentials
This class maintains a map of login credentials by resource ID. The resource ID's
themselves are just strings. The only expectation on resource ID strings is that they
should be suitable for use as the Keys to a hash map. Otherwise no formation rules are
assumed nor expected. User names and passwords for multiple web-sites, ftp sites, etc.
are maintained by a single instance of this class. Call:
CredentialsManager.getManager()
to get a reference to that single instance.
In a graphical environment this class handles presenting dialogs to the user to gather
logon credentials. In a shell environment it will interact with the TTY to get user
information.
An example of using this class to handle Das 2.1 server authentication which html
location information formatting follows:
CredentialsManage cm = CrentialsManager.getMannager();
String sLocId = "planet.physics.uiowa.edu/das/das2Server|voyager1/pwi/SpecAnalyzer-4s-Efield";
if(!cm.hasCredentials(sLocId)){
DasServer svr = DasServer.create(sDsdf);
String sDesc = String.Format("
Two previous classes, org.das2.util.filesystem.KeyChain (autoplot) and
org.das2.client.Authenticator have approached this problem as well. However both of
those classes make assumptions that are not valid in general. The first assumes that
the caller somehow knows the username. The second assumes that you are talking to
a first generation Das 2.1 server. Details of server communication are beyond the
scope of this class.%s
Server: %s
DataSource: %s
",
DasServer.getName(), "planet.physics.uiowa.edu",
"voyager1 > pwi > SpecAnalyzer-4s-Efield");
cm.setDescription(sLocId, sDesc, DasServer.getLogo());
}
String sHash = getHttpBasicHash(sLocId)
returns the location of the local directory sandbox. For example, The web filesystem object downloads temporary files to here, logging properties file, etc. Assume that this File is local, so I/O is quick, and that the process has write access to this area. For definition, assume that at least 1Gb of storage is available as well.
Get credentials in the form of a hashed HTTP Basic authentication string If there are no credentials stored for the given location id, this function may trigger interaction with the user, such as presenting modal dialogs, or changing the TTY to non-echo.
Get credentials in the form of a hashed HTTP Basic authentication string. If there are no credentials stored for the given location id, this function may trigger interaction with the user, such as presenting modal dialogs, or changing the TTY to non-echo.
Get a reference to the authentication manager. Typically this is the function you want to use to get started.
support restricted security environment by checking permissions before checking property.
Determine if there are any stored credentials for this location If either a username or a password have been provided for the location then it is considered to have credentials
Determine if a given location has been described Gathering descriptive information about a remote location may trigger communication with a remote site. Use this function to see if such communication is needed.
Determine is a site image has been set for a location ID. This function is provided because retrieving the logo for a site may trigger remote host communication. Use this function to see if such communication is needed.
Let the credentials manager know that stored credentials for a location are invalid
Provide a description of a location for use in authentication dialogs. Use this function to tie a string description to a location id. This description will be used when interacting with the user. If no description is present, then just the location ID itself will be used to identify the site to the end user. Usually location strings aren't that easy to read so use of this function or the version with an icon argument is recommended, though not required.
Allow scripts to set username and password.