org.das2.util.filesystem.KeyChain

class that contains the credentials for websites. This is first introduced so that ftp://papco:@mrfrench.lanl.gov/ and subdirectories would just ask for credentials once. Also, this allows all the sensitive information to be stored in one class. https://datatracker.ietf.org/doc/html/rfc7617 talks about how this should be done. Presently this is done by URL and not the realm. TODO: This needs to be redone so that the keys are stored by realm as well, and once a directory is left a 401 and resending of the realm will be needed before the key is sent again.

KeyChain( )


addCookie

addCookie( String url, String cookie ) → void

Add a cookie for the URL. This was added as a work-around to provide access to the MMS data server at LASP.

Parameters

url - a String
cookie - a String

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


checkUserInfo

checkUserInfo( java.net.URL url ) → String

return null or the stored user info. This allows clients to attempt to use stored user info without bothering the scientist if the info isn't needed.

Parameters

url - the URL

Returns:

the user info (user:password) associated, or null if the user info isn't found.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


clearAll

clearAll( ) → void

clear all passwords.

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


clearUserPassword

clearUserPassword( java.net.URI uri ) → void

Parameters

uri - an URI

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]

clearUserPassword( java.net.URL url ) → void

getDefault

getDefault( ) → KeyChain

get the single instance of the class.

Returns:

the single instance of the class.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getInstance

getInstance( String name ) → KeyChain

get the instance for this name. This is added to support future applications, such as servlets, where multiple users are using the same process.

Parameters

name - a String

Returns:

an org.das2.util.filesystem.KeyChain

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getUserInfo

getUserInfo( java.net.URI uri ) → String

get the user credentials, maybe throwing CancelledOperationException if the user hits cancel.

Parameters

uri - an URI

Returns:

a String

See Also:

getUserInfo(java.net.URL)


[search for examples] [view on GitHub] [view on old javadoc] [view source]

getUserInfo( java.net.URL url ) → String
getUserInfo( java.net.URL url, String userInfo ) → String

getUserInfoBase64Encoded

getUserInfoBase64Encoded( java.net.URL url ) → String

return the user info but base-64 encoded. This is put in so that a future version of the software can cache these as well. This is intended to be inserted like so: connection= theUrl.getConnection(); String encode= KeyChain.getDefault().getUserInfoBase64Encoded( theUrl ); if ( encode!=null ) connection.setRequestProperty("Authorization", "Basic " + encode);

Parameters

url - the URL which may contain user info.

Returns:

the base-64 encoded credentials.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


getWWWAuthenticate

getWWWAuthenticate( java.net.URL url ) → String

return null or the WWW-Authenticate string.

Parameters

url - an URL

Returns:

a String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


hideUserInfo

hideUserInfo( java.net.URI root ) → String

Parameters

root - an URI

Returns:

java.lang.String

[search for examples] [view on GitHub] [view on old javadoc] [view source]


main

main( java.lang.String[] args ) → void

Parameters

args - a java.lang.String[]

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


resolveUserInfo

resolveUserInfo( java.net.URI root ) → URI

plug the username and password into the URI.

Parameters

root - the URI, possibly needing a username and password.

Returns:

the URI with the username and password.

[search for examples] [view on GitHub] [view on old javadoc] [view source]


setParentGUI

setParentGUI( java.awt.Component c ) → void

Parameters

c - a Component

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


setUserInfo

setUserInfo( java.net.URL url, String userInfo ) → void

insert the userInfo into the table of stored passwords. TODO: note the path is not used in the hash, and it should be.

Parameters

url - an URL
userInfo - a String

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]


writeKeysFile

writeKeysFile( ) → void

dump the loaded keys into the file new File( FileSystem.settings().getLocalCacheDir(), "keychain.txt" )

Returns:

void (returns nothing)

[search for examples] [view on GitHub] [view on old javadoc] [view source]

writeKeysFile( boolean toFile ) → void