public class HubSwingClientAuthorizer extends java.lang.Object implements ClientAuthorizer
Modifier and Type | Field and Description |
---|---|
private static java.util.logging.Logger |
logger_ |
private static int |
MAX_POPUP_WIDTH |
private java.awt.Component |
parent_ |
Constructor and Description |
---|
HubSwingClientAuthorizer(java.awt.Component parent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private static void |
attemptSetAlwaysOnTop(java.awt.Window win,
boolean isOnTop)
Tries to set the always-on-top property of a window.
|
boolean |
authorize(HttpServer.Request request,
java.lang.String appName)
Indicates whether an HTTP request representing an otherwise
unauthorized connection attempt will be permitted access to
sensitive system resources.
|
private javax.swing.JComponent |
createLabelledFields(java.util.Map infoMap,
java.lang.String undeclaredWord)
Returns a component displaying name/value pairs represented by
a given String->String map.
|
private java.lang.Object[] |
getMessageLines(HttpServer.Request request,
java.lang.String appName,
AuthResourceBundle.Content authContent)
Returns a "message" object describing the applying client to the user.
|
private java.lang.String |
getOrigin(java.lang.String uri)
Returns the serialized origin for a given URI string.
|
private static java.util.List |
toLineList(java.lang.String linesTxt)
Turns a multi-line string into a List of strings.
|
private static java.lang.String[] |
toLines(java.lang.String linesTxt)
Turns a multi-line string into an array of strings.
|
private final java.awt.Component parent_
private static final int MAX_POPUP_WIDTH
private static final java.util.logging.Logger logger_
public HubSwingClientAuthorizer(java.awt.Component parent)
parent
- parent componentpublic boolean authorize(HttpServer.Request request, java.lang.String appName)
ClientAuthorizer
appName
parameter by way of additional information about
its identity. However, the value of this name is supplied by the
(potentially malicious) applicant, so cannot in itself be regarded
as an additional security measure.authorize
in interface ClientAuthorizer
request
- incoming HTTP requestappName
- name by which the application submitting the request
wishes to be knownprivate java.lang.Object[] getMessageLines(HttpServer.Request request, java.lang.String appName, AuthResourceBundle.Content authContent)
msg
argument
of one of JOptionPane
's methods.request
- HTTP request bearing the applicationappName
- application name claimed by the applicantauthContent
- content of AuthResourceBundle bundleJOptionPane
private javax.swing.JComponent createLabelledFields(java.util.Map infoMap, java.lang.String undeclaredWord)
infoMap
- String->String map of key->value pairsundeclaredWord
- text to use to indicate a null valueprivate java.lang.String getOrigin(java.lang.String uri)
uri
- URIuri
,
null
(note: not "null") if it cannot be determinedprivate static java.lang.String[] toLines(java.lang.String linesTxt)
linesTxt
- string perhaps with embedded \n charactersprivate static java.util.List toLineList(java.lang.String linesTxt)
linesTxt
- string perhaps with embedded \n charactersprivate static void attemptSetAlwaysOnTop(java.awt.Window win, boolean isOnTop)
win
- window to setisOnTop
- true for on top, false for not