Class Credentials
- All Implemented Interfaces:
Serializable
This class is used along with AuthenticationProvider to provide arbitrary HTTP-based authentication for Guacamole.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCredentials
(String username, String password, javax.servlet.http.HttpServletRequest request) Creates a new Credentials object with the given username, password, and HTTP request.Credentials
(String username, String password, RequestDetails requestDetails) Creates a new Credentials object with the given username, password, and general HTTP request details. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of the HTTP header having the given name from the original details of the HTTP request that is related to these credentials.getParameter
(String name) Returns the value of the HTTP parameter having the given name from the original details of the HTTP request that is related to these credentials.Returns the password associated with this set of credentials.Returns the address of the client end of the connection which provided these credentials, if known.Returns the hostname of the client end of the connection which provided these credentials, if known.javax.servlet.http.HttpServletRequest
Deprecated.It is not reliable to reference an HttpServletRequest outside the scope of the specific request that created it.Returns the details of the HTTP request related to these Credentials.javax.servlet.http.HttpSession
Returns the HttpSession associated with this set of credentials.Returns the username associated with this set of credentials.boolean
isEmpty()
Returns whether this Credentials object does not contain any specific authentication parameters, including HTTP parameters and the HTTP header used for the authentication token.void
setPassword
(String password) Sets the password associated with this set of credentials.void
setRemoteAddress
(String remoteAddress) Deprecated.Since 1.6.0, the address that may be associated with a Credentials object is tied to the RequestDetails.void
setRemoteHostname
(String remoteHostname) Deprecated.Since 1.6.0, the hostname that may be associated with a Credentials object is tied to the RequestDetails.void
setRequest
(javax.servlet.http.HttpServletRequest request) Deprecated.It is not reliable to reference an HttpServletRequest outside the scope of the specific request that created it.void
setRequestDetails
(RequestDetails requestDetails) Replaces the current HTTP request details of these Credentials with the given details.void
setSession
(javax.servlet.http.HttpSession session) Deprecated.Since 1.6.0, the HttpSession that may be associated with a Credentials object is tied to the RequestDetails.void
setUsername
(String username) Sets the username associated with this set of credentials.
-
Constructor Details
-
Credentials
Creates a new Credentials object with the given username, password, and HTTP request. The details of the request are copied for later reference and can be retrieved withgetRequestDetails()
.- Parameters:
username
- The username that was provided for authentication.password
- The password that was provided for authentication.request
- The HTTP request associated with the authentication request.
-
Credentials
Creates a new Credentials object with the given username, password, and general HTTP request details.- Parameters:
username
- The username that was provided for authentication.password
- The password that was provided for authentication.requestDetails
- The details of the HTTP request associated with the authentication request.
-
-
Method Details
-
getPassword
Returns the password associated with this set of credentials.- Returns:
- The password associated with this username/password pair, or null if no password has been set.
-
setPassword
Sets the password associated with this set of credentials.- Parameters:
password
- The password to associate with this username/password pair.
-
getUsername
Returns the username associated with this set of credentials.- Returns:
- The username associated with this username/password pair, or null if no username has been set.
-
setUsername
Sets the username associated with this set of credentials.- Parameters:
username
- The username to associate with this username/password pair.
-
getRequest
Deprecated.It is not reliable to reference an HttpServletRequest outside the scope of the specific request that created it. UsegetRequestDetails()
instead.Returns the HttpServletRequest associated with this set of credentials.- Returns:
- The HttpServletRequest associated with this set of credentials, or null if no such request exists.
-
setRequest
Deprecated.It is not reliable to reference an HttpServletRequest outside the scope of the specific request that created it. UsesetRequestDetails(org.apache.guacamole.net.RequestDetails)
instead.Sets the HttpServletRequest associated with this set of credentials.- Parameters:
request
- The HttpServletRequest to associated with this set of credentials.
-
getRequestDetails
Returns the details of the HTTP request related to these Credentials.- Returns:
- The details of the HTTP request related to these Credentials.
-
setRequestDetails
Replaces the current HTTP request details of these Credentials with the given details.- Parameters:
requestDetails
- The details of the HTTP request that should replace the established details within these Credentials.
-
getSession
public javax.servlet.http.HttpSession getSession()Returns the HttpSession associated with this set of credentials.This is a convenience function that is equivalent to invoking
RequestDetails.getSession()
on theRequestDetails
returned bygetRequestDetails()
.NOTE: Guacamole itself does not use the HttpSession. The extension subsystem does not provide access to the session object used by Guacamole, which is considered internal. Access to an HttpSession is only of use if you have another application in place that does use HttpSession and needs to be considered.
- Returns:
- The HttpSession associated with this set of credentials, or null if there is no HttpSession.
-
setSession
Deprecated.Since 1.6.0, the HttpSession that may be associated with a Credentials object is tied to the RequestDetails. If the HttpSession is part of a Credentials and truly needs to be replaced by another HttpSession, usesetRequestDetails(org.apache.guacamole.net.RequestDetails)
to override the underlyingRequestDetails
instead.Sets the HttpSession associated with this set of credentials.- Parameters:
session
- The HttpSession to associated with this set of credentials.
-
getHeader
Returns the value of the HTTP header having the given name from the original details of the HTTP request that is related to these credentials. Header names are case-insensitive. If no such header was present, null is returned. If the header had multiple values, the first value is returned.For access to all values of a header, as well as other details of the request, see
getRequestDetails()
. This is a convenience function that is equivalent to invokingRequestDetails.getHeader(java.lang.String)
.- Parameters:
name
- The name of the header to retrieve. This name is case-insensitive.- Returns:
- The first value of the HTTP header with the given name, or null if there is no such header.
-
getParameter
Returns the value of the HTTP parameter having the given name from the original details of the HTTP request that is related to these credentials. Parameter names are case-sensitive. If no such parameter was present, null is returned. If the parameter had multiple values, the first value is returned.For access to all values of a parameter, as well as other details of the request, see
getRequestDetails()
. This is a convenience function that is equivalent to invokingRequestDetails.getParameter(java.lang.String)
.- Parameters:
name
- The name of the parameter to retrieve. This name is case-sensitive.- Returns:
- The first value of the HTTP parameter with the given name, or null if there is no such parameter.
-
getRemoteAddress
Returns the address of the client end of the connection which provided these credentials, if known.This is a convenience function that is equivalent to invoking
RequestDetails.getRemoteAddress()
on theRequestDetails
returned bygetRequestDetails()
.- Returns:
- The address of the client end of the connection which provided these credentials, or null if the address is not known.
-
setRemoteAddress
Deprecated.Since 1.6.0, the address that may be associated with a Credentials object is tied to the RequestDetails. If the address truly needs to be replaced, usesetRequestDetails(org.apache.guacamole.net.RequestDetails)
to override the underlyingRequestDetails
instead.Sets the address of the client end of the connection which provided these credentials.- Parameters:
remoteAddress
- The address of the client end of the connection which provided these credentials, or null if the address is not known.
-
getRemoteHostname
Returns the hostname of the client end of the connection which provided these credentials, if known. If the hostname of the client cannot be determined, but the address is known, the address may be returned instead.This is a convenience function that is equivalent to invoking
RequestDetails.getRemoteHostname()
on theRequestDetails
returned bygetRequestDetails()
.- Returns:
- The hostname or address of the client end of the connection which provided these credentials, or null if the hostname is not known.
-
setRemoteHostname
Deprecated.Since 1.6.0, the hostname that may be associated with a Credentials object is tied to the RequestDetails. If the hostname truly needs to be replaced, usesetRequestDetails(org.apache.guacamole.net.RequestDetails)
to override the underlyingRequestDetails
instead.Sets the hostname of the client end of the connection which provided these credentials, if known. If the hostname of the client cannot be determined, but the address is known, the address may be specified instead.- Parameters:
remoteHostname
- The hostname or address of the client end of the connection which provided these credentials, or null if the hostname is not known.
-
isEmpty
public boolean isEmpty()Returns whether this Credentials object does not contain any specific authentication parameters, including HTTP parameters and the HTTP header used for the authentication token. An authentication request that contains no parameters whatsoever will tend to be the first, anonymous, credential-less authentication attempt that results in the initial login screen rendering.- Returns:
- true if this Credentials object contains no authentication parameters whatsoever, false otherwise.
-