Class WopiAccessHandler

java.lang.Object
org.imixs.workflow.wopi.WopiAccessHandler

@ApplicationScoped public class WopiAccessHandler extends Object
The WopiAccessHandler provides methods to generate 'access_token's and also computes the WOPI Client endpoints from the discovery URL.

The wopi client endpoint can be set by the environment variable WOPI_PUBLIC_ENDPOINT

Optional a discoveryEndpoint (WOPI_DISCOVERY_ENDPOINT) can be set to resolve the WOPI Client endpoints dynamically. In most cases this is not necessary and a wopi.public.endpoint can be set.

The method cacheFileData and fetchFileData are used to store a modified file object temporarily into the wopi local file cache.

Version:
1.0
Author:
rsoika
  • Constructor Details

    • WopiAccessHandler

      public WopiAccessHandler()
  • Method Details

    • cacheFileData

      public void cacheFileData(String accessToken, org.imixs.workflow.FileData fileData) throws IOException
      This method caches a fileData temporarily into the servers filesystem. The cached fileData is identified by the accesstoken+filename (with a hash value).

      The method also deletes outdated cached files.

      Parameters:
      jsessionid -
      file -
      Throws:
      IOException
    • fetchFileData

      public org.imixs.workflow.FileData fetchFileData(String accessToken, String filename)
      This method tries the fetch a file content from the local wopi file cache.

      If no cached file data exits, the method returns null.

      Parameters:
      accessToken -
      Returns:
      cached fileData object or null if no object was found for the given accessToken
      Throws:
      IOException
    • getAllFileData

      public List<org.imixs.workflow.FileData> getAllFileData(String accessToken)
      This method is called by the WopiController before a workitem is processed. The method returns all modified cached files in a list of FileData objects.
      Parameters:
      accessToken -
      Returns:
    • clearFileCache

      public void clearFileCache(String accessToken)
      Deletes all existing files cached for a given token.
      Parameters:
      accessToken -
    • generateAccessToken

      public String generateAccessToken(String userid, String username) throws org.imixs.jwt.JWTException
      Generates a new access token
      Returns:
      Throws:
      org.imixs.jwt.JWTException
    • validateAccessToken

      public jakarta.json.JsonObject validateAccessToken(String access_token)
      Validates if a given access_token is still valid.

      The method also clears the token form invalid query params. For some reasons Collabora sends additional query params starting with '?' which is not expected here!

      In case the token is valid, the method returns the paylod, otherwise the method returns null.

      Parameters:
      access_token -
      Returns:
      the token payload or null if the token is not valid
    • purgeAccessToken

      public String purgeAccessToken(String access_token)
      For some reason the LibreOffice Online adds additional query params starting with '?' into the access token, with is not expected. Thes helper method removes such parts of the token.
      Parameters:
      accesstoken -
      Returns:
      clean access token
    • getClientEndpointByFilename

      public String getClientEndpointByFilename(String filename)
      Returns a WOPI Client endpoint by a file extension

      If wopi.public.endpoint is set than this endpoint will be returned. If not the endpoint is resolved dynamically by the wopi.desovery.endpoint

      Parameters:
      ext -
      Returns:
    • getClientEndpointByMimeType

      public String getClientEndpointByMimeType(String mimeType)
      Returns a WOPI Client endpoint by a file mime type

      If wopi.public.endpoint is set than this endpoint will be returned. If not the endpoint is resolved dynamically by the wopi.desovery.endpoint

      Parameters:
      ext -
      Returns: