public class TLcyNetworkConnectionAddOn extends ALcyPreferencesAddOn
This addon allows to configure settings related to network connections used in Lucy.
By default, the following settings are provided:
ProxySelector
and Authenticator
.com.luciad.lucy.util.TLcyProperties
.
The keys are prefixed by the addon class name.Authenticator
is used to request user credentials (username and password)
in a dialog, when a server is accessed that requires BASIC or DIGEST authentication.
Providing hard-coded credentials for certain servers can be done by overriding getPasswordAuthentication(String, int, String, String, String, InetAddress, URL, Authenticator.RequestorType)
.
Constructor and Description |
---|
TLcyNetworkConnectionAddOn()
Creates the addon using the default preferences.
|
Modifier and Type | Method and Description |
---|---|
protected PasswordAuthentication |
getPasswordAuthentication(String aRequestingHost,
int aRequestingPort,
String aRequestingPrompt,
String aRequestingProtocol,
String aRequestingScheme,
InetAddress aRequestingSite,
URL aRequestingURL,
Authenticator.RequestorType aRequestorType)
The
Authenticator installed by this add-on will delegate to this method from its Authenticator.getPasswordAuthentication()
method. |
void |
plugInto(ILcyLucyEnv aLucyEnv)
Creates and plugs in the add-on's preferences tool.
|
void |
unplugFrom(ILcyLucyEnv aLucyEnv)
Unplugs the add-on's preferences tool.
|
createPreferencesTool, getLongPrefix, getLucyEnv, getPreferences, getPreferencesTool, getShortPrefix
getConfigSourceName, getDisplayName, setConfigSourceName, setDisplayName
public TLcyNetworkConnectionAddOn()
public void plugInto(ILcyLucyEnv aLucyEnv)
ALcyPreferencesAddOn
plugInto
in class ALcyPreferencesAddOn
aLucyEnv
- the Lucy environment to plug intoALcyAddOn.unplugFrom(com.luciad.lucy.ILcyLucyEnv)
public void unplugFrom(ILcyLucyEnv aLucyEnv)
ALcyPreferencesAddOn
unplugFrom
in class ALcyPreferencesAddOn
aLucyEnv
- the Lucy environmentALcyAddOn.plugInto(com.luciad.lucy.ILcyLucyEnv)
protected PasswordAuthentication getPasswordAuthentication(String aRequestingHost, int aRequestingPort, String aRequestingPrompt, String aRequestingProtocol, String aRequestingScheme, InetAddress aRequestingSite, URL aRequestingURL, Authenticator.RequestorType aRequestorType)
Authenticator
installed by this add-on will delegate to this method from its Authenticator.getPasswordAuthentication()
method. The default implementation shows a dialog to the user requesting the user name and password.
Overriding this method allows to provide hardcoded credentials for a certain server,
while keeping the functionality of the dialog intact for other servers.
For example:
@Override
protected PasswordAuthentication getPasswordAuthentication(String aRequestingHost,
int aRequestingPort,
String aRequestingPrompt,
String aRequestingProtocol,
String aRequestingScheme,
InetAddress aRequestingSite,
URL aRequestingURL,
Authenticator.RequestorType aRequestorType ){
if(aRequestorType == RequestorType.SERVER &&
aRequestingHost != null &&
"my_host".equals(aRequestingHost){
//return hardcoded credentials for this specific server
return new PasswordAuthentication("root", new char[]{'r','o','o','t'});
}
//Show the dialog for all other connections
return super.getPasswordAuthentication(aRequestingHost, aRequestingPort, aRequestingPrompt, aRequestingProtocol, aRequestingScheme, aRequestingSite, aRequestingURL, aRequestorType);
}
Note: the Authenticator
installed by this add-on is set as default Authenticator on the whole JVM.
As a result, it is not possible to have 2 Lucy instances running in the same JVM which provide different credentials.
aRequestingHost
- See Authenticator.getRequestingHost()
aRequestingPort
- See Authenticator.getRequestingPort()
aRequestingPrompt
- See Authenticator.getRequestingPrompt()
aRequestingProtocol
- See Authenticator.getRequestingProtocol()
aRequestingScheme
- See Authenticator.getRequestingScheme()
aRequestingSite
- See Authenticator.getRequestingSite()
aRequestingURL
- See Authenticator.getRequestingURL()
aRequestorType
- See Authenticator.getRequestorType()
. Currently this method is not called for Authenticator.RequestorType.PROXY
requests.Authenticator.getPasswordAuthentication()