public class KeyChain
extends java.lang.Object
https://datatracker.ietf.org/doc/html/rfc7617| Constructor and Description |
|---|
KeyChain() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(java.lang.String url,
java.lang.String cookie)
Add a cookie for the URL.
|
java.lang.String |
checkUserInfo(java.net.URL url)
return null or the stored user info.
|
void |
clearAll()
clear all passwords.
|
void |
clearUserPassword(java.net.URI uri) |
void |
clearUserPassword(java.net.URL url)
remove the password from the list of known passwords.
|
protected java.lang.String |
getCookie(java.net.URL url)
Some servers want cookies to handle the authentication.
|
static KeyChain |
getDefault()
get the single instance of the class.
|
static KeyChain |
getInstance(java.lang.String name)
get the instance for this name.
|
java.lang.String |
getUserInfo(java.net.URI uri)
get the user credentials, maybe throwing CancelledOperationException if the
user hits cancel.
|
java.lang.String |
getUserInfo(java.net.URL url)
return the user info (username:password) associated with this URL.
|
java.lang.String |
getUserInfo(java.net.URL url,
java.lang.String userInfo)
get the user credentials, maybe throwing CancelledOperationException if the
user hits cancel.
|
java.lang.String |
getUserInfoBase64Encoded(java.net.URL url)
return the user info but base-64 encoded.
|
java.lang.String |
getWWWAuthenticate(java.net.URL url)
return null or the WWW-Authenticate string.
|
java.lang.String |
hideUserInfo(java.net.URI root) |
static void |
main(java.lang.String[] args) |
java.net.URI |
resolveUserInfo(java.net.URI root)
plug the username and password into the URI.
|
void |
setParentGUI(java.awt.Component c) |
void |
setUserInfo(java.net.URL url,
java.lang.String userInfo)
insert the userInfo into the table of stored passwords.
|
void |
writeKeysFile()
dump the loaded keys into the file new File( FileSystem.settings().getLocalCacheDir(), "keychain.txt" )
|
void |
writeKeysFile(boolean toFile)
format the keys file.
|
public static KeyChain getDefault()
public static KeyChain getInstance(java.lang.String name)
name - public void writeKeysFile()
public void writeKeysFile(boolean toFile)
throws java.io.IOException
toFile - the file should be created.java.io.IOExceptionappendKeysFile(java.lang.String, java.lang.String)public java.lang.String getUserInfo(java.net.URI uri)
throws CancelledOperationException
uri - CancelledOperationExceptiongetUserInfo(java.net.URL)public java.lang.String getUserInfo(java.net.URL url)
throws CancelledOperationException
url - the URLCancelledOperationExceptionwhich will always check and prompt.public java.lang.String checkUserInfo(java.net.URL url)
url - the URLpublic void setUserInfo(java.net.URL url,
java.lang.String userInfo)
url - userInfo - public java.lang.String getUserInfoBase64Encoded(java.net.URL url)
throws CancelledOperationException
connection= theUrl.getConnection();
String encode= KeyChain.getDefault().getUserInfoBase64Encoded( theUrl );
if ( encode!=null ) connection.setRequestProperty("Authorization", "Basic " + encode);
url - the URL which may contain user info.CancelledOperationExceptionpublic void setParentGUI(java.awt.Component c)
public java.lang.String getWWWAuthenticate(java.net.URL url)
url - public java.lang.String getUserInfo(java.net.URL url,
java.lang.String userInfo)
throws CancelledOperationException
url - userInfo - that is available separately. (Java doesn't like user@usersHost:password@server)CancelledOperationExceptionhttps://sourceforge.net/p/autoplot/bugs/1652/public void clearAll()
public void clearUserPassword(java.net.URI uri)
public void clearUserPassword(java.net.URL url)
url - public java.net.URI resolveUserInfo(java.net.URI root)
throws CancelledOperationException
root - the URI, possibly needing a username and password.CancelledOperationExceptionpublic java.lang.String hideUserInfo(java.net.URI root)
public static void main(java.lang.String[] args)
throws java.net.MalformedURLException,
CancelledOperationException
java.net.MalformedURLExceptionCancelledOperationExceptionpublic void addCookie(java.lang.String url,
java.lang.String cookie)
url - cookie - protected java.lang.String getCookie(java.net.URL url)
url -