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