public class RestArgument extends Object
Modifier and Type | Class and Description |
---|---|
static class |
RestArgument.DATAMODEL |
static class |
RestArgument.REST_FIELD |
static class |
RestArgument.REST_GROUP |
static class |
RestArgument.REST_ROOT_FIELD |
Constructor and Description |
---|
RestArgument(com.fasterxml.jackson.databind.node.ObjectNode emptyArgument)
Create a RestArgument
|
Modifier and Type | Method and Description |
---|---|
void |
addAnswer(com.fasterxml.jackson.databind.node.ObjectNode node) |
void |
addCountLimit(long count,
long limit) |
void |
addFilter(com.fasterxml.jackson.databind.node.ObjectNode filter) |
void |
addIdToUriArgs() |
void |
addOptions(String allow,
String path,
com.fasterxml.jackson.databind.node.ArrayNode detailedAllow)
Add options in answer
|
void |
addResult(com.fasterxml.jackson.databind.node.ObjectNode result) |
void |
addSubUriToUriArgs(String name,
int rank) |
void |
checkBaseAuthent(HmacSha256 hmacSha256,
String extraKey,
long maxInterval)
This implementation of authentication is as follow: if X_AUTH is included
in the URI or Header
0) Check that timestamp is correct (|curtime - timestamp| < maxinterval) from ARG_X_AUTH_TIMESTAMP, if maxInterval is 0, not mandatory 1) Get all URI args (except ARG_X_AUTH_KEY itself, but including timestamp), lowered case, in alphabetic order 2) Add an extra Key if not null (from ARG_X_AUTH_INTERNALKEY) 3) Compute an hash (SHA-1 or SHA-256) 4) Compare this hash with ARG_X_AUTH_KEY |
void |
checkTime(long maxInterval)
Check Time only (no signature)
|
void |
clean()
Clean all internal values
|
protected static String |
computeKey(HmacSha256 hmacSha256,
String extraKey,
TreeMap<String,String> treeMap,
String argPath) |
static com.fasterxml.jackson.databind.node.ObjectNode |
fillDetailedAllow(HttpRestHandler.METHOD method,
String path,
String command,
com.fasterxml.jackson.databind.node.ObjectNode body,
com.fasterxml.jackson.databind.JsonNode result) |
String |
getAllowOption() |
String |
getAllowUrisOption() |
com.fasterxml.jackson.databind.node.ObjectNode |
getAnswer() |
static String[] |
getBaseAuthent(HmacSha256 hmacSha256,
io.netty.handler.codec.http.QueryStringEncoder encoder,
String user,
String extraKey)
The encoder is completed with extra necessary URI part containing
ARG_X_AUTH_TIMESTAMP & ARG_X_AUTH_KEY
|
String |
getBaseUri() |
com.fasterxml.jackson.databind.node.ObjectNode |
getBody() |
DataModelRestMethodHandler.COMMAND_TYPE |
getCommand() |
String |
getCommandField() |
com.fasterxml.jackson.databind.node.ObjectNode |
getCookieArgs() |
long |
getCount() |
String |
getDetail() |
com.fasterxml.jackson.databind.node.ArrayNode |
getDetailedAllowOption() |
com.fasterxml.jackson.databind.node.ObjectNode |
getFilter() |
com.fasterxml.jackson.databind.node.ObjectNode |
getHeaderArgs() |
com.fasterxml.jackson.databind.JsonNode |
getId() |
static com.fasterxml.jackson.databind.JsonNode |
getId(com.fasterxml.jackson.databind.node.ObjectNode node) |
long |
getLimit() |
long |
getLimitFromUri() |
HttpRestHandler.METHOD |
getMethod() |
com.fasterxml.jackson.databind.node.ArrayNode |
getResults() |
int |
getStatusCode() |
String |
getStatusMessage() |
Iterator<com.fasterxml.jackson.databind.JsonNode> |
getSubUri() |
int |
getSubUriSize() |
String |
getUri() |
com.fasterxml.jackson.databind.node.ObjectNode |
getUriArgs() |
String |
getXAuthKey() |
RoleDefault.ROLE |
getXAuthRole() |
String |
getXAuthTimestamp() |
String |
getXAuthUser() |
void |
methodFromHeader()
set method From Header
|
void |
methodFromUri()
set method From URI
|
String |
prettyPrint() |
void |
setCommand(DataModelRestMethodHandler.COMMAND_TYPE command) |
void |
setCommand(String cmd) |
void |
setCookieArgs(String cookieString)
set values from Cookies into arguments.path(ARGS_COOKIE)
|
void |
setDetail(String detail) |
void |
setFromArgument(RestArgument source)
Set X_AUTH_USER, Method, Path, Basepath and Cookie from source
|
void |
setHeaderArgs(Iterator<Map.Entry<CharSequence,CharSequence>> iterator)
set values from Header into arguments.path(ARGS_HEADER)
|
void |
setHeaderArgs(List<Map.Entry<String,String>> list)
set values from Header into arguments.path(ARGS_HEADER)
|
void |
setRequest(io.netty.handler.codec.http.HttpRequest request)
Set values according to the request URI
|
void |
setResult(io.netty.handler.codec.http.HttpResponseStatus status) |
void |
setXAuthRole(RoleDefault role) |
String |
toString() |
public RestArgument(com.fasterxml.jackson.databind.node.ObjectNode emptyArgument)
emptyArgument
- might be null, but might be also already
initialized with some valuespublic final void clean()
public final void setRequest(io.netty.handler.codec.http.HttpRequest request)
request
- public final void setFromArgument(RestArgument source)
source
- public final String getUri()
public final String getBaseUri()
public final Iterator<com.fasterxml.jackson.databind.JsonNode> getSubUri()
public final int getSubUriSize()
public final void addSubUriToUriArgs(String name, int rank)
public final void addIdToUriArgs()
public final com.fasterxml.jackson.databind.JsonNode getId()
public static com.fasterxml.jackson.databind.JsonNode getId(com.fasterxml.jackson.databind.node.ObjectNode node)
public final long getLimitFromUri()
public final String getXAuthKey()
public final String getXAuthUser()
public final String getXAuthTimestamp()
public final void setXAuthRole(RoleDefault role)
public final RoleDefault.ROLE getXAuthRole()
public final com.fasterxml.jackson.databind.node.ObjectNode getUriArgs()
public final HttpRestHandler.METHOD getMethod()
public final void setHeaderArgs(List<Map.Entry<String,String>> list)
HttpIncorrectRequestException
public final void setHeaderArgs(Iterator<Map.Entry<CharSequence,CharSequence>> iterator)
HttpIncorrectRequestException
public final com.fasterxml.jackson.databind.node.ObjectNode getHeaderArgs()
public final void methodFromUri()
public final void methodFromHeader()
public final void setCookieArgs(String cookieString)
public final com.fasterxml.jackson.databind.node.ObjectNode getCookieArgs()
public final com.fasterxml.jackson.databind.node.ObjectNode getBody()
public final com.fasterxml.jackson.databind.node.ObjectNode getAnswer()
public final void addAnswer(com.fasterxml.jackson.databind.node.ObjectNode node)
public final void setResult(io.netty.handler.codec.http.HttpResponseStatus status)
public final int getStatusCode()
public final String getStatusMessage()
public final void setDetail(String detail)
public final String getDetail()
public final void setCommand(DataModelRestMethodHandler.COMMAND_TYPE command)
public final void setCommand(String cmd)
public final String getCommandField()
public final DataModelRestMethodHandler.COMMAND_TYPE getCommand()
public final void addFilter(com.fasterxml.jackson.databind.node.ObjectNode filter)
filter
- the filter used in multi getpublic final com.fasterxml.jackson.databind.node.ObjectNode getFilter()
public final com.fasterxml.jackson.databind.node.ArrayNode getResults()
public final void addResult(com.fasterxml.jackson.databind.node.ObjectNode result)
result
- added to the array of results (in DataModel multi
get)public final void addCountLimit(long count, long limit)
count
- added to answer if > 0limit
- added to answerpublic final long getCount()
public final long getLimit()
public final void addOptions(String allow, String path, com.fasterxml.jackson.databind.node.ArrayNode detailedAllow)
allow
- path
- detailedAllow
- public final String getAllowOption()
public final String getAllowUrisOption()
public final com.fasterxml.jackson.databind.node.ArrayNode getDetailedAllowOption()
public static String[] getBaseAuthent(HmacSha256 hmacSha256, io.netty.handler.codec.http.QueryStringEncoder encoder, String user, String extraKey) throws HttpInvalidAuthenticationException
hmacSha256
- SHA-256 key to create the signatureencoder
- user
- might be nullextraKey
- might be nullHttpInvalidAuthenticationException
- if the computation of
the
authentication failedpublic final void checkTime(long maxInterval) throws HttpInvalidAuthenticationException
maxInterval
- HttpInvalidAuthenticationException
public final void checkBaseAuthent(HmacSha256 hmacSha256, String extraKey, long maxInterval) throws HttpInvalidAuthenticationException
hmacSha256
- SHA-256 key to create the signatureextraKey
- will be added as ARG_X_AUTH_INTERNALKEY might be
nullmaxInterval
- ARG_X_AUTH_TIMESTAMP will be tested if value >
0HttpInvalidAuthenticationException
- if the authentication
failedprotected static String computeKey(HmacSha256 hmacSha256, String extraKey, TreeMap<String,String> treeMap, String argPath) throws HttpInvalidAuthenticationException
hmacSha256
- SHA-256 key to create the signatureextraKey
- might be nulltreeMap
- argPath
- HttpInvalidAuthenticationException
public final String prettyPrint()
public static com.fasterxml.jackson.databind.node.ObjectNode fillDetailedAllow(HttpRestHandler.METHOD method, String path, String command, com.fasterxml.jackson.databind.node.ObjectNode body, com.fasterxml.jackson.databind.JsonNode result)
Copyright © 2009–2022 Waarp. All rights reserved.