public interface IBrowsers
This allows one to open an URL in a web browser, and install certificates and keys into their certificate stores.
Projects that share some of the goals are BareBonesBrowserLauncher and BrowserLaunch2. These would be good alternatives when no certificate installation is required. This API is heavily inspired by the latter.
Modifier and Type | Method | Description |
---|---|---|
Set<String> |
getBrowserList() |
Returns a list of browser id's to be used for browser targetting.
|
String |
getBrowserName(String browserid) |
Returns the descriptive name of a browser's id.
|
Properties |
getBrowserProperties(String browserid) |
Return a list of Properties for a browser.
|
String |
getDefaultBrowser() |
Returns the default system browser's id.
|
Set<String> |
getKnownBrowserList() |
Returns a list of browser id's that are recognised by the program.
|
void |
initialize() |
Discovers available browsers.
|
void |
installPKCS12(File pkcs) |
Installs a PKCS#12 file into the default browser's keystore.
|
void |
installPKCS12(String browserid,
File pkcs) |
Installs a PKCS#12 file into a browser's keystore.
|
void |
openUrl(String urlString) |
Opens the passed url in the system's default browser.
|
void |
openUrl(String browserid,
String urlString) |
Opens a URL in a specific browser.
|
void |
openUrl(List<String> browserids,
String urlString) |
Opens a URL in one of the supplied browsers.
|
void initialize() throws IOException
IOException
void openUrl(String urlString) throws BrowserNotAvailableException, BrowserExecutionException
urlString
- URL to openBrowserExecutionException
BrowserNotAvailableException
void openUrl(String browserid, String urlString) throws BrowserNotAvailableException, BrowserExecutionException
Allows user to target a specific browser. The id's of
potential browsers can be accessed via the
getBrowserList
method.
If the call to the requested browser fails, the code will
fail over to the default browser. If the browserid argument
is null
, the system's default browser may be called, or a
BrowserNotAvailableException may be thrown, depending on
the implementation.
browserid
- browser identifierurlString
- URL to openBrowserNotAvailableException
BrowserExecutionException
void openUrl(List<String> browserids, String urlString) throws BrowserNotAvailableException, BrowserExecutionException
Allows user to target several browsers. The names of
potential browsers can be accessed via the
getBrowserList
method.
The browsers from the list will be tried in order (first to last) until one of the calls succeeds. If all the calls to the requested browsers fail, the code will fail over to the default browser.
browserids
- List of browser identifiers to tryurlString
- URL to openBrowserNotAvailableException
BrowserExecutionException
Set<String> getBrowserList()
Set<String> getKnownBrowserList()
They may not be all present in the system, use getBrowserList()
for that.
String getDefaultBrowser()
If no default system browser could be found, returns the first browser found. Returns null if no browsers found.
String getBrowserName(String browserid)
This should be used when presenting an option to the user.
void installPKCS12(String browserid, File pkcs) throws BrowserNotAvailableException, BrowserExecutionException
This probably requires user interaction such as entering the keystore's master password, and the PCKS#12 file's passphrase.
browserid
- browser identifier to install certificate forpkcs
- file containing PKCS#12 certificateBrowserNotAvailableException
BrowserExecutionException
void installPKCS12(File pkcs) throws BrowserNotAvailableException, BrowserExecutionException
BrowserNotAvailableException
BrowserExecutionException
installPKCS12(String, File)
Properties getBrowserProperties(String browserid) throws BrowserNotAvailableException
This exposes the browser's Properties
that are used internally.
Please do think twice before using this, because relying on internal
details generally is not wise. It might be useful, however, in certain
cases.
Please realise that this method may vanish in later versions, so be warned.
browserid
- browser identifier to obtain Properties ofBrowserNotAvailableException
Copyright © 2010-2018 Nikhef / Stichting FOM. All Rights Reserved.