%SYS.MFT.Connection.Basepersistent class %SYS.MFT.Connection.Base
The file manager to be used by %MFT classes will be described by a persistent class whose properties
are stored in the CACHESYS database. This persistent file manager description will contain locations,
user name and authentication information - essentially the connection and authentication information
for the file management service.
The user of the file management API must create a persistent description of the connection to remote file management service. This connection is defined by the subclass of %SYS.MFT.Connection.Base which is implemented for the service provider being used.
The initially supported services all authenticate by using the OAuth 2.0 protocol. The file management connection will use OAuth 2.0 support to do the required authentication. An OAuth2 client must be configured for use by the connection. The details of the client are defined by the requirements of the specific vendor service. The ApplicationName property below is the application name for the OAuth2 client.
The %SYS.MFT.Connection>base class contains the base properties and methods for the remote file management services that we support. The %Admin_Secure will be required in order to open or save this object.
ApplicationName is the OAuth2 application name associated with this connection. The ConnectionId property will be used as the session id for the specific access token. property HttpRequest as %Net.HttpRequest [ Transient ];
Use the same %Net.HttpRequest object for all requests in the same session. property Name as %String(MAXLEN=64) [ Required ];
Name is the name of this connection to a file management service. Name serves as the IDKey for this class. property SSLConfiguration as %String(MAXLEN=64);
SSLConfiguration is the name of the SSL Configuration to be used to communicate with the file management API. property Service as %String [ InitialExpression = $piece($classname(),".",*) ];
Service is the name of the service that is accessed by this connection. property URL as %OAuth2.uri [ InitialExpression = ..DefaultURL() ];
URL is the base URL for REST access to this service including the final /. URL will default to the base URL for the remote file management service that is provided by the vendor. URL may be modified for locally hosted or private remote implementations. property Username as %Library.Username;
Username is the name of the user on whose behalf the file access will take place.
Create an OAuth 2.0 client with the parameters required to authorize. classmethod DefaultScope() as %String
name is the name to be given to the OAuth 2.0 client.
sslConfiguration is the SSLConfiguration used to make the HTTP request.
clientId and ClientSecret are the id and secret for the OAuth 2.0 client which is obtained from the corresponding App definition.
If addiitonal properties are needed, then the OAuth 2.0 client may be opened and modified.
If a server definition does not yet exist for the OAuth 2.0 client, then a new server definition is created.
The default scope to use for obtaining the access token. classmethod DefaultURL() as %String
Each subclass will define the DefaultURL method to supply the default URL for the service. classmethod DeleteId(name As %String, keepOAuth2 As %Boolean = 0) as %Status
The DeleteId method deletes an existing connection object specified by its name. If keepOAuth2 is true, then the associated OAuth 2.0 connection is deleted. Otherwise, the OAuth2 connection is kept. method GetAuthorizationCodeURL(redirect As %String, scope As %String, ByRef properties As %String, Output sc As %Status) as %String
Get the URL for use by authorization code grant type. method IsAuthorized(Output errorMessage As %String) as %Boolean
Check if this connection has been authorized. The default authorization is via OAuth 2.0 access token. method MakeHttpRequest(httpRequest As %Net.HttpRequest, method As %String, url As %String, reset As %Boolean = 1) as %Status
MakeHttpRequest will add authentication to the specified %Net.HttpRequest object and execute the request using the specified method with the specified REST parameters added to the URL. After the request is made, the authentication information is removed to avoid making this available to user code. method OAuth2ClientCount() as %Integer
Get count of connection which reference the specified OAuth 2.0 client. classmethod Open(name As %String, Output sc As %Status) as %SYS.MFT.Connection.Base
Open a %SYS.MFT.Connection.Base subclass instance based on the ConnectionName property. method RevokeToken() as %Status
Revoke the token associated with this connection. method Save() as %Status
The Save method saves a %SYS.MFT.Connection.Base object. To save a new Connection object use the following procedure:
- get a new object with %New of the appropriate subclass of %SYS.MFT.Connection.Base.
- set required unique Name property.
- set any needed properties.
- call the Save method.
The IDKEY for %SYS.MFT.Connection.Base is a unique user defined name.