Interface VaadinRequest
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
VaadinServletRequest
public interface VaadinRequest extends Serializable
A generic request to the server, wrapping a more specific request type, e.g. HttpServletReqest or PortletRequest.- Since:
- 7.0.0
- Author:
- Vaadin Ltd
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Object
getAttribute(String name)
Gets a request attribute.Enumeration<String>
getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this request.String
getAuthType()
Returns the name of the authentication scheme used for the connection between client and server, for example,BASIC_AUTH
,CLIENT_CERT_AUTH
, a custom one ornull
if there was no authentication.String
getCharacterEncoding()
Returns the name of the character encoding used in the body of this request.int
getContentLength()
Returns the length of the request content that can be read from the input stream returned bygetInputStream()
.String
getContentType()
Returns the MIME type of the body of the request, or null if the type is not known.String
getContextPath()
Returns the portion of the request URI that indicates the context of the request.javax.servlet.http.Cookie[]
getCookies()
Returns an array containing all of theCookie
objects the client sent with this request.long
getDateHeader(String name)
Returns the value of the specified request header as a long value that represents a Date object.String
getHeader(String headerName)
Gets the value of a request header, e.g.Enumeration<String>
getHeaderNames()
Returns an enumeration of all the header names this request contains.Enumeration<String>
getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.InputStream
getInputStream()
Returns an input stream from which the request content can be read.Locale
getLocale()
Gets locale information from the query, e.g.Enumeration<Locale>
getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header.String
getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.String
getParameter(String parameter)
Gets the named request parameter This is typically a HTTP GET or POST parameter, though other request types might have other ways of representing parameters.Map<String,String[]>
getParameterMap()
Gets all the parameters of the request.String
getPathInfo()
Gets the path of the requested resource relative to the application.BufferedReader
getReader()
Retrieves the body of the request as character data using aBufferedReader
.String
getRemoteAddr()
Returns the IP address from which the request came.String
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.int
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.String
getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated.VaadinService
getService()
Gets the vaadin service for the context of this request.Principal
getUserPrincipal()
Returns ajava.security.Principal
object containing the name of the current authenticated user.WrappedSession
getWrappedSession()
Gets the session associated with this request, creating a new if there is no session.WrappedSession
getWrappedSession(boolean allowSessionCreation)
Gets the session associated with this request, optionally creating a new if there is no session.boolean
isSecure()
Checks whether the request was made using a secure channel, e.g.boolean
isUserInRole(String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role".void
removeAttribute(String name)
Removes an attribute from this request.void
setAttribute(String name, Object value)
Defines a request attribute.
-
-
-
Method Detail
-
getParameter
String getParameter(String parameter)
Gets the named request parameter This is typically a HTTP GET or POST parameter, though other request types might have other ways of representing parameters.- Parameters:
parameter
- the name of the parameter- Returns:
- The paramter value, or
null
if no parameter with the given name is present - See Also:
ServletRequest.getParameter(String)
,javax.portlet.PortletRequest#getParameter(String)
-
getParameterMap
Map<String,String[]> getParameterMap()
Gets all the parameters of the request. Framework's internal init parameters have prefix "v-" (does not include such parameters as "theme" and "debug").- Returns:
- A mapping of parameter names to arrays of parameter values
- See Also:
getParameter(String)
,ServletRequest.getParameterMap()
,javax.portlet.PortletRequest#getParameter(String)
-
getContentLength
int getContentLength()
Returns the length of the request content that can be read from the input stream returned bygetInputStream()
.- Returns:
- content length in bytes
- See Also:
ServletRequest.getContentLength()
-
getInputStream
InputStream getInputStream() throws IOException
Returns an input stream from which the request content can be read. The request content length can be obtained withgetContentLength()
without reading the full stream contents.- Returns:
- the input stream from which the contents of the request can be read
- Throws:
IOException
- if the input stream can not be opened- See Also:
ServletRequest.getInputStream()
,javax.portlet.ClientDataRequest#getPortletInputStream()
-
getAttribute
Object getAttribute(String name)
Gets a request attribute.- Parameters:
name
- the name of the attribute- Returns:
- the value of the attribute, or
null
if there is no attribute with the given name - See Also:
ServletRequest.getAttribute(String)
,javax.portlet.PortletRequest#getAttribute(String)
-
setAttribute
void setAttribute(String name, Object value)
Defines a request attribute.- Parameters:
name
- the name of the attributevalue
- the attribute value- See Also:
ServletRequest.setAttribute(String, Object)
,javax.portlet.PortletRequest#setAttribute(String, Object)
-
getPathInfo
String getPathInfo()
Gets the path of the requested resource relative to the application. The path isnull
if no path information is available. Does always start with / if the path isn'tnull
.- Returns:
- a string with the path relative to the application.
- See Also:
HttpServletRequest.getPathInfo()
-
getContextPath
String getContextPath()
Returns the portion of the request URI that indicates the context of the request. The context path always comes first in a request URI.- Returns:
- a String specifying the portion of the request URI that indicates the context of the request
- See Also:
HttpServletRequest.getContextPath()
-
getWrappedSession
WrappedSession getWrappedSession()
Gets the session associated with this request, creating a new if there is no session.- Returns:
- the wrapped session for this request
- See Also:
WrappedSession
,HttpServletRequest.getSession()
-
getWrappedSession
WrappedSession getWrappedSession(boolean allowSessionCreation)
Gets the session associated with this request, optionally creating a new if there is no session.- Parameters:
allowSessionCreation
-true
to create a new session for this request if necessary;false
to returnnull
if there's no current session- Returns:
- the wrapped session for this request
- See Also:
WrappedSession
,HttpServletRequest.getSession(boolean)
,PortletRequest#getPortletSession(boolean)
-
getContentType
String getContentType()
Returns the MIME type of the body of the request, or null if the type is not known.- Returns:
- a string containing the name of the MIME type of the request, or null if the type is not known
- See Also:
ServletRequest.getContentType()
,javax.portlet.ResourceRequest#getContentType()
-
getLocale
Locale getLocale()
Gets locale information from the query, e.g. using the Accept-Language header.- Returns:
- the preferred Locale
- See Also:
ServletRequest.getLocale()
-
getRemoteAddr
String getRemoteAddr()
Returns the IP address from which the request came. This might also be the address of a proxy between the server and the original requester.- Returns:
- a string containing the IP address, or
null
if the address is not available - See Also:
ServletRequest.getRemoteAddr()
-
isSecure
boolean isSecure()
Checks whether the request was made using a secure channel, e.g. using https.- Returns:
- a boolean indicating if the request is secure
- See Also:
ServletRequest.isSecure()
-
getHeader
String getHeader(String headerName)
Gets the value of a request header, e.g. a http header for aHttpServletRequest
.- Parameters:
headerName
- the name of the header- Returns:
- the header value, or
null
if the header is not present in the request - See Also:
HttpServletRequest.getHeader(String)
-
getService
VaadinService getService()
Gets the vaadin service for the context of this request.- Returns:
- the vaadin service
- See Also:
VaadinService
-
getCookies
javax.servlet.http.Cookie[] getCookies()
Returns an array containing all of theCookie
objects the client sent with this request. This method returnsnull
if no cookies were sent.- Returns:
- an array of all the
Cookies
included with this request, ornull
if the request has no cookies - See Also:
HttpServletRequest.getCookies()
-
getAuthType
String getAuthType()
Returns the name of the authentication scheme used for the connection between client and server, for example,BASIC_AUTH
,CLIENT_CERT_AUTH
, a custom one ornull
if there was no authentication.- Returns:
- a string indicating the authentication scheme, or
null
if the request was not authenticated. - See Also:
HttpServletRequest.getAuthType()
-
getRemoteUser
String getRemoteUser()
Returns the login of the user making this request, if the user has been authenticated, or null if the user has not been authenticated. Whether the user name is sent with each subsequent request depends on the browser and type of authentication.- Returns:
- a String specifying the login of the user making this request, or
null
if the user login is not known. - See Also:
HttpServletRequest.getRemoteUser()
-
getUserPrincipal
Principal getUserPrincipal()
Returns ajava.security.Principal
object containing the name of the current authenticated user. If the user has not been authenticated, the method returnsnull
.- Returns:
- a
java.security.Principal
containing the name of the user making this request;null
if the user has not been authenticated - See Also:
HttpServletRequest.getUserPrincipal()
-
isUserInRole
boolean isUserInRole(String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role". Roles and role membership can be defined using deployment descriptors. If the user has not been authenticated, the method returnsfalse
.- Parameters:
role
- a String specifying the name of the role- Returns:
- a boolean indicating whether the user making this request belongs
to a given role;
false
if the user has not been authenticated - See Also:
HttpServletRequest.isUserInRole(String)
-
removeAttribute
void removeAttribute(String name)
Removes an attribute from this request. This method is not generally needed as attributes only persist as long as the request is being handled.- Parameters:
name
- a String specifying the name of the attribute to remove- See Also:
ServletRequest.removeAttribute(String)
-
getAttributeNames
Enumeration<String> getAttributeNames()
Returns an Enumeration containing the names of the attributes available to this request. This method returns an empty Enumeration if the request has no attributes available to it.- Returns:
- an Enumeration of strings containing the names of the request's attributes
- See Also:
ServletRequest.getAttributeNames()
-
getLocales
Enumeration<Locale> getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order starting with the preferred locale, the locales that are acceptable to the client based on the Accept-Language header. If the client request doesn't provide an Accept-Language header, this method returns an Enumeration containing one Locale, the default locale for the server.- Returns:
- an Enumeration of preferred Locale objects for the client
- See Also:
ServletRequest.getLocales()
-
getRemoteHost
String getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request. If the engine cannot or chooses not to resolve the hostname (to improve performance), this method returns the dotted-string form of the IP address.- Returns:
- a String containing the fully qualified name of the client, or
null
if the information is not available. - See Also:
ServletRequest.getRemoteHost()
-
getRemotePort
int getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.- Returns:
- an integer specifying the port number, or -1 if the information is not available.
- See Also:
ServletRequest.getRemotePort()
-
getCharacterEncoding
String getCharacterEncoding()
Returns the name of the character encoding used in the body of this request. This method returnsnull
if the request does not specify a character encoding.- Returns:
- a String containing the name of the character encoding, or null if the request does not specify a character encoding
- See Also:
ServletRequest.getCharacterEncoding()
-
getReader
BufferedReader getReader() throws IOException
Retrieves the body of the request as character data using aBufferedReader
. The reader translates the character data according to the character encoding used on the body. Either this method orgetInputStream()
may be called to read the body, not both.- Returns:
- a BufferedReader containing the body of the request
- Throws:
UnsupportedEncodingException
- - if the character set encoding used is not supported and the text cannot be decodedIllegalStateException
- - ifgetInputStream()
method has been called on this requestIOException
- if an input or output exception occurred- See Also:
ServletRequest.getReader()
-
getMethod
String getMethod()
Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.- Returns:
- a String specifying the name of the method with which this request was made
- See Also:
HttpServletRequest.getMethod()
-
getDateHeader
long getDateHeader(String name)
Returns the value of the specified request header as a long value that represents a Date object. Use this method with headers that contain dates, such as If-Modified-Since.The date is returned as the number of milliseconds since January 1, 1970 GMT. The header name is case insensitive.
If the request did not have a header of the specified name, this method returns -1. If the header can't be converted to a date, the method throws an IllegalArgumentException.
- Parameters:
name
- a String specifying the name of the header- Returns:
- a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the request
- Throws:
IllegalArgumentException
- If the header value can't be converted to a date- See Also:
HttpServletRequest.getDateHeader(String)
-
getHeaderNames
Enumeration<String> getHeaderNames()
Returns an enumeration of all the header names this request contains. If the request has no headers, this method returns an empty enumeration.Some implementations do not allow access headers using this method, in which case this method returns
null
- Returns:
- an enumeration of all the header names sent with this request; if
the request has no headers, an empty enumeration; if the
implementation does not allow this method,
null
- See Also:
HttpServletRequest.getHeaderNames()
-
getHeaders
Enumeration<String> getHeaders(String name)
Returns all the values of the specified request header as an Enumeration of String objects.Some headers, such as
Accept-Language
can be sent by clients as several headers each with a different value rather than sending the header as a comma separated list.If the request did not include any headers of the specified name, this method returns an empty Enumeration. If the request does not support accessing headers, this method returns
null
.The header name is case insensitive. You can use this method with any request header.
- Parameters:
name
- a String specifying the header name- Returns:
- an Enumeration containing the values of the requested header. If
the request does not have any headers of that name return an
empty enumeration. If the header information is not available,
return
null
- See Also:
HttpServletRequest.getHeaders(String)
-
-