001package com.nimbusds.openid.connect.provider.spi;
002
003
004import java.io.InputStream;
005import java.net.URI;
006
007import javax.servlet.ServletContext;
008
009import com.nimbusds.oauth2.sdk.id.Issuer;
010import org.infinispan.manager.EmbeddedCacheManager;
011
012
013/**
014 * Context for the initialisation of SPI implementations.
015 *
016 * <p>Features:
017 *
018 * <ul>
019 *     <li>Provides a method to retrieve a configuration or another file from
020 *         the web application.
021 *     <li>Provides methods to obtain the OpenID Provider issuer identifier and
022 *         token endpoint URI, which may be used to set the accepted audience
023 *         values for SAML 2.0 or JWT bearer grant handlers.
024 *     <li>Provides a service context for accessing selected Connect2id server
025 *         components that may be required in order to process claims or grant
026 *         handler requests.
027 * </ul>
028 */
029public interface InitContext {
030        
031        
032        /**
033         * Returns the servlet context.
034         *
035         * @return The servlet context.
036         */
037        ServletContext getServletContext();
038
039
040        /**
041         * Returns the resource located at the named path as an input stream.
042         * Has the same behaviour as
043         * {@link javax.servlet.ServletContext#getResourceAsStream}.
044         *
045         * @param path The path to the resource, must be begin with a '/' and
046         *             is interpreted as relative to the web application root.
047         *             Must not be {@code null}.
048         *
049         * @return The resource as an input stream, or {@code null} if no
050         *         resource exists at the specified path.
051         */
052        InputStream getResourceAsStream(final String path);
053        
054        
055        /**
056         * Returns the Infinispan cache manager.
057         *
058         * @return The Infinispan cache manager.
059         */
060        EmbeddedCacheManager getInfinispanCacheManager();
061
062
063        /**
064         * Returns the OpenID Provider (OP) issuer identifier. May be used to
065         * set the accepted audience values for SAML 2.0 or JWT bearer grant
066         * handlers.
067         *
068         * @return The OpenID Provider (OP) issuer identifier.
069         */
070        Issuer getOPIssuer();
071
072
073        /**
074         * Returns the token endpoint of the OpenID Provider (OP) /
075         * Authorisation Server (AS). May be used to set the accepted audience
076         * values for SAML 2.0 or JWT bearer grant handlers.
077         *
078         * @return The token endpoint URI.
079         */
080        URI getTokenEndpointURI();
081
082
083        /**
084         * Returns a service context for accessing selected Connect2id server
085         * components that may be required in order to process claims or grant
086         * handler requests. The service context is only available during SPI
087         * request processing. Attempting to use it during SPI
088         * {@link Lifecycle#init ininitialisation} will produce an
089         * {@link IllegalStateException}.
090         *
091         * @return The service context.
092         */
093        ServiceContext getServiceContext();
094}
095