Package org.cristalise.restapi
Class RestHandler
java.lang.Object
org.cristalise.restapi.RestHandler
- Direct Known Subclasses:
CookieLogin,CookieLogout,ItemUtils,PathUtils,RootAccess,TokenLogin
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassHandles encoding/decoding of agent and timestamp data -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionjavax.ws.rs.core.NewCookiecheckAndCreateNewCookie(javax.ws.rs.core.Cookie authCookie) This method will check if authentication is 30seconds old, if true then it will return NewCookie.javax.ws.rs.core.NewCookiecheckAndCreateNewCookie(RestHandler.AuthData authData) This method will check if authentication is 30seconds old, if true then it will return NewCookie.checkAuthCookie(javax.ws.rs.core.Cookie authCookie) Authorisation data is decrypted from the cookiejavax.ws.rs.core.NewCookiecreateNewCookie(AgentPath agentPath) javax.ws.rs.core.NewCookiecreateNewCookie(RestHandler.AuthData authData) protected RestHandler.AuthDatadecryptAuthData(String authData) Tries to decrypt AuthData from the cookie string.protected StringAgentProxy is resolved either from authorisation data or from the name.AgentProxy is resolved either from cookie or from the name.getAgentPath(javax.ws.rs.core.Cookie authCookie) AgentPath is decrypted from the cookiegetPagedResult(javax.ws.rs.core.UriInfo uri, int start, int batchSize, int totalRows, List<?> rows) Constructs the Map containing all data describing a PagedResult.getPropertiesFromQParams(String search) Converts QueryParams to Item Propertiesjavax.ws.rs.core.Response.ResponseBuilder
-
Field Details
-
COOKIENAME
- See Also:
-
USERNAME
- See Also:
-
PASSWORD
- See Also:
-
-
Constructor Details
-
RestHandler
public RestHandler()
-
-
Method Details
-
decryptAuthData
protected RestHandler.AuthData decryptAuthData(String authData) throws InvalidItemPathException, InvalidDataException Tries to decrypt AuthData from the cookie string. It will make 5 attempts before throwing the exception. Check issue https://github.com/cristal-ise/restapi/issues/25- Parameters:
authData- the cookie string- Returns:
- the decypted
RestHandler.AuthData
-
encryptAuthData
- Parameters:
auth-- Returns:
-
toJSON
public javax.ws.rs.core.Response.ResponseBuilder toJSON(Object data, javax.ws.rs.core.NewCookie cookie) -
checkAndCreateNewCookie
This method will check if authentication is 30seconds old, if true then it will return NewCookie. Return null if not.- Parameters:
authData-- Returns:
- NewCookie
-
checkAndCreateNewCookie
public javax.ws.rs.core.NewCookie checkAndCreateNewCookie(javax.ws.rs.core.Cookie authCookie) This method will check if authentication is 30seconds old, if true then it will return NewCookie. Return null if not.- Parameters:
authCookie-- Returns:
- NewCookie
-
createNewCookie
-
createNewCookie
-
getAgentPath
AgentPath is decrypted from the cookie- Parameters:
authCookie- the cookie sent by the client- Returns:
- AgentPath decrypted from the cookie
-
checkAuthCookie
Authorisation data is decrypted from the cookie- Parameters:
authCookie- the cookie sent by the client- Returns:
- AuthData decrypted from the cookie
-
getAgent
public AgentProxy getAgent(String agentName, javax.ws.rs.core.Cookie authCookie) throws ObjectNotFoundException AgentProxy is resolved either from cookie or from the name. If property REST.requireLoginCookie=true the AgentProxy must be resolved from the authorisation data or an error is thrown.- Parameters:
agentName- the name of the AgentauthCookie- the cookie sent by the client- Throws:
ObjectNotFoundException
-
getAgent
AgentProxy is resolved either from authorisation data or from the name. If property REST.requireLoginCookie=true the AgentProxy must be resolved from the authorisation data or an error is thrown.- Parameters:
agentName- the name of the AgentauthData- authorisation data (from cookie or token)- Returns:
- AgentProxy
- Throws:
ObjectNotFoundException
-
getPagedResult
public Map<String,Object> getPagedResult(javax.ws.rs.core.UriInfo uri, int start, int batchSize, int totalRows, List<?> rows) Constructs the Map containing all data describing a PagedResult. Normally this result is converted to JSON- Parameters:
uri- The resource URI which is used to create pervPage and nextPage URLstart- the start index of the result set to be retrievedbatchSize- the size of the result set to be retrievedtotalRows- the total number of rows in the result setrows- the actual rows- Returns:
- the Map containing all data describing a PagedResult
-
getPropertiesFromQParams
Converts QueryParams to Item Properties- Parameters:
search- the string to decompose in the format: name,prop:val,prop:val- Returns:
- the decoded list of Item Properties
-
makeItemDomainPathsData
- Parameters:
ip-
-