Class 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
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static void attemptSetAlwaysOnTop​(java.awt.Window win, boolean isOnTop)
      Tries to set the always-on-top property of a window.
      void authorize​(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.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.util.Map securityMap, AuthResourceBundle.Content authContent)
      Returns a "message" object describing the applying client to the user.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • parent_

        private final java.awt.Component parent_
      • logger_

        private static final java.util.logging.Logger logger_
    • Constructor Detail

      • HubSwingClientAuthorizer

        public HubSwingClientAuthorizer​(java.awt.Component parent,
                                        CredentialPresenter presenter)
        Constructor.
        Parameters:
        parent - parent component
        presenter - 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: ClientAuthorizer
        Indicates 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:
        authorize in interface ClientAuthorizer
        Parameters:
        request - incoming HTTP request
        securityMap - 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 the msg argument of one of JOptionPane's methods.
        Parameters:
        request - HTTP request bearing the application
        securityMap - information supplied explicitly by application
        authContent - content of AuthResourceBundle bundle
        Returns:
        message array describing the applicant to the user
        Throws:
        SampExecution - if registration is to be rejected out of hand
        SampException
        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 pairs
        undeclaredWord - 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 set
        isOnTop - true for on top, false for not