Package org.astrogrid.samp.web
Class HubSwingClientAuthorizer
- java.lang.Object
-
- org.astrogrid.samp.web.HubSwingClientAuthorizer
-
- All Implemented Interfaces:
ClientAuthorizer
public class HubSwingClientAuthorizer extends java.lang.Object implements ClientAuthorizer
ClientAuthorizer implementation that queries the user for permission via a popup dialogue.- Since:
- 2 Feb 2011
- Author:
- Mark Taylor
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerlogger_private static intMAX_POPUP_WIDTHprivate java.awt.Componentparent_private CredentialPresenterpresenter_
-
Constructor Summary
Constructors Constructor Description HubSwingClientAuthorizer(java.awt.Component parent, CredentialPresenter presenter)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidattemptSetAlwaysOnTop(java.awt.Window win, boolean isOnTop)Tries to set the always-on-top property of a window.voidauthorize(HttpServer.Request request, java.util.Map securityMap)Indicates whether an HTTP request representing an otherwise unauthorized connection attempt will be permitted access to sensitive system resources.private javax.swing.JComponentcreateLabelledFields(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.util.Map securityMap, AuthResourceBundle.Content authContent)Returns a "message" object describing the applying client to the user.private static java.util.ListtoLineList(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.
-
-
-
Field Detail
-
parent_
private final java.awt.Component parent_
-
presenter_
private final CredentialPresenter presenter_
-
MAX_POPUP_WIDTH
private static final int MAX_POPUP_WIDTH
- See Also:
- Constant Field Values
-
logger_
private static final java.util.logging.Logger logger_
-
-
Constructor Detail
-
HubSwingClientAuthorizer
public HubSwingClientAuthorizer(java.awt.Component parent, CredentialPresenter presenter)Constructor.- Parameters:
parent- parent componentpresenter- handles credential presentation to the user
-
-
Method Detail
-
authorize
public void authorize(HttpServer.Request request, java.util.Map securityMap) throws SampException
Description copied from interface:ClientAuthorizerIndicates whether an HTTP request representing an otherwise unauthorized connection attempt will be permitted access to sensitive system resources. If so, the method exits normally. If authorization is denied, a SampException is thrown, with a message that indicates the reason for denial.- Specified by:
authorizein interfaceClientAuthorizer- Parameters:
request- incoming HTTP requestsecurityMap- credential items supplied explicitly by aspiring client to support its registration request- Throws:
SampException- with reason if authorization is denied
-
getMessageLines
private java.lang.Object[] getMessageLines(HttpServer.Request request, java.util.Map securityMap, AuthResourceBundle.Content authContent) throws SampException
Returns a "message" object describing the applying client to the user. The return value is suitable for use as themsgargument of one ofJOptionPane's methods.- Parameters:
request- HTTP request bearing the applicationsecurityMap- information supplied explicitly by applicationauthContent- content of AuthResourceBundle bundle- Returns:
- message array describing the applicant to the user
- Throws:
SampExecution- if registration is to be rejected out of handSampException- See Also:
JOptionPane
-
createLabelledFields
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.- Parameters:
infoMap- String->String map of key->value pairsundeclaredWord- text to use to indicate a null value- Returns:
- display component
-
toLines
private static java.lang.String[] toLines(java.lang.String linesTxt)
Turns a multi-line string into an array of strings.- Parameters:
linesTxt- string perhaps with embedded \n characters- Returns:
- array of lines
-
toLineList
private static java.util.List toLineList(java.lang.String linesTxt)
Turns a multi-line string into a List of strings.- Parameters:
linesTxt- string perhaps with embedded \n characters- Returns:
- list of String lines
-
attemptSetAlwaysOnTop
private static void attemptSetAlwaysOnTop(java.awt.Window win, boolean isOnTop)Tries to set the always-on-top property of a window. This is only possible in JRE1.5 and later, so it's done here by reflection. If it fails, a logging message is emitted.- Parameters:
win- window to setisOnTop- true for on top, false for not
-
-