public class CredentialsManager
extends java.lang.Object
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("%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)
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.Modifier and Type | Class and Description |
---|---|
protected static class |
CredentialsManager.Location |
Modifier | Constructor and Description |
---|---|
protected |
CredentialsManager(java.lang.String sName) |
Modifier and Type | Method and Description |
---|---|
protected boolean |
getCredentialsCmdLine(CredentialsManager.Location loc)
get the credentials from the command line.
|
protected boolean |
getCredentialsGUI(CredentialsManager.Location loc)
Gather User Credentials
|
static java.io.File |
getDas2UserDirectory()
returns the location of the local directory sandbox.
|
java.lang.String |
getHttpBasicHash(java.lang.String sLocationId)
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.
|
java.lang.String |
getHttpBasicHashRaw(java.lang.String sLocationId)
Get credentials in the form of a hashed HTTP Basic authentication string.
|
static CredentialsManager |
getMannager()
Get a reference to the authentication manager.
|
static CredentialsManager |
getMannager(java.lang.String sWhich)
Get an authentication manager associated with an associated tracking string.
|
static java.lang.String |
getProperty(java.lang.String name,
java.lang.String deft)
support restricted security environment by checking permissions before
checking property.
|
boolean |
hasCredentials(java.lang.String sLocationId)
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
|
boolean |
hasDescription(java.lang.String sLocationId)
Determine if a given location has been described
Gathering descriptive information about a remote location may trigger communication
with a remote site.
|
boolean |
hasIcon(java.lang.String sLocationId)
Determine is a site image has been set for a location ID.
|
void |
invalidate(java.lang.String sLocationId)
Let the credentials manager know that stored credentials for a location are invalid
|
void |
setDescription(java.lang.String sLocationId,
java.lang.String sDescription)
Provide a description of a location for use in authentication dialogs.
|
void |
setDescription(java.lang.String sLocationId,
java.lang.String sDescription,
javax.swing.ImageIcon icon)
Provide a description of a location with an Image Icon
Use this function to tie a string description and an Icon to a location.
|
void |
setHttpBasicHashRaw(java.lang.String sLocationId,
java.lang.String userInfo)
Allow scripts to set username and password.
|
public static CredentialsManager getMannager()
public static CredentialsManager getMannager(java.lang.String sWhich)
sWhich
- - A string used to differentiate this credentials manager from the
default instance.public void setDescription(java.lang.String sLocationId, java.lang.String sDescription)
sLocationId
- The location to describe, can not be null.sDescription
- A string to present to a user when prompting for a credentials
for this location, may be a basic HTML string.public void setDescription(java.lang.String sLocationId, java.lang.String sDescription, javax.swing.ImageIcon icon)
sLocationId
- The location to describe, can not be null.sDescription
- The description, may be a simply formatted HTML string.icon
- An icon to display for the server.public boolean hasCredentials(java.lang.String sLocationId)
sLocationId
- The location to describe, can not be null.public void setHttpBasicHashRaw(java.lang.String sLocationId, java.lang.String userInfo)
sLocationId
- the location/realm, like "http://jupiter.physics.uiowa.edu/das/server|Juno Magnetospheric Working Group"userInfo
- the user pass in string like "usern:passw"public boolean hasDescription(java.lang.String sLocationId)
sLocationId
- The location in questionpublic boolean hasIcon(java.lang.String sLocationId)
sLocationId
- the location in questionpublic java.lang.String getHttpBasicHash(java.lang.String sLocationId)
sLocationId
- A unique string identifying a location. There are no formation
rules on the string, but convenience functions are provided if a uniform naming
convention is desired.getHttpBasicHashRaw(java.lang.String)
public java.lang.String getHttpBasicHashRaw(java.lang.String sLocationId)
sLocationId
- A unique string identifying a location. There are no formation
rules on the string, but convenience functions are provided if a uniform naming
convention is desired.getHttpBasicHash(java.lang.String)
public void invalidate(java.lang.String sLocationId)
sLocationId
- public static java.lang.String getProperty(java.lang.String name, java.lang.String deft)
name
- deft
- !
public static java.io.File getDas2UserDirectory()
!
protected boolean getCredentialsGUI(CredentialsManager.Location loc)
loc
- The Location in questionprotected boolean getCredentialsCmdLine(CredentialsManager.Location loc)
loc
-