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