001package com.nimbusds.openid.connect.provider.spi; 002 003 004import java.io.InputStream; 005import javax.servlet.ServletContext; 006 007 008/** 009 * Servlet-based context for the initialisation of SPI implementations. 010 */ 011public class ServletInitContext implements InitContext { 012 013 014 /** 015 * The servlet context. 016 */ 017 private final ServletContext servletContext; 018 019 020 /** 021 * Creates a new servlet-based SPI initialisation context. 022 * 023 * @param servletContext The servlet context. Must not be {@code null}. 024 */ 025 public ServletInitContext(final ServletContext servletContext) { 026 027 if (servletContext == null) 028 throw new IllegalArgumentException("The servlet context must not be null"); 029 030 this.servletContext = servletContext; 031 } 032 033 034 /** 035 * Returns the servlet context. 036 * 037 * @return The servlet context. 038 */ 039 public ServletContext getServletContext() { 040 041 return servletContext; 042 } 043 044 045 @Override 046 public InputStream getResourceAsStream(final String path) { 047 048 return servletContext.getResourceAsStream(path); 049 } 050} 051