Class RestHandler

java.lang.Object
org.cristalise.restapi.RestHandler
Direct Known Subclasses:
CookieLogin, CookieLogout, ItemUtils, PathUtils, RootAccess, TokenLogin

public abstract class RestHandler extends Object
  • Field Details

  • 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

      protected String encryptAuthData(RestHandler.AuthData auth)
      Parameters:
      auth -
      Returns:
    • toJSON

      public javax.ws.rs.core.Response.ResponseBuilder toJSON(Object data, javax.ws.rs.core.NewCookie cookie)
    • checkAndCreateNewCookie

      public javax.ws.rs.core.NewCookie checkAndCreateNewCookie(RestHandler.AuthData authData)
      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

      public javax.ws.rs.core.NewCookie createNewCookie(AgentPath agentPath)
    • createNewCookie

      public javax.ws.rs.core.NewCookie createNewCookie(RestHandler.AuthData authData)
    • getAgentPath

      public AgentPath getAgentPath(javax.ws.rs.core.Cookie authCookie)
      AgentPath is decrypted from the cookie
      Parameters:
      authCookie - the cookie sent by the client
      Returns:
      AgentPath decrypted from the cookie
    • checkAuthCookie

      public RestHandler.AuthData checkAuthCookie(javax.ws.rs.core.Cookie authCookie)
      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 Agent
      authCookie - the cookie sent by the client
      Throws:
      ObjectNotFoundException
    • getAgent

      public AgentProxy getAgent(String agentName, String authData) throws ObjectNotFoundException
      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 Agent
      authData - 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 URL
      start - the start index of the result set to be retrieved
      batchSize - the size of the result set to be retrieved
      totalRows - the total number of rows in the result set
      rows - the actual rows
      Returns:
      the Map containing all data describing a PagedResult
    • getPropertiesFromQParams

      public List<Property> getPropertiesFromQParams(String search)
      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

      protected Map<String,Object> makeItemDomainPathsData(ItemPath ip)
      Parameters:
      ip -