public class HttpUtil extends BaseHttpUtil
HttpUtil
provides a set of useful static methods.
Many of the methods are for use by JSP pages or servlets that run in a servlet container to perform operations related to HTTP Requests. These are easy to distinguish because they require an HTTPServletRequest parameter.
Other methods can be used in any environment.
In particular, the initEnv() and getHttpRptServer() are important and useful
methods that can be used by code running in any environment.
CONTENT_LOCATION, PROP_OUTPUT_ENCODING
Modifier and Type | Method and Description |
---|---|
static void |
bindHttpRptServer(HttpRptServer server,
java.lang.String dispatchId)
Bind the HttpRptServer to the specified dispatchId.
|
static boolean |
checkAdminLogin(javax.servlet.http.HttpServletRequest req)
Performs an authentication check for the current HTTP Request looking for an admin user.
|
static boolean |
checkAdminLogin(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Performs an authentication check for the current HTTP Request looking for an admin user.
|
static boolean |
checkAdminLoginEx(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
static boolean |
checkLogin(javax.servlet.http.HttpServletRequest req)
Performs an authentication check for the current HTTP Request.
|
static boolean |
checkLogin(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Performs an authentication check for the current HTTP Request.
|
static boolean |
checkLoginEx(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res) |
static boolean |
checkPermission(javax.servlet.http.HttpServletRequest req)
Tests whether the JReport user logged into the current session is
authorized to perform the requested action against the target resource
which is indicated in the HTTP Request.
|
static void |
copyFilesByPrefix(java.lang.String srcDir,
java.lang.String srcPrefix,
java.lang.String destDir,
java.lang.String destPrefix)
Copies files from a directory to another directory.
|
static HttpRptServer |
dispatchHttpRptServer(javax.servlet.http.HttpServletRequest request)
Dispatch and return a HttpRptServer object by HttpRequest according dispatch implement algorithm(round-Robin).
|
static java.lang.String |
filterXSS(java.lang.String oldVal)
Filters html content to prevent Cross Site Scripting (XSS) vulnerability.
|
static boolean |
getAdHoc()
Gets if AdHoc feature is enabled.
|
static java.lang.String |
getAdhocJspPath()
Gets adhoc jsp path.
|
static java.lang.String |
getAdhocServletPath()
Gets adhoc servlet path.
|
static java.lang.String |
getAuthScheme()
Gets the scheme of authentication initialed by initEnv(..).
|
static long |
getAutoRecoverTaskInterval()
Gets retry interval for auto recovering failed scheduled tasks.
|
static int |
getAutoRecoverTaskMaxTimes()
Gets maximum retry times for auto recovering failed scheduled tasks.
|
static boolean |
getAutoRecoverTaskRedoAll()
Checks whether to recreate all results for auto recovering failed scheduled tasks.
|
static java.lang.String |
getBase(javax.servlet.http.HttpServletRequest req,
boolean convertEscapeForServletPath)
Gets the path of HttpServletRequest, including the servlet path.
|
static java.lang.String |
getBaseNoPath(javax.servlet.http.HttpServletRequest req,
boolean convertEscapeForServletPath)
Gets the servlet path.
|
static HttpRptServer |
getBindedHttpRptServer(java.lang.String dispatchId)
Gets the HttpRptServer which binded to the specified dispatchId.
|
static java.lang.String |
getDefaultDoc()
Gets the home page of JReport Server initialed by initEnv(..).
|
static java.lang.String |
getHostAddress(java.lang.String hostName)
Gets the host address by host name.
|
static HttpRptServer |
getHttpRptServer()
Gets the HttpRptServer object created by initEnv(...).
|
static HttpRptServer |
getHttpRptServer(javax.servlet.http.HttpServletRequest request)
Gets the HttpRptServer object by HTTP Request according RemoteDispatch implement (session-level dispatch).
|
static HttpRptServer |
getHttpRptServer(javax.servlet.http.HttpServletRequest request,
int clusterMemberId)
If system is cluster-enabled and clusterMemberId is exist in the active cluster nodes, return the node of specified by clusterMemberId,
otherwise return
getHttpRptServer(HttpServletRequest) |
static java.lang.String |
getHttpURL()
Gets the current Http prefix.
|
static java.lang.String |
getInternalBuildLable()
Gets internal build lable of the server.
|
static java.lang.String |
getJRServletPath()
Gets the JReport servlet path.
|
static java.lang.String |
getJspUri(javax.servlet.http.HttpServletRequest request,
java.lang.String jspPath)
Gets the url of the jsp by jsp path.
|
static java.lang.String |
getJSPWebAppName(java.lang.String propname)
Gets jsp webapp name from bin\server.properties.
|
static java.util.List |
getLanguageList()
Gets the supported languages list.
|
static java.lang.String |
getLogInfoAfterService(javax.servlet.ServletRequest _req,
javax.servlet.ServletResponse _res)
Gets the debug information related to a ServletResponse object for the
access.log.
|
static java.lang.String |
getLogInfoBeforeService(javax.servlet.ServletRequest _req,
javax.servlet.ServletResponse _res)
Gets the debug information related to a ServletRequest object for the access.log.
|
static java.lang.String |
getOndemandJspUri(javax.servlet.http.HttpServletRequest request)
Gets the url of the on demand page by the path of specified request.
|
static int |
getOndemandTaskInitPriority()
Gets the initial priority of on demand tasks.
|
static java.lang.String |
getProductLicense(java.text.SimpleDateFormat df)
Gets license of the server.
|
static java.lang.String |
getProductSystemInfo()
Gets system information of the server.
|
static java.lang.String |
getProductSystemProp()
Gets system properties of the server.
|
static java.lang.String |
getProductVersionInfo()
Gets version information of the server.
|
static java.lang.String |
getQueryBase(javax.servlet.http.HttpServletRequest req,
boolean convertEscapeForServletPath)
Gets the path of HttpServletRequest, including the servlet path for making
HTTP query string.
|
static java.lang.String |
getQueryBaseNoPath(javax.servlet.http.HttpServletRequest req,
boolean convertEscapeForServletPath)
Gets the servlet path for making HTTP query string.
|
static java.lang.String |
getRealmDir()
Gets the directory for realm files on the server.
|
static java.lang.String |
getReferer(javax.servlet.http.HttpServletRequest request)
auto get jsp referer, used to relative jsp prosess business logic and return to the previous page.
|
static RemoteFileService |
getRemoteFileService()
Gets the
RemoteFileService which connect to the HttpRptServer object created by initEnv(...) |
static RemoteFileService |
getRemoteFileService(javax.servlet.http.HttpServletRequest request)
Deprecated.
As of v12.1 replaced by
RptServer.getRemoteFileService() |
static long |
getReportWaitTimeouts()
Gets the timeouts of waiting reports in milliseconds.
|
static int |
getScheduleTaskInitPriority()
Gets the initial priority of scheduled tasks.
|
static java.lang.String |
getServletPath(javax.servlet.http.HttpServletRequest req)
Gets the servlet path.
|
static java.util.Properties |
getUploadFileProperties(javax.servlet.http.HttpServletRequest req,
java.lang.String tempDir)
Uploads and unzips zipped files and gets relevant properties of the
files.
|
static java.util.Properties |
getUploadFileProperties(javax.servlet.http.HttpServletRequest req,
java.lang.String tempDir,
boolean isZip)
Uploads and gets relevant properties of the files.
|
static java.lang.String |
getUser(javax.servlet.http.HttpServletRequest req)
Gets the JReport user ID (user name) logged into the session associated with the HttpServletRequest.
|
static java.lang.String |
getValidMonitoringURL()
Gets the currently valid and active monitoring web url entry.
|
static java.lang.String |
getValidMonitoringURL(java.lang.String host,
java.lang.String port)
Gets the currently valid and active monitoring web url entry.
|
static java.lang.String |
getWebAppUrl(javax.servlet.http.HttpServletRequest req,
java.lang.String appName)
Gets the url of the given web app name, based on provided
HttpServletRequest object. |
static void |
handleFileNameByBrowserTypeForDownload(java.lang.String fileName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Encoding download file name by browser type, if browser type can not be identified, will set download file name by original file name.
|
static void |
initEnv(java.util.Properties props)
Creates and initializes the HttpRptServer object using the given set of properties.
|
static boolean |
isEnableDynamicResource()
Checks if resources from real path is enabled.
|
static boolean |
isEnableMonitorLink()
Checks if the monitor link is enabled.
|
static boolean |
isEnableTaskDuration()
Checks whether task duration is enabled.
|
static boolean |
isPipeline()
Checks whether to support pipeline for try-view reports
|
static boolean |
isPublishTempToVersion()
Checks if temp result can be published to version system.
|
static boolean |
isPublishTempToVersion(java.lang.String filename)
Checks if the specified file of temp result can publish to version system.
|
static boolean |
isRemoteServer()
Checks whether it is a remote server.
|
static boolean |
isSecure()
Deprecated.
since v6.1, replaced by
jet.server.api.UserSessionManager.needSecurity().
|
static boolean |
isShowNameWithPostfix()
Gets a boolean value from bin\server.properties to show names with or
without extension.
|
static boolean |
isShowVersionParamContents()
Checks whether to show the contents of parameter files in the version table
|
static boolean |
isStandaloneServer()
Checks whether the server is in an integrated environment.
|
static boolean |
isValidMonitoringURL(java.lang.String sURL)
Checks if the specific monitor URL is valid.
|
static boolean |
isValidMonitoringURL(java.lang.String sURL,
java.lang.String host,
java.lang.String port)
Checks if the specific monitor URL is valid.
|
static void |
logout(javax.servlet.http.HttpServletRequest req)
Logs out the JReport user currently logged in to the UserSession associated with the Http Request.
|
static java.lang.String |
printURL(javax.servlet.http.HttpServletRequest request) |
static void |
processPartialRequest(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file,
java.util.Hashtable ht)
Processes an http request for partial contents.
|
static void |
restartServer()
Restarts the HttpRptServer.
|
static void |
sendBytes(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
byte[] bytes,
java.lang.String name) |
static void |
sendFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.io.File file)
Sends a file to the client.
|
static void |
sendRemoteFile(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res,
java.lang.String filename)
Sends a file to a remote end.
|
static void |
shutdownServer()
Shuts down the HttpRptServer.
|
static void |
unbindHttpRptServer(java.lang.String dispatchId)
Unbind the dispatchId with the HttpRptServer which binded by
bindHttpRptServer(HttpRptServer, String) . |
static void |
updateLicense(java.lang.String uid,
java.lang.String licenseKey) |
static void |
updateServletPaths(javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request)
Updates servlet paths in server.properties automatically.
|
static java.util.Properties |
uploadSkinFile(javax.servlet.http.HttpServletRequest req,
java.lang.String tempDir)
Uploads a single unzipped file and specifies the file name.
|
static boolean |
useRelativeWebAppUrl()
Indicates use relative path or absolute path when getting a web app url.
|
changePassword, decodeEsc, decodeEscapeEx, dirIncludeCatalog, dirIncludeReport, encodeEsc, encodeEsc, getParameters, getResultType, getTempResultKey, hasPageSecurity, isClientAPI, isJRClient, makeQuery, makeQueryWithout, outputHtmlTableHeader, parseQuery, redirect, sendMessage, sendMessage
public static void initEnv(java.util.Properties props)
Use this method to avoid creating more than one HttpRptServer instance.
If the HttpRptServer is not started, this will start it, so that it can be used by all later requests.
If the HttpRptServer has already been started, this method will do nothing.
The "props" parameter should contain the properties to be used by the HttpRptServer which is initialized. A common convention is to call this method with the property values that are registered in the external property files, using System.getProperties() to obtain them.
Example: HttpUtil.initEnv(System.getProperties());
props
- properties of the server. The property "reporthome" must be
set. Other properties are optional.
The properties are:
public static void updateLicense(java.lang.String uid, java.lang.String licenseKey)
public static boolean isRemoteServer()
public static RemoteFileService getRemoteFileService()
RemoteFileService
which connect to the HttpRptServer object created by initEnv(...)getHttpRptServer()
public static RemoteFileService getRemoteFileService(javax.servlet.http.HttpServletRequest request)
RptServer.getRemoteFileService()
request
- the HttpServletRequest object.RptServer.getRemoteFileService()
public static HttpRptServer getHttpRptServer()
public static HttpRptServer getHttpRptServer(javax.servlet.http.HttpServletRequest request)
request
- the HttpServletRequest object.public static HttpRptServer getHttpRptServer(javax.servlet.http.HttpServletRequest request, int clusterMemberId)
getHttpRptServer(HttpServletRequest)
request
- clusterMemberId
- public static HttpRptServer dispatchHttpRptServer(javax.servlet.http.HttpServletRequest request)
Generally, to make subsequence request connect to same HttpRptServer, client need to bind the result HttpRptServer to a specified dispathId.
Client should not call this method before the first time initEnv(Properties)
successful.
request
- bindHttpRptServer(HttpRptServer, String)
,
#getHttpRptServerByDispatchId(String)
public static void bindHttpRptServer(HttpRptServer server, java.lang.String dispatchId)
The dispatchId required be unique in the cluster scope, and has pattern: XXXX@serverMemberId.
Client should not call this method before the first time initEnv(Properties)
successful.
server
- dispatchId
- must be unique in the cluster scopepublic static HttpRptServer getBindedHttpRptServer(java.lang.String dispatchId)
client should not call this method before the first time initEnv(Properties)
successful.
dispatchId
- null
if there is not a binded HttpRptServer for the dispatchId.public static void unbindHttpRptServer(java.lang.String dispatchId)
bindHttpRptServer(HttpRptServer, String)
.
If has not HttpRptServer bind with the specified dispatchId, no effect.
Client should not call this method before the first time initEnv(Properties)
successful.
dispatchId
- public static java.lang.String getAuthScheme()
initEnv(Properties props).
public static java.lang.String getDefaultDoc()
initEnv(Properties props).
public static java.lang.String getBase(javax.servlet.http.HttpServletRequest req, boolean convertEscapeForServletPath)
For example:
req
- the HttpServletRequest.convertEscapeForServletPath
- indicates whether to convert escape characters for the servlet
path.public static java.lang.String getBaseNoPath(javax.servlet.http.HttpServletRequest req, boolean convertEscapeForServletPath)
For example:
req
- the HttpServletRequest.convertEscapeForServletPath
- indicates whether to convert escape characters for the servlet
path.public static java.lang.String getQueryBase(javax.servlet.http.HttpServletRequest req, boolean convertEscapeForServletPath)
For examples:
req
- the HttpServletRequest.convertEscapeForServletPath
- indicates whether to convert escape characters for the servlet
path.public static java.lang.String getQueryBaseNoPath(javax.servlet.http.HttpServletRequest req, boolean convertEscapeForServletPath)
For examples:
req
- the HttpServletRequest.convertEscapeForServletPath
- indicates whether to convert escape characters for the servlet
path.public static java.lang.String getUser(javax.servlet.http.HttpServletRequest req)
req
- the HttpServletRequest. Return the user ID (suer name) logged into the session associated with the
HttpServletRequest object.public static boolean isSecure()
public static void restartServer() throws java.lang.Throwable
java.lang.Throwable
- if a Throwable occurs.public static void shutdownServer() throws java.lang.Throwable
java.lang.Throwable
- if a Throwable occurs.public static java.lang.String getHttpURL()
public static boolean checkLogin(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException
Returns true if an authenticated JReport Server user is logged-in to the web session.
There is no false return. For the non-true case, it sends a response to the browser and stops processing.
This is a facade pattern for calling HttpUserSessionManager.checkLogin(), followed by a potential call to HttpUserSessionManager.sendUnauthorizedResponse() to initiate an HTTP Authentication dialog with the browser. It initiates the dialog with the browser when a logged-in user can not be found. This method does not return when a logged-in user is not found. (This is when HttpUserSessionManager.checkLogin() returns false.)
If a logged-in user is not found, it attempts to log in a user based on the HttpExternalAuthorized login framework, and the current HTTP Request parameters passed in to it.
First, it calls the HttpExternalAuthorized class method getExternalAuthorizedUser().
If this returns a valid JReport user id, it logs this user into the JReport session.
If this does not return a valid user id, it looks in the HTTP Request header
for the Authorization field (following the current HTTP
Authentication protocal settings, either Basic or Digest),
and uses what it finds as the name/password credentials to validate as a known JReport user.
If the header has credentials and they validate, it logs this user into the JReport session.
If the HTTP Request header does not contain credentials that validate, it looks
in the HttpServletRequest parameters for either the pair of parameters
APIConst.TAG_AUTH_UID and APIConst.TAG_AUTH_PWD or the single parameter
APIConst.TAG_AUTHORIZATION, and uses the parameter values or value to get
the name/password credentials to validate.
If these exist and the values validate, it logs this user into the JReport session.
When a user is logged into the JReport session based on credentials that checkLogin validates during this call, a new UserSession is established within the servlet session so that subsequent calls to checkLogin can return true immediately based on a user being logged-in.
If checkLogin is able to log in a user during this call it returns true.
If checkLogin does not find a user already logged-in and can not log in a user
following this process, it calls HttpUserSessionManager.sendUnauthorizedResponse()
which sends an HTTP Response to the client and stops processing on the server.
There is no return from the call in this case.
This method implicitly calls HttpUtil.initEnv(...). So one may get the HttpRptServer handle by HttpUtil.getHttpRptServer() after calling this method.
req
- the HttpServletRequest.res
- the HttpServletResponse.TooManyUsersException
- if a TooManyUsersException occurs.TooManyTimesException
- if a TooManyTimesException occurs.java.io.IOException
- if an IOException occurs.java.lang.RuntimeException
NoRemoteServerException
HttpExternalAuthorized
,
HttpUserSessionManager.checkLogin()
,
HttpUserSessionManager.sendUnauthorizedResponse()
public static boolean checkLoginEx(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException, InvalidUserException
TooManyUsersException
java.io.IOException
TooManyTimesException
java.lang.RuntimeException
NoRemoteServerException
InvalidUserException
public static boolean checkLogin(javax.servlet.http.HttpServletRequest req) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException
Returns true if an authenticated JReport Server user is logged-in to the web session.
There is no false return. For the non-true case, it dont sends a response to the browser and stops processing.
This is a facade pattern for calling HttpUserSessionManager.checkLogin(), followed by a potential call to HttpUserSessionManager.sendUnauthorizedResponse() to initiate an HTTP Authentication dialog with the browser. It initiates the dialog with the browser when a logged-in user can not be found. This method does not return when a logged-in user is not found. (This is when HttpUserSessionManager.checkLogin() returns false.)
If a logged-in user is not found, it attempts to log in a user based on the HttpExternalAuthorized login framework, and the current HTTP Request parameters passed in to it.
First, it calls the HttpExternalAuthorized class method getExternalAuthorizedUser().
If this returns a valid JReport user id, it logs this user into the JReport session.
If this does not return a valid user id, it looks in the HTTP Request header
for the Authorization field (following the current HTTP
Authentication protocal settings, either Basic or Digest),
and uses what it finds as the name/password credentials to validate as a known JReport user.
If the header has credentials and they validate, it logs this user into the JReport session.
If the HTTP Request header does not contain credentials that validate, it looks
in the HttpServletRequest parameters for either the pair of parameters
APIConst.TAG_AUTH_UID and APIConst.TAG_AUTH_PWD or the single parameter
APIConst.TAG_AUTHORIZATION, and uses the parameter values or value to get
the name/password credentials to validate.
If these exist and the values validate, it logs this user into the JReport session.
When a user is logged into the JReport session based on credentials that checkLogin validates during this call, a new UserSession is established within the servlet session so that subsequent calls to checkLogin can return true immediately based on a user being logged-in.
If checkLogin is able to log in a user during this call it returns true.
If checkLogin does not find a user already logged-in and can not log in a user
following this process, it calls HttpUserSessionManager.sendUnauthorizedResponse()
which sends an HTTP Response to the client and stops processing on the server.
There is no return from the call in this case.
This method implicitly calls HttpUtil.initEnv(...). So one may get the HttpRptServer handle by HttpUtil.getHttpRptServer() after calling this method.
req
- the HttpServletRequest.TooManyUsersException
- if a TooManyUsersException occurs.TooManyTimesException
- if a TooManyTimesException occurs.java.io.IOException
- if an IOException occurs.java.lang.RuntimeException
NoRemoteServerException
HttpExternalAuthorized
,
HttpUserSessionManager.checkLogin()
,
HttpUserSessionManager.sendUnauthorizedResponse()
public static boolean checkAdminLogin(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException
There is no false return. For the non-true case, it sends a response to the browser and stops processing.
This is a facade pattern for calling HttpUserSessionManager.checkAdminLogin(), followed by a potential call to HttpUserSessionManager.sendUnauthorizedResponse() to initiate an HTTP Authentication dialog with the browser. It initiates the dialog with the browser when a logged-in admin user can not be found. This method does not return when a logged-in user is not found. (This is when HttpUserSessionManager.checkAdminLogin() returns false.)
If a logged-in admin user is not found, it attempts to log in a user based on the HttpExternalAuthorized login framework, and the current HTTP Request parameters passed in to it.
First, it calls the HttpExternalAuthorized class method getExternalAuthorizedUser().
If this returns a valid JReport admin user id, it logs this user into the JReport session.
If this does not return a valid admin user id, it looks in the HTTP Request header
for the Authorization field (following the current HTTP
Authentication protocal settings, either Basic or Digest),
and uses what it finds as the name/password credentials to validate as a known JReport admin user.
If the header has credentials and they validate an admin user, it logs this user into the JReport session.
If the HTTP Request header does not contain credentials that validate, it looks
in the HttpServletRequest parameters for either the pair of parameters
APIConst.TAG_AUTH_UID and APIConst.TAG_AUTH_PWD or the single parameter
APIConst.TAG_AUTHORIZATION, and uses the parameter values or value to get
the name/password credentials to validate.
If these exist and the values validate an admin user, it logs this user into the JReport session.
When a admin user is logged into the JReport session based on credentials that checkLogin validates during this call, a new UserSession is established within the servlet session so that subsequent calls to checkAdminLogin can return true immediately based on an admin user being logged-in.
If checkAdminLogin() is able to log in an admin user during this call it returns true.
If checkAdminLogin does not find an admin user already logged-in and can not log in an admin user
following this process, it calls HttpUserSessionManager.sendUnauthorizedResponse()
which sends an HTTP Response to the client and stops processing on the server.
There is no return from the call in this case.
This method implicitly calls HttpUtil.initEnv(...). So one may get the HttpRptServer handle by HttpUtil.getHttpRptServer() after calling this method.
req
- the HttpServletRequest.res
- the HttpServletResponse.TooManyUsersException
- if a TooManyUsersException occurs.TooManyTimesException
- if a TooManyTimesException occurs.java.io.IOException
- if an IOException occurs.java.lang.RuntimeException
NoRemoteServerException
HttpExternalAuthorized
,
HttpUserSessionManager.checkAdminLogin()
,
HttpUserSessionManager.sendUnauthorizedResponse()
public static boolean checkAdminLoginEx(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException, InvalidUserException
TooManyUsersException
java.io.IOException
TooManyTimesException
java.lang.RuntimeException
NoRemoteServerException
InvalidUserException
public static boolean checkAdminLogin(javax.servlet.http.HttpServletRequest req) throws TooManyUsersException, java.io.IOException, TooManyTimesException, java.lang.RuntimeException, NoRemoteServerException
There is no false return. For the non-true case, it dont sends a response to the browser and stops processing.
This is a facade pattern for calling HttpUserSessionManager.checkAdminLogin(), followed by a potential call to HttpUserSessionManager.sendUnauthorizedResponse() to initiate an HTTP Authentication dialog with the browser. It initiates the dialog with the browser when a logged-in admin user can not be found. This method does not return when a logged-in user is not found. (This is when HttpUserSessionManager.checkAdminLogin() returns false.)
If a logged-in admin user is not found, it attempts to log in a user based on the HttpExternalAuthorized login framework, and the current HTTP Request parameters passed in to it.
First, it calls the HttpExternalAuthorized class method getExternalAuthorizedUser().
If this returns a valid JReport admin user id, it logs this user into the JReport session.
If this does not return a valid admin user id, it looks in the HTTP Request header
for the Authorization field (following the current HTTP
Authentication protocal settings, either Basic or Digest),
and uses what it finds as the name/password credentials to validate as a known JReport admin user.
If the header has credentials and they validate an admin user, it logs this user into the JReport session.
If the HTTP Request header does not contain credentials that validate, it looks
in the HttpServletRequest parameters for either the pair of parameters
APIConst.TAG_AUTH_UID and APIConst.TAG_AUTH_PWD or the single parameter
APIConst.TAG_AUTHORIZATION, and uses the parameter values or value to get
the name/password credentials to validate.
If these exist and the values validate an admin user, it logs this user into the JReport session.
When a admin user is logged into the JReport session based on credentials that checkLogin validates during this call, a new UserSession is established within the servlet session so that subsequent calls to checkAdminLogin can return true immediately based on an admin user being logged-in.
If checkAdminLogin() is able to log in an admin user during this call it returns true.
If checkAdminLogin does not find an admin user already logged-in and can not log in an admin user
following this process, it calls HttpUserSessionManager.sendUnauthorizedResponse()
which sends an HTTP Response to the client and stops processing on the server.
There is no return from the call in this case.
This method implicitly calls HttpUtil.initEnv(...). So one may get the HttpRptServer handle by HttpUtil.getHttpRptServer() after calling this method.
req
- the HttpServletRequest.TooManyUsersException
- if a TooManyUsersException occurs.TooManyTimesException
- if a TooManyTimesException occurs.java.io.IOException
- if an IOException occurs.java.lang.RuntimeException
NoRemoteServerException
HttpExternalAuthorized
,
HttpUserSessionManager.checkAdminLogin()
,
HttpUserSessionManager.sendUnauthorizedResponse()
public static void logout(javax.servlet.http.HttpServletRequest req)
req
- http servlet request.public static boolean checkPermission(javax.servlet.http.HttpServletRequest req) throws NoPrivilegeException
The requested action is the value of "jrs.cmd" query paramter in the HttpServletRequest or is the HTTP method of the HttpServletRequest.
The target resource is the report resource identified by the path information query parameters in the HttpServletRequest.
The path information is indicated by query parameters:
req
- the HttpServletRequest.NoPrivilegeException
public static void sendFile(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.io.File file) throws java.io.IOException
req
- the HttpServletRequest.res
- the HttpServletResponse.file
- the file.java.io.IOException
- if an IOException occurs.public static void sendBytes(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, byte[] bytes, java.lang.String name) throws java.io.IOException
java.io.IOException
public static void sendRemoteFile(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.lang.String filename) throws java.io.IOException
req
- the HttpServletRequest.res
- the HttpServletResponse.file
- the file.java.io.IOException
- if an IOException occurs.public static java.lang.String getServletPath(javax.servlet.http.HttpServletRequest req)
req
- the HttpServletRequest.public static long getReportWaitTimeouts()
public static boolean isPublishTempToVersion()
public static boolean isPublishTempToVersion(java.lang.String filename)
public static boolean isEnableDynamicResource()
public static boolean isEnableTaskDuration()
public static void copyFilesByPrefix(java.lang.String srcDir, java.lang.String srcPrefix, java.lang.String destDir, java.lang.String destPrefix) throws java.lang.Exception
srcDir
- the source directory.srcPrefix
- source file's prefix.destDir
- destination file's directory.destPrefix
- destination file's prefix.java.lang.Exception
public static void processPartialRequest(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, java.io.File file, java.util.Hashtable ht) throws java.lang.Exception
req
- the http request.res
- the http response.file
- the file that is required.ht
- additional properties of the request.java.lang.Exception
- when exception is thrown during processing.public static boolean isShowNameWithPostfix()
public static java.lang.String getJSPWebAppName(java.lang.String propname)
propname
- the property name that records this webapp eg. propname
"jsp.webapp.sendfile" sendfile's webapp name
"\servlet\sendfile"public static boolean useRelativeWebAppUrl()
getWebAppUrl()
public static java.lang.String getWebAppUrl(javax.servlet.http.HttpServletRequest req, java.lang.String appName)
HttpServletRequest
object. Returned value varies,
depending on the returned value HttpUtil.useRelativeWebAppUrl()
,
if it is true, return a url related with provided req
,
otherwise return absolute path of appName
. For example,
appName
is "/dhtml", the servlet path of req
is "/jinfonet/runReport.jsp", if
WebPageOptions.useRelativeWebAppUrl()
returns true,
this method return "../dhtml", otherwise return "/dhtml".req
- the HttpServletRequest
object.appName
- a web app name, for example, "/dhtml".appName
based on
the provided request.useRelativeWebAppUrl()
public static java.util.List getLanguageList()
public static boolean isPipeline()
public static boolean isShowVersionParamContents()
public static java.lang.String getProductVersionInfo()
public static java.lang.String getInternalBuildLable()
public static java.lang.String getProductLicense(java.text.SimpleDateFormat df)
public static java.lang.String getProductSystemInfo()
public static java.lang.String getAdhocServletPath()
public static java.lang.String getAdhocJspPath()
public static java.lang.String getJRServletPath()
public static boolean isEnableMonitorLink()
public static java.lang.String getProductSystemProp()
public static boolean getAdHoc()
public static java.lang.String getLogInfoBeforeService(javax.servlet.ServletRequest _req, javax.servlet.ServletResponse _res)
req
- the ServletRequest._res
- the ServletResponse. Return the debug information related to a
ServletRequest object for the access.log.public static java.lang.String getLogInfoAfterService(javax.servlet.ServletRequest _req, javax.servlet.ServletResponse _res)
req
- the ServletRequest._res
- the ServletResponse. Return the debug information related to a
ServletResponse object for the access.log.public static java.util.Properties uploadSkinFile(javax.servlet.http.HttpServletRequest req, java.lang.String tempDir) throws java.io.IOException
req
- the HttpServletRequest.tempDir
- the temp directory for uploading.java.io.IOException
public static java.util.Properties getUploadFileProperties(javax.servlet.http.HttpServletRequest req, java.lang.String tempDir) throws java.io.IOException
req
- the HttpServletRequest.tempDir
- the temp directory for returning
relevant properties of the filesjava.io.IOException
public static java.util.Properties getUploadFileProperties(javax.servlet.http.HttpServletRequest req, java.lang.String tempDir, boolean isZip) throws java.io.IOException
req
- the HttpServletRequest.tempDir
- the temp directory for uploading files.isZip
- if the uploaded files is compressed.java.io.IOException
public static boolean isStandaloneServer()
public static void updateServletPaths(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request)
context root + servlet mapped path
.
context root
is gotten from the parameter context
, and
servlet mapped path
must be a constant string which
JReport Server has defined for each servlet. In server.properties, the values
of below properties will be updatedProperty Name | Servlet Mapped Path |
jsp.webapp.sendfile |
sendfile |
web.jreport_servlet_path |
jrserver |
web.dhtml_jsp_path |
dhtmljsp |
web.dhtml_servlet_entry_path |
jrdhtml |
web.dhtml_servlet_path |
dhtml |
web.help_servlet_path |
help |
context
- the ServletContext
which the current servlet
belongs to.request
- the HttpServletRequest
received in current
servlet.public static java.lang.String getRealmDir()
public static boolean isValidMonitoringURL(java.lang.String sURL, java.lang.String host, java.lang.String port)
sURL
- the monitor URL.host
- the monitor host.port
- the monitor port.public static boolean isValidMonitoringURL(java.lang.String sURL)
sURL
- the monitor URL.public static java.lang.String getValidMonitoringURL()
public static java.lang.String getValidMonitoringURL(java.lang.String host, java.lang.String port)
host
- the monitor host.port
- the monitor port.public static java.lang.String getHostAddress(java.lang.String hostName)
hostName
- the host name.public static int getAutoRecoverTaskMaxTimes()
public static long getAutoRecoverTaskInterval()
public static boolean getAutoRecoverTaskRedoAll()
public static java.lang.String getJspUri(javax.servlet.http.HttpServletRequest request, java.lang.String jspPath)
request
- the http servlet request.jspPath
- the path of the jsp.public static java.lang.String getOndemandJspUri(javax.servlet.http.HttpServletRequest request)
the
- based http request.public static java.lang.String filterXSS(java.lang.String oldVal)
oldVal
- the original html contentpublic static int getOndemandTaskInitPriority()
public static int getScheduleTaskInitPriority()
public static java.lang.String getReferer(javax.servlet.http.HttpServletRequest request)
public static java.lang.String printURL(javax.servlet.http.HttpServletRequest request)
public static void handleFileNameByBrowserTypeForDownload(java.lang.String fileName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.lang.Exception
fileName
- Original file namerequest
- HttpServletRequestresponse
- HttpServletResponsejava.lang.Exception