persistent 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.
as %Net.HttpRequest [ Transient ];
Use the same %Net.HttpRequest object for all requests in the same session.
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.
SSLConfiguration is the name of the SSL Configuration to be used to communicate with the file management API.
as %String [ InitialExpression = $piece($classname(),".",*) ];
Service is the name of the service that is accessed by this connection.
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.
Username is the name of the user on whose behalf the file access will take place.
classmethod CreateClient(name As %String, sslConfiguration As %String, clientId As %String, clientSecret As %String, issuer, host As %String, port As %Integer, prefix As %String, useSSL As %Boolean)
Create an OAuth 2.0 client with the parameters required to authorize.
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.
Each subclass will define the DefaultURL method to supply the default URL for the service.
classmethod DeleteId(name As %String, keepOAuth2 As %Boolean = 0)
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)
Get the URL for use by authorization code grant type.
method IsAuthorized(Output errorMessage As %String)
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)
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.
Get count of connection which reference the specified OAuth 2.0 client.
classmethod Open(name As %String, Output sc As %Status)
Open a %SYS.MFT.Connection.Base subclass instance based on the ConnectionName property.
Revoke the token associated with this connection.
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.
index (IDIndex on Name) [IdKey,Unique];
The IDKEY for %SYS.MFT.Connection.Base is a unique user defined name.