All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nimbusds.openid.connect.provider.spi.ServletInitContext Maven / Gradle / Ivy

Go to download

SDK for Connect2id Server extensions, such as OpenID Connect claims sources and OAuth 2.0 grant handlers

There is a newer version: 5.8
Show newest version
package com.nimbusds.openid.connect.provider.spi;


import jakarta.servlet.ServletContext;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.infinispan.manager.EmbeddedCacheManager;

import java.io.InputStream;
import java.util.Objects;


/**
 * Servlet-based context for the initialisation of SPI implementations.
 */
public abstract class ServletInitContext implements InitContext {


	/**
	 * The servlet context.
	 */
	private final ServletContext servletContext;


	/**
	 * Creates a new servlet-based SPI initialisation context.
	 *
	 * @param servletContext The servlet context. Must not be {@code null}.
	 */
	public ServletInitContext(final ServletContext servletContext) {
		this.servletContext = Objects.requireNonNull(servletContext);
	}


	/**
	 * Returns the servlet context.
	 *
	 * @return The servlet context.
	 */
	public ServletContext getServletContext() {

		return servletContext;
	}


	@Override
	public @Nullable InputStream getResourceAsStream(final String path) {

		return servletContext.getResourceAsStream(path);
	}
	
	
	@Override
	public EmbeddedCacheManager getInfinispanCacheManager() {
		
		// Constant from com.nimbusds.common.servlet.InfinispanLauncher.INFINISPAN_CTX_ATTRIBUTE_NAME
		return (EmbeddedCacheManager) servletContext.getAttribute("org.infinispan.manager.EmbeddedCacheManager");
	}
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy