Class AbstractGuiseContainer

    • Constructor Summary

      Constructors 
      Constructor Description
      AbstractGuiseContainer​(java.net.URI baseURI)
      Container base URI constructor.
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addGuiseSession​(GuiseSession guiseSession)
      Adds and initializes a Guise session.
      java.util.Collection<GuiseApplication> getApplications()  
      com.globalmentor.net.URIPath getBasePath()
      Reports the base path of the container.
      java.net.URI getBaseURI()
      Reports the base URI of the container.
      java.io.InputStream getInputStream​(java.net.URI uri)
      Retrieves an input stream to the entity at the given URI.
      protected char[] getPassword​(AbstractGuiseApplication application, java.security.Principal principal)
      Looks up the corresponding password for the given principal.
      protected java.security.Principal getPrincipal​(AbstractGuiseApplication application, java.lang.String id)
      Looks up an application principal from the given ID.
      protected java.lang.String getRealm​(AbstractGuiseApplication application, java.net.URI resourceURI)
      Determines the realm applicable for the resource indicated by the given URI.
      protected abstract java.io.InputStream getResourceInputStream​(java.lang.String resourcePath)
      Retrieves an input stream to the resource at the given path.
      protected abstract boolean hasResource​(java.lang.String resourcePath)
      Determines if the application has a resource available stored at the given resource path.
      protected void installApplication​(AbstractGuiseApplication application, java.net.URI baseURI, java.io.File homeDirectory, java.io.File logDirectory, java.io.File tempDirectory)
      Installs the given application at the given base path.
      protected boolean isAuthorized​(AbstractGuiseApplication application, java.net.URI resourceURI, java.security.Principal principal, java.lang.String realm)
      Checks whether the given principal is authorized to access the resource at the given application path.
      protected void removeGuiseSession​(GuiseSession guiseSession)
      Removes and destroys a Guise session.
      com.globalmentor.net.URIPath resolvePath​(com.globalmentor.net.URIPath path)
      Resolves a relative or absolute path against the container base path.
      java.net.URI resolveURI​(java.net.URI uri)
      Resolves URI against the container base path.
      protected void uninstallApplication​(AbstractGuiseApplication application)
      Uninstalls the given application.
      • Methods inherited from class java.lang.Object

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

      • AbstractGuiseContainer

        public AbstractGuiseContainer​(java.net.URI baseURI)
        Container base URI constructor.
        Parameters:
        baseURI - The base URI of the container, an absolute URI that ends with the base path, which ends with a slash ('/'), indicating the base path of the application base paths.
        Throws:
        java.lang.NullPointerException - if the base URI is null.
        java.lang.IllegalArgumentException - if the base URI is not absolute or does not end with a slash ('/') character.
    • Method Detail

      • getBaseURI

        public java.net.URI getBaseURI()
        Description copied from interface: GuiseContainer
        Reports the base URI of the container. The base URI is an absolute URI that ends with the base path, which ends with a slash ('/').
        Specified by:
        getBaseURI in interface GuiseContainer
        Returns:
        The base URI representing the Guise container.
      • getBasePath

        public com.globalmentor.net.URIPath getBasePath()
        Description copied from interface: GuiseContainer
        Reports the base path of the container. The base path is an absolute path that ends with a slash ('/'), indicating the base path of the application base paths.
        Specified by:
        getBasePath in interface GuiseContainer
        Returns:
        The base path representing the Guise container.
      • addGuiseSession

        protected void addGuiseSession​(GuiseSession guiseSession)
        Adds and initializes a Guise session. This version creates a thread group for the session. The Guise session will be registered with the Guise application before it is initialized. Initialization will occur inside the appropriate session thread group.
        Parameters:
        guiseSession - The Guise session to add.
        See Also:
        GuiseApplication.registerSession(GuiseSession), GuiseSession.initialize()
      • removeGuiseSession

        protected void removeGuiseSession​(GuiseSession guiseSession)
        Removes and destroys a Guise session. The Guise session will be unregistered from the Guise application after it is uninitialized. Destruction will occur inside the appropriate session thread group.
        Parameters:
        guiseSession - The Guise session to remove.
        See Also:
        GuiseSession.destroy(), GuiseApplication.unregisterSession(GuiseSession)
      • installApplication

        protected void installApplication​(AbstractGuiseApplication application,
                                          java.net.URI baseURI,
                                          java.io.File homeDirectory,
                                          java.io.File logDirectory,
                                          java.io.File tempDirectory)
                                   throws java.io.IOException
        Installs the given application at the given base path. If no theme is specified, the default theme will be loaded. This version ensures the home, log, and temp directories exist.
        Parameters:
        application - The application to install.
        baseURI - The base URI at which the application is being installed.
        homeDirectory - The home directory of the application.
        logDirectory - The log directory of the application.
        tempDirectory - The temporary directory of the application.
        Throws:
        java.lang.NullPointerException - if the application, base URI, home directory, log directory, and/or temporary directory is null.
        java.lang.IllegalArgumentException - if the given base URI is not absolute or the path of which is not absolute or not a collection.
        java.lang.IllegalStateException - if the application is already installed in some container.
        java.lang.IllegalStateException - if there is already an application installed in this container at the given base path.
        java.io.IOException - if there is an I/O error when installing the application.
      • uninstallApplication

        protected void uninstallApplication​(AbstractGuiseApplication application)
        Uninstalls the given application.
        Parameters:
        application - The application to uninstall.
        Throws:
        java.lang.NullPointerException - if the application is null.
        java.lang.IllegalStateException - if the application is not installed in this container.
      • resolvePath

        public com.globalmentor.net.URIPath resolvePath​(com.globalmentor.net.URIPath path)
        Description copied from interface: GuiseContainer
        Resolves a relative or absolute path against the container base path. Relative paths will be resolved relative to the container base path. Absolute paths will be be considered already resolved. For a container base path "/path/to/container/", resolving "relative/path" will yield "/path/to/container/relative/path", while resolving "/absolute/path" will yield "/absolute/path".
        Specified by:
        resolvePath in interface GuiseContainer
        Parameters:
        path - The path to be resolved.
        Returns:
        The path resolved against the container base path.
        See Also:
        GuiseContainer.getBasePath()
      • resolveURI

        public java.net.URI resolveURI​(java.net.URI uri)
        Description copied from interface: GuiseContainer
        Resolves URI against the container base path. Relative paths will be resolved relative to the container base path. Absolute paths will be considered already resolved, as will absolute URIs. For a container base path "/path/to/container/", resolving "relative/path" will yield "/path/to/container/relative/path", while resolving "/absolute/path" will yield "/absolute/path". Resolving "http://example.com/path" will yield "http://example.com/path".
        Specified by:
        resolveURI in interface GuiseContainer
        Parameters:
        uri - The URI to be resolved.
        Returns:
        The URI resolved against the container base path.
        See Also:
        GuiseContainer.getBasePath()
      • hasResource

        protected abstract boolean hasResource​(java.lang.String resourcePath)
        Determines if the application has a resource available stored at the given resource path. The provided path is first normalized.
        Parameters:
        resourcePath - A container-relative path to a resource in the resource storage area.
        Returns:
        true if a resource exists at the given resource path.
        Throws:
        java.lang.IllegalArgumentException - if the given resource path is absolute.
        java.lang.IllegalArgumentException - if the given path is not a valid path.
      • getResourceInputStream

        protected abstract java.io.InputStream getResourceInputStream​(java.lang.String resourcePath)
        Retrieves an input stream to the resource at the given path. The provided path is first normalized.
        Parameters:
        resourcePath - A container-relative path to a resource in the resource storage area.
        Returns:
        An input stream to the resource at the given resource path, or null if no resource exists at the given resource path.
        Throws:
        java.lang.IllegalArgumentException - if the given resource path is absolute.
        java.lang.IllegalArgumentException - if the given path is not a valid path.
      • getInputStream

        public java.io.InputStream getInputStream​(java.net.URI uri)
                                           throws java.io.IOException
        Retrieves an input stream to the entity at the given URI. The URI is first resolved to the container base URI.
        Specified by:
        getInputStream in interface GuiseContainer
        Parameters:
        uri - A URI to the entity; either absolute or relative to the container.
        Returns:
        An input stream to the entity at the given resource URI, or null if no entity exists at the given resource path.
        Throws:
        java.lang.NullPointerException - if the given URI is null.
        java.io.IOException - if there was an error connecting to the entity at the given URI.
        See Also:
        getBaseURI()
      • getPrincipal

        protected java.security.Principal getPrincipal​(AbstractGuiseApplication application,
                                                       java.lang.String id)
        Looks up an application principal from the given ID. This version delegates to the given Guise application.
        Parameters:
        application - The application for which a principal should be returned for the given ID.
        id - The ID of the principal.
        Returns:
        The principal corresponding to the given ID, or null if no principal could be determined.
      • getPassword

        protected char[] getPassword​(AbstractGuiseApplication application,
                                     java.security.Principal principal)
        Looks up the corresponding password for the given principal. This version delegates to the given Guise application.
        Parameters:
        application - The application for which a password should e retrieved for the given principal.
        principal - The principal for which a password should be returned.
        Returns:
        The password associated with the given principal, or null if no password is associated with the given principal.
      • getRealm

        protected java.lang.String getRealm​(AbstractGuiseApplication application,
                                            java.net.URI resourceURI)
        Determines the realm applicable for the resource indicated by the given URI. This version delegates to the given Guise application.
        Parameters:
        application - The application for which a realm should be returned for the given resource URI.
        resourceURI - The URI of the resource requested.
        Returns:
        The realm appropriate for the resource, or null if the given resource is not in a known realm.
        See Also:
        GuiseApplication.relativizeURI(URI)
      • isAuthorized

        protected boolean isAuthorized​(AbstractGuiseApplication application,
                                       java.net.URI resourceURI,
                                       java.security.Principal principal,
                                       java.lang.String realm)
        Checks whether the given principal is authorized to access the resource at the given application path. This version delegates to the given Guise application.
        Parameters:
        application - The application for which a principal should be authorized for a given resource URI.
        resourceURI - The URI of the resource requested.
        principal - The principal requesting authentication, or null if the principal is not known.
        realm - The realm with which the resource is associated, or null if the realm is not known.
        Returns:
        true if the given principal is authorized to access the resource represented by the given resource URI.