public class RemoteUserAuthServlet
extends javax.servlet.http.HttpServlet
Common usage allows for extraction of REMOTE_USER or a username from request attributes or headers.
More advanced features include the ability to directly consume a Subject from a request
attribute (in which case it is returned sight unseen directly to the IdP as the external result)
and the ability to check a header for strings containing authentication method identifiers which
can be mapped back into custom Principal objects (in which case they are attached to a newly
constructed Subject to return).
| Modifier and Type | Field and Description |
|---|---|
private static String |
AUTHN_AUTHORITY_HEADER_PARAM
Init parameter identifying a header to check for one or more proxied authenticating authority strings.
|
private static String |
AUTHN_METHOD_HEADER_PARAM
Init parameter identifying a header to check for one or more authentication method strings.
|
private String |
authnAuthorityHeader
Header to check for proxied authenticating authority strings.
|
private String |
authnMethodHeader
Header to check for authentication method strings.
|
private static String |
CHECK_ATTRIBUTES_PARAM
Init parameter controlling what attributes to check.
|
private static String |
CHECK_HEADERS_PARAM
Init parameter controlling what headers to check.
|
private static String |
CHECK_REMOTE_USER_PARAM
Init parameter controlling whether to check for REMOTE_USER.
|
private Collection<String> |
checkAttributes
List of request attributes to check for an identity.
|
private Collection<String> |
checkHeaders
List of request headers to check for an identity.
|
private boolean |
checkRemoteUser
Whether to check REMOTE_USER for an identity.
|
private org.slf4j.Logger |
log
Class logger.
|
private static long |
serialVersionUID
Serial UID.
|
private static String |
SUBJECT_ATTRIBUTE_PARAM
Init parameter identifying an attribute to check for a Subject.
|
private String |
subjectAttribute
Request attribute to check for a
Subject. |
| Constructor and Description |
|---|
RemoteUserAuthServlet()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
AuthenticationFlowDescriptor |
getAuthenticationFlowDescriptor(String key,
javax.servlet.http.HttpServletRequest httpRequest)
Get the executing
AuthenticationFlowDescriptor. |
Principal |
getPrincipal(AuthenticationFlowDescriptor descriptor,
String method)
Locate a custom
Principal matching a string, supported by the flow descriptor. |
void |
init(javax.servlet.ServletConfig config) |
protected void |
service(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse) |
void |
setAuthnAuthorityHeader(String header)
Set the name of a request header to check for authenticating authority strings.
|
void |
setAuthnMethodHeader(String header)
Set the name of a request header to check for authentication method strings.
|
void |
setCheckAttributes(Collection<String> attributes)
Set the list of request attributes to check for an identity.
|
void |
setCheckHeaders(Collection<String> headers)
Set the list of request headers to check for an identity.
|
void |
setCheckRemoteUser(boolean flag)
Set whether to check REMOTE_USER for an identity.
|
void |
setSubjectAttribute(String attribute)
Set the name of a request attribute to check for a
Subject. |
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, serviceprivate static final long serialVersionUID
@Nonnull @NotEmpty private static final String CHECK_REMOTE_USER_PARAM
@Nonnull @NotEmpty private static final String CHECK_ATTRIBUTES_PARAM
@Nonnull @NotEmpty private static final String CHECK_HEADERS_PARAM
@Nonnull @NotEmpty private static final String SUBJECT_ATTRIBUTE_PARAM
@Nonnull @NotEmpty private static final String AUTHN_METHOD_HEADER_PARAM
@Nonnull @NotEmpty private static final String AUTHN_AUTHORITY_HEADER_PARAM
@Nonnull private final org.slf4j.Logger log
private boolean checkRemoteUser
@Nonnull @NonnullElements private Collection<String> checkAttributes
@Nonnull @NonnullElements private Collection<String> checkHeaders
@Nullable @NotEmpty private String subjectAttribute
Subject.@Nullable @NotEmpty private String authnMethodHeader
public void setCheckRemoteUser(boolean flag)
flag - value to setpublic void setCheckAttributes(@Nonnull@NonnullElements Collection<String> attributes)
attributes - list of request attributes to checkpublic void setCheckHeaders(@Nonnull@NonnullElements Collection<String> headers)
headers - list of request headers to checkpublic void setSubjectAttribute(@Nullable@NotEmpty String attribute)
Subject.attribute - request attribute namepublic void setAuthnMethodHeader(@Nullable@NotEmpty String header)
header - request header namepublic void setAuthnAuthorityHeader(@Nullable@NotEmpty String header)
header - request header namepublic void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
init in interface javax.servlet.Servletinit in class javax.servlet.GenericServletjavax.servlet.ServletExceptionprotected void service(javax.servlet.http.HttpServletRequest httpRequest,
javax.servlet.http.HttpServletResponse httpResponse)
throws javax.servlet.ServletException,
IOException
service in class javax.servlet.http.HttpServletjavax.servlet.ServletExceptionIOException@Nullable public AuthenticationFlowDescriptor getAuthenticationFlowDescriptor(@Nonnull@NotEmpty String key, @Nonnull javax.servlet.http.HttpServletRequest httpRequest) throws ExternalAuthenticationException
AuthenticationFlowDescriptor.key - external authentication keyhttpRequest - servlet requestExternalAuthenticationException - if unable to access the profile context@Nullable public Principal getPrincipal(@Nonnull AuthenticationFlowDescriptor descriptor, @Nonnull@NotEmpty String method)
Principal matching a string, supported by the flow descriptor.descriptor - flow descriptormethod - method stringPrincipal or nullCopyright © 1999–2018 Shibboleth Consortium. All rights reserved.