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 void clean()
public void setRequest(io.netty.handler.codec.http.HttpRequest request)
request
- public void setFromArgument(RestArgument source)
source
- public String getUri()
public String getBaseUri()
public Iterator<com.fasterxml.jackson.databind.JsonNode> getSubUri()
public int getSubUriSize()
public void addSubUriToUriArgs(String name, int rank)
public void addIdToUriArgs()
public com.fasterxml.jackson.databind.JsonNode getId()
public static com.fasterxml.jackson.databind.JsonNode getId(com.fasterxml.jackson.databind.node.ObjectNode node)
public long getLimitFromUri()
public String getXAuthKey()
public String getXAuthUser()
public String getXAuthTimestamp()
public void setXAuthRole(RoleDefault role)
public RoleDefault.ROLE getXAuthRole()
public com.fasterxml.jackson.databind.node.ObjectNode getUriArgs()
public HttpRestHandler.METHOD getMethod()
public void setHeaderArgs(List<Map.Entry<String,String>> list)
HttpIncorrectRequestException
public void setHeaderArgs(Iterator<Map.Entry<CharSequence,CharSequence>> iterator)
HttpIncorrectRequestException
public com.fasterxml.jackson.databind.node.ObjectNode getHeaderArgs()
public void methodFromUri()
public void methodFromHeader()
public void setCookieArgs(String cookieString)
public com.fasterxml.jackson.databind.node.ObjectNode getCookieArgs()
public com.fasterxml.jackson.databind.node.ObjectNode getBody()
public com.fasterxml.jackson.databind.node.ObjectNode getAnswer()
public void addAnswer(com.fasterxml.jackson.databind.node.ObjectNode node)
public void setResult(io.netty.handler.codec.http.HttpResponseStatus status)
public int getStatusCode()
public String getStatusMessage()
public void setDetail(String detail)
public String getDetail()
public void setCommand(DataModelRestMethodHandler.COMMAND_TYPE command)
public void setCommand(String cmd)
public String getCommandField()
public DataModelRestMethodHandler.COMMAND_TYPE getCommand()
public void addFilter(com.fasterxml.jackson.databind.node.ObjectNode filter)
filter
- the filter used in multi getpublic com.fasterxml.jackson.databind.node.ObjectNode getFilter()
public com.fasterxml.jackson.databind.node.ArrayNode getResults()
public void addResult(com.fasterxml.jackson.databind.node.ObjectNode result)
result
- added to the array of results (in DataModel multi
get)public void addCountLimit(long count, long limit)
count
- added to answer if > 0limit
- added to answerpublic long getCount()
public long getLimit()
public void addOptions(String allow, String path, com.fasterxml.jackson.databind.node.ArrayNode detailedAllow)
allow
- path
- detailedAllow
- public String getAllowOption()
public String getAllowUrisOption()
public 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 void checkTime(long maxInterval) throws HttpInvalidAuthenticationException
maxInterval
- HttpInvalidAuthenticationException
public 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 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–2020 Waarp. All rights reserved.