public class S3Handler extends Object
Modifier and Type | Field and Description |
---|---|
static Pattern |
BUCKET_ADJACENT_DOTS_DASHES_PATTERN |
static Pattern |
BUCKET_INVALID_SUFFIX_PATTERN |
static Pattern |
BUCKET_INVALIDATION_PREFIX_PATTERN |
static boolean |
BUCKET_NAMING_RESTRICTION_ENABLED |
static Pattern |
BUCKET_PATH_PATTERN |
static Pattern |
BUCKET_VALID_NAME_PATTERN |
AsyncUserAccessAuditLogWriter |
mAsyncAuditLogWriter |
static int |
MAX_HEADER_METADATA_SIZE |
static boolean |
MULTIPART_CLEANER_ENABLED |
static Pattern |
OBJECT_PATH_PATTERN |
Constructor and Description |
---|
S3Handler(String bucket,
String object,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
S3Handler Constructor.
|
Modifier and Type | Method and Description |
---|---|
S3AuditContext |
createAuditContext(String command,
String user,
String bucket,
String object)
Creates a
S3AuditContext instance. |
static S3Handler |
createHandler(String path,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Create a S3Handler based on the incoming Request.
|
void |
doAuthentication()
Do S3 request authentication.
|
void |
extractAMZHeaders()
Utility function to help extract x-amz- headers from request.
|
String |
getBucket()
Get the bucket name of this request.
|
String |
getHeader(String headerName)
get specified HTTP header value of this request.
|
String |
getHeaderOrDefault(String headerName,
String defaultHeaderValue)
get specified HTTP header with a default if not exist.
|
String |
getHTTPVerb()
get HTTP verb of this request.
|
javax.servlet.ServletInputStream |
getInputStream()
retrieve inputstream from incoming request.
|
FileSystem |
getMetaFS()
Get system user FileSystem object.
|
String |
getObject()
Get the object name of this request.
|
String |
getQueryParameter(String queryParam)
retrieve given query parameter value.
|
S3BaseTask |
getS3Task()
get S3Task of this S3Handler.
|
javax.servlet.ServletContext |
getServletContext()
get ServletContext from current http conversation.
|
javax.servlet.http.HttpServletRequest |
getServletRequest()
get HttpServletRequest of this request.
|
javax.servlet.http.HttpServletResponse |
getServletResponse()
get HttpServletResponse of this request.
|
com.google.common.base.Stopwatch |
getStopwatch()
Get Stopwatch object used for recording this request's latency.
|
String |
getUser()
Get the user name of this request.
|
void |
init()
Initialize the S3Handler object in preparation for handling the request.
|
String |
printCollection(String prefix,
Collection<? extends Object> collection)
Utility function to dump a collection into a string.
|
String |
printMap(String prefix,
Map<? extends Object,? extends Object> map)
Utility function to dump a map into a string.
|
static void |
processResponse(javax.servlet.http.HttpServletResponse servletResponse,
javax.ws.rs.core.Response response)
Process the response returned from S3Task core logic to write to downstream.
|
void |
rejectUnsupportedResources()
Reject unsupported request from the given subresources from request.
|
void |
setS3Task(S3BaseTask task)
set S3Task for this S3Handler.
|
void |
setStopwatch(com.google.common.base.Stopwatch stopwatch)
Set the Stopwatch object used for recording this request's latency.
|
public static final boolean BUCKET_NAMING_RESTRICTION_ENABLED
public static final int MAX_HEADER_METADATA_SIZE
public static final boolean MULTIPART_CLEANER_ENABLED
public static final Pattern BUCKET_ADJACENT_DOTS_DASHES_PATTERN
public static final Pattern BUCKET_INVALIDATION_PREFIX_PATTERN
public static final Pattern BUCKET_INVALID_SUFFIX_PATTERN
public static final Pattern BUCKET_VALID_NAME_PATTERN
public static final Pattern BUCKET_PATH_PATTERN
public static final Pattern OBJECT_PATH_PATTERN
public AsyncUserAccessAuditLogWriter mAsyncAuditLogWriter
public static S3Handler createHandler(String path, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
path
- request
- response
- Exception
public static void processResponse(javax.servlet.http.HttpServletResponse servletResponse, javax.ws.rs.core.Response response) throws IOException
servletResponse
- response
- IOException
public void init() throws Exception
Exception
public S3BaseTask getS3Task()
public void setS3Task(S3BaseTask task)
task
- public String getHTTPVerb()
public String getHeader(String headerName)
headerName
- public String getHeaderOrDefault(String headerName, String defaultHeaderValue)
headerName
- defaultHeaderValue
- public javax.servlet.http.HttpServletResponse getServletResponse()
public javax.servlet.http.HttpServletRequest getServletRequest()
public javax.servlet.ServletContext getServletContext()
public String getQueryParameter(String queryParam)
queryParam
- public javax.servlet.ServletInputStream getInputStream() throws IOException
IOException
public S3AuditContext createAuditContext(String command, String user, @Nullable String bucket, @Nullable String object)
S3AuditContext
instance.command
- the command to be logged by this S3AuditContext
user
- user namebucket
- bucket nameobject
- object nameS3AuditContext
instancepublic String printCollection(String prefix, Collection<? extends Object> collection)
prefix
- collection
- public String printMap(String prefix, Map<? extends Object,? extends Object> map)
prefix
- map
- public void extractAMZHeaders()
public void rejectUnsupportedResources() throws S3Exception
S3Exception
public void doAuthentication() throws Exception
Exception
public String getUser()
public String getBucket()
public String getObject()
public FileSystem getMetaFS()
public com.google.common.base.Stopwatch getStopwatch()
public void setStopwatch(com.google.common.base.Stopwatch stopwatch)
stopwatch
- Copyright © 2023. All Rights Reserved.