Package com.nimbusds.common.servlet
Class ResourceRetriever
java.lang.Object
com.nimbusds.common.servlet.ResourceRetriever
Servlet resource retriever. Can be used to retrieve the content of a file as
java.io.InputStream
, String
or java.util.Properties
.-
Method Summary
Modifier and TypeMethodDescriptionstatic Properties
getProperties
(jakarta.servlet.ServletConfig servletConfig, String paramName, org.apache.logging.log4j.Logger logger) Gets thejava.util.Properties
in the specified servletweb.xml
init parameter location.static Properties
getProperties
(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) Gets thejava.util.Properties
in the specified servlet contextweb.xml
init parameter location.static InputStream
getStream
(jakarta.servlet.ServletConfig servletConfig, String paramName, org.apache.logging.log4j.Logger logger) Gets the resource in the specified servletweb.xml
init parameter location.static InputStream
getStream
(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) Gets the resource in the specified servlet contextweb.xml
init parameter location.static String
getString
(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) Gets the resource in the specified servlet contextweb.xml
init parameter location.
-
Method Details
-
getStream
public static InputStream getStream(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) throws Exception Gets the resource in the specified servlet contextweb.xml
init parameter location.- Parameters:
servletCtx
- The servlet context. Must not benull
.paramName
- The name of the servlet context init parameter specifying the resource file (relative to the web app root). For example,/WEB-INF/authService.properties
. Must not benull
.logger
- To log exceptions at ERROR level,null
if none.- Returns:
- The resource as an input stream.
- Throws:
Exception
- On a missing servlet context parameter or a missing resource.
-
getStream
public static InputStream getStream(jakarta.servlet.ServletConfig servletConfig, String paramName, org.apache.logging.log4j.Logger logger) throws Exception Gets the resource in the specified servletweb.xml
init parameter location.- Parameters:
servletConfig
- The servlet configuration. Must not benull
.paramName
- The name of the servlet init parameter specifying the resource file (relative to the web app root). For example,/WEB-INF/authService.properties
. Must not benull
.logger
- To log exceptions at ERROR level,null
if none.- Returns:
- The resource as an input stream.
- Throws:
Exception
- On a missing servlet init parameter or a missing resource.
-
getString
public static String getString(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) throws Exception Gets the resource in the specified servlet contextweb.xml
init parameter location.- Parameters:
servletCtx
- The servlet context. Must not benull
.paramName
- The name of the servlet context init parameter specifying the resource file (relative to the web app root). For example,/WEB-INF/authService.properties
. Must not benull
.logger
- To log exceptions at ERROR level,null
if none.- Returns:
- The resource as a string.
- Throws:
Exception
- On a missing servlet context parameter or a missing resource.
-
getProperties
public static Properties getProperties(jakarta.servlet.ServletContext servletCtx, String paramName, org.apache.logging.log4j.Logger logger) throws Exception Gets thejava.util.Properties
in the specified servlet contextweb.xml
init parameter location.- Parameters:
servletCtx
- The servlet context. Must not benull
.paramName
- The name of the servlet context init parameter specifying the properties file (relative to the web app root). For example,/WEB-INF/authService.properties
. Must not benull
.logger
- To log exceptions at ERROR level,null
if none.- Returns:
- The properties.
- Throws:
Exception
- On a missing servlet context parameter, missing or bad properties file.
-
getProperties
public static Properties getProperties(jakarta.servlet.ServletConfig servletConfig, String paramName, org.apache.logging.log4j.Logger logger) throws Exception Gets thejava.util.Properties
in the specified servletweb.xml
init parameter location.- Parameters:
servletConfig
- The servlet configuration. Must not benull
.paramName
- The name of the servlet init parameter specifying the properties file (relative to the web app root). For example,/WEB-INF/authService.properties
. Must not benull
.logger
- To log exceptions at ERROR level,null
if none.- Returns:
- The properties.
- Throws:
Exception
- On a missing servlet context parameter, missing or bad properties file.
-