|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler org.apache.sling.auth.core.spi.AbstractAuthenticationHandler
public abstract class AbstractAuthenticationHandler
The AbstractAuthenticationHandler
implements the
AuthenticationHandler
interface and extends the
DefaultAuthenticationFeedbackHandler
providing some helper methods
which may be used by authentication handlers.
Field Summary |
---|
Fields inherited from interface org.apache.sling.auth.core.spi.AuthenticationHandler |
---|
FAILURE_REASON, PATH_PROPERTY, REQUEST_LOGIN_PARAMETER, SERVICE_NAME, TYPE_PROPERTY |
Constructor Summary | |
---|---|
AbstractAuthenticationHandler()
|
Method Summary | |
---|---|
static String |
getAttributeOrParameter(javax.servlet.http.HttpServletRequest request,
String name,
String defaultValue)
Returns the value of the named request attribute or parameter as a string as follows: If there is a request attribute of that name, which is a non-empty string, it is returned. |
static String |
getLoginResource(javax.servlet.http.HttpServletRequest request,
String defaultLoginResource)
Returns any resource target to redirect to after successful authentication. |
static boolean |
isValidateRequest(javax.servlet.http.HttpServletRequest request)
Returns true if the the client just asks for validation of
submitted username/password credentials. |
static void |
sendInvalid(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Sends a 403/FORBIDDEN response to a credential validation request providing the given reason as the value of the X_REASON header. |
static void |
sendRedirect(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
String target,
Map<String,String> params)
Redirects to the given target path appending any parameters provided in the parameter map. |
static void |
sendValid(javax.servlet.http.HttpServletResponse response)
Sends a 200/OK response to a credential validation request. |
static String |
setLoginResourceAttribute(javax.servlet.http.HttpServletRequest request,
String defaultValue)
Ensures and returns the Authenticator.LOGIN_RESOURCE request
attribute is set to a non-null, non-empty string. |
Methods inherited from class org.apache.sling.auth.core.spi.DefaultAuthenticationFeedbackHandler |
---|
authenticationFailed, authenticationSucceeded, handleRedirect |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.sling.auth.core.spi.AuthenticationHandler |
---|
dropCredentials, extractCredentials, requestCredentials |
Constructor Detail |
---|
public AbstractAuthenticationHandler()
Method Detail |
---|
public static String getAttributeOrParameter(javax.servlet.http.HttpServletRequest request, String name, String defaultValue)
defaultValue
is returned.
request
- The request from which to return the attribute or request
parametername
- The name of the attribute/parameterdefaultValue
- The default value to use if neither a non-empty
string attribute or a non-empty parameter exists in the
request.
defaultValue
as defined
above.public static String getLoginResource(javax.servlet.http.HttpServletRequest request, String defaultLoginResource)
defaultLoginResource
parameter. First the
resource
request attribute is checked. If it is a non-empty
string, it is returned. Second the resource
request
parameter is checked and returned if it is a non-empty string.
request
- The request providing the attribute or parameterdefaultLoginResource
- The default login resource value
defaultLoginResource
.public static String setLoginResourceAttribute(javax.servlet.http.HttpServletRequest request, String defaultValue)
Authenticator.LOGIN_RESOURCE
request
attribute is set to a non-null, non-empty string. If the attribute is not
currently set, this method sets it as follows:
Authenticator.LOGIN_RESOURCE
request parameter is set
to a non-empty string, that parameter is setdefaultValue
is a non-empty string the
default value is used
request
- The request to check for the resource attributedefaultValue
- The default value to use if the attribute is not set
and the request parameter is not set. This parameter is
ignored if it is null
or an empty string.
public static void sendRedirect(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, String target, Map<String,String> params) throws IOException
This method implements the following functionality:
target
path parameter must not be prefixed with the context
path.params
map does not contain a (non-
null
) value for the resource
entry, such an entry is generated from the request URI and the
(optional) query string of the given request
.params
map or at least a single
resource
parameter are added to the
target path for the redirect. Each parameter value is encoded using the
java.net.URLEncoder
with UTF-8 encoding to make it safe for
requests
request
- The request object used to get the current request URI and
request query string if the params
map does not
have the resource
parameter set.response
- The response used to send the redirect to the client.target
- The target path to redirect the client to. This parameter
must not be prefixed with the request's context path because
this will be added by this method.params
- The map of parameters to be added to the target path. This
may be null
.
IOException
- If an error occurrs sending the redirect request
IllegalStateException
- If the response was committed or if a
partial URL is given and cannot be converted into a valid URL
InternalError
- If the UTF-8 character encoding is not supported by
the platform. This should not be caught, because it is a real
problem if the encoding required by the specification is
missing.public static boolean isValidateRequest(javax.servlet.http.HttpServletRequest request)
true
if the the client just asks for validation of
submitted username/password credentials.
This implementation returns true
if the request parameter
PAR_J_VALIDATE
is set to true
(case-insensitve). If
the request parameter is not set or to any value other than
true
this method returns false
.
request
- The request to provide the parameter to check
true
if the PAR_J_VALIDATE
parameter is set
to true
.public static void sendValid(javax.servlet.http.HttpServletResponse response)
response
- The response objectpublic static void sendInvalid(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
X_REASON
header.
response
- The response objectreason
- The reason to set on the header; not expected to be
null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |