Package org.nuxeo.wopi
Class WOPIServiceImpl
- java.lang.Object
-
- org.nuxeo.runtime.model.DefaultComponent
-
- org.nuxeo.wopi.WOPIServiceImpl
-
- All Implemented Interfaces:
Adaptable
,Component
,Extensible
,TimestampedService
,WOPIService
public class WOPIServiceImpl extends DefaultComponent implements WOPIService
- Since:
- 10.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
WOPIServiceImpl.WOPIDiscoveryInvalidation
class
WOPIServiceImpl.WOPIDiscoveryInvalidator
-
Field Summary
Fields Modifier and Type Field Description protected CheckFileInfoUpdater
checkFileInfoUpdater
protected String
discoveryURL
static String
DOWNLOAD_REASON
protected Map<String,Map<String,String>>
extensionActionURLs
protected Map<String,String>
extensionAppNames
protected WOPIServiceImpl.WOPIDiscoveryInvalidator
invalidator
protected PublicKey
oldProofKey
static String
PLACEHOLDER_IS_LICENSED_USER
static String
PLACEHOLDER_IS_LICENSED_USER_VALUE
protected PublicKey
proofKey
static String
SUPPORTED_APP_NAMES_PROPERTY_KEY
protected static String
WOPI_DISCOVERY_INVAL_PUBSUB_TOPIC
static String
WOPI_PROPERTY_NAMESPACE
static String
XP_CHECK_FILE_INFO_UPDATER
-
Fields inherited from class org.nuxeo.runtime.model.DefaultComponent
lastModified, name
-
-
Constructor Summary
Constructors Constructor Description WOPIServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected org.apache.http.impl.client.CloseableHttpClient
buildHttpClient()
boolean
checkDownloadBlob(DocumentModel doc, String xpath, Blob blob)
Checks whether the download of the blob is allowed.protected void
configureProxy(org.apache.http.impl.client.HttpClientBuilder builder)
protected byte[]
fetchDiscovery()
protected void
fireRefreshDiscovery()
String
getActionURL(Blob blob, String action)
Returns the WOPI action url given ablob
and anaction
.protected byte[]
getDiscovery()
protected String
getExtension(Blob blob)
protected KeyValueStore
getKeyValueStore()
protected List<String>
getSupportedAppNames()
WOPIBlobInfo
getWOPIBlobInfo(Blob blob)
Returns aWOPIBlobInfo
for the given blob if it is supported by WOPI,null
otherwise.protected boolean
hasDiscoveryURL()
boolean
isEnabled()
Returns @{code true} if WOPI is enabled,false
otherwise.boolean
isSupported(Blob blob)
Returnstrue
if the givenblob
is supported by WOPI,false
otherwise.protected void
loadDiscovery()
protected boolean
loadDiscovery(byte[] discoveryBytes)
boolean
refreshDiscovery()
Refreshes the WOPI discovery: fetches the data from the discovery URL, stores it and loads it in memory.protected void
registerApp(WOPIDiscovery.App app)
protected void
registerInvalidator()
void
start(ComponentContext context)
Start the component.void
stop(ComponentContext context)
Stop the component.protected void
storeDiscovery(byte[] discoveryBytes)
protected void
unregisterInvalidator()
Map<String,Serializable>
updateCheckFileInfoProperties(Map<String,Serializable> checkFileInfoProperties)
boolean
verifyProofKey(String proofKeyHeader, String oldProofKeyHeader, String url, String accessToken, String timestampHeader)
Verifies that the request originate from Office Online.-
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, addRuntimeMessage, addRuntimeMessage, deactivate, getAdapter, getDescriptor, getDescriptors, getLastModified, getRegistry, register, registerContribution, registerExtension, setLastModified, setModifiedNow, setName, unregister, unregisterContribution, unregisterExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.runtime.model.Component
applicationStarted, getApplicationStartedOrder
-
-
-
-
Field Detail
-
XP_CHECK_FILE_INFO_UPDATER
public static final String XP_CHECK_FILE_INFO_UPDATER
- See Also:
- Constant Field Values
-
PLACEHOLDER_IS_LICENSED_USER
public static final String PLACEHOLDER_IS_LICENSED_USER
- See Also:
- Constant Field Values
-
PLACEHOLDER_IS_LICENSED_USER_VALUE
public static final String PLACEHOLDER_IS_LICENSED_USER_VALUE
- See Also:
- Constant Field Values
-
WOPI_PROPERTY_NAMESPACE
public static final String WOPI_PROPERTY_NAMESPACE
- See Also:
- Constant Field Values
-
SUPPORTED_APP_NAMES_PROPERTY_KEY
public static final String SUPPORTED_APP_NAMES_PROPERTY_KEY
- See Also:
- Constant Field Values
-
DOWNLOAD_REASON
public static final String DOWNLOAD_REASON
- See Also:
- Constant Field Values
-
WOPI_DISCOVERY_INVAL_PUBSUB_TOPIC
protected static final String WOPI_DISCOVERY_INVAL_PUBSUB_TOPIC
- See Also:
- Constant Field Values
-
proofKey
protected PublicKey proofKey
-
oldProofKey
protected PublicKey oldProofKey
-
discoveryURL
protected String discoveryURL
-
invalidator
protected WOPIServiceImpl.WOPIDiscoveryInvalidator invalidator
-
checkFileInfoUpdater
protected CheckFileInfoUpdater checkFileInfoUpdater
-
-
Method Detail
-
start
public void start(ComponentContext context)
Description copied from interface:Component
Start the component. This method is called after all the components were resolved and activated- Specified by:
start
in interfaceComponent
- Overrides:
start
in classDefaultComponent
-
stop
public void stop(ComponentContext context)
Description copied from interface:Component
Stop the component.- Specified by:
stop
in interfaceComponent
- Overrides:
stop
in classDefaultComponent
-
hasDiscoveryURL
protected boolean hasDiscoveryURL()
-
registerInvalidator
protected void registerInvalidator()
-
unregisterInvalidator
protected void unregisterInvalidator()
-
loadDiscovery
protected void loadDiscovery()
-
loadDiscovery
protected boolean loadDiscovery(byte[] discoveryBytes)
-
fireRefreshDiscovery
protected void fireRefreshDiscovery()
-
registerApp
protected void registerApp(WOPIDiscovery.App app)
-
isEnabled
public boolean isEnabled()
Description copied from interface:WOPIService
Returns @{code true} if WOPI is enabled,false
otherwise.The WOPI discovery XML file has been loaded.
- Specified by:
isEnabled
in interfaceWOPIService
-
getWOPIBlobInfo
public WOPIBlobInfo getWOPIBlobInfo(Blob blob)
Description copied from interface:WOPIService
Returns aWOPIBlobInfo
for the given blob if it is supported by WOPI,null
otherwise.- Specified by:
getWOPIBlobInfo
in interfaceWOPIService
-
isSupported
public boolean isSupported(Blob blob)
Description copied from interface:WOPIService
Returnstrue
if the givenblob
is supported by WOPI,false
otherwise.This method relies on checking that the blob's filename extension is supported by the WOPI discovery.
- Specified by:
isSupported
in interfaceWOPIService
-
getActionURL
public String getActionURL(Blob blob, String action)
Description copied from interface:WOPIService
Returns the WOPI action url given ablob
and anaction
.- Specified by:
getActionURL
in interfaceWOPIService
-
verifyProofKey
public boolean verifyProofKey(String proofKeyHeader, String oldProofKeyHeader, String url, String accessToken, String timestampHeader)
Description copied from interface:WOPIService
Verifies that the request originate from Office Online.- Specified by:
verifyProofKey
in interfaceWOPIService
-
refreshDiscovery
public boolean refreshDiscovery()
Description copied from interface:WOPIService
Refreshes the WOPI discovery: fetches the data from the discovery URL, stores it and loads it in memory.- Specified by:
refreshDiscovery
in interfaceWOPIService
- Returns:
true
if refreshing the discovery has succeeded,false
otherwise
-
fetchDiscovery
protected byte[] fetchDiscovery()
-
buildHttpClient
protected org.apache.http.impl.client.CloseableHttpClient buildHttpClient()
-
configureProxy
protected void configureProxy(org.apache.http.impl.client.HttpClientBuilder builder)
-
getDiscovery
protected byte[] getDiscovery()
-
storeDiscovery
protected void storeDiscovery(byte[] discoveryBytes)
-
getKeyValueStore
protected KeyValueStore getKeyValueStore()
-
checkDownloadBlob
public boolean checkDownloadBlob(DocumentModel doc, String xpath, Blob blob)
Description copied from interface:WOPIService
Checks whether the download of the blob is allowed.- Specified by:
checkDownloadBlob
in interfaceWOPIService
- Returns:
true
if download is allowed
-
updateCheckFileInfoProperties
public Map<String,Serializable> updateCheckFileInfoProperties(Map<String,Serializable> checkFileInfoProperties)
- Specified by:
updateCheckFileInfoProperties
in interfaceWOPIService
-
-