Creating a Digest Authentication Process Parent topic

To bypass the Digest Authentication Filter, you will need to use the following broker account credentials:
  • Broker account name
    This name is shown on the Broker Accounts screen of the Central Management Console under Name.
  • Digest passphrase
    This field is shown on the Edit Broker screen of the corresponding broker account.
  • Digest realm
    This credential is always the following fixed value: securecloud@trend.com
The following task shows how to create the digest authentication process that you must attach to every SecureCloud request.
Note
Note
Each of these programming tasks assumes that you are you are using a new programming code file. The examples shown are using Python programming language. Other programming languages, such as C++ or Java, are capable of performing the same requests.

Procedure

  1. Create variables for each part of the broker account information.
    These variables are as follows:
    • Broker account name
      In the example, this variable is digest_broker_account.
    • Digest passphrase
      In the example, this variable is digest_password.
    • Digest realm
      In the example, this variable is digest_realm.
    digest_broker_account = "test_digest_account"
    digest_password = "QTpYVL0QKI"
    digest_realm = "securecloud@trend.com"
  2. Add broker account information and the API URL to the password manager in the same function.
    The API URL is a variable that will be defined in each independent function. It is not defined generally here. In the example, this variable is api_url.
    pwd_mgr = urllib2.HTTPPasswordMgr()
    pwd_mgr.add_password(digest_realm, api_url, digest_broker_account, digest_password)
  3. Add the broker account information and the API URL to the API request handler.
    opener = urllib2.build_opener()
    opener.add_handler(urllib2.HTTPDigestAuthHandler(pwd_mgr))
  4. Request the API using the API URL.
    1. Set the API request data type as XML format.
    2. Include the broker account name in the header, defined as BrokerName.
    req = urllib2.Request(api_url)
    req.add_header('Content-Type', 'application/xml; charset=utf-8')
    req.add_header('BrokerName', digest_broker_account)
  5. Use this code directly in each part of the API request.
    The digest authentication process parts can be placed at varying locations in the request code, as long as the programming language does not encounter sequencing problems. Declare the API URL variable before calling API URL requests.

Sample Code Parent topic

Note
Note
The example shown here is merely a part of a total request. It will not execute properly by itself. It is possible to use this content as an independent function to be called in other requests.
The API URL is a variable that will be defined in each independent function. It is not defined generally here. In the example, this variable is api_url.
# Create variables for each part of the broker account information.                       
digest_broker_account = "test_digest_account"                       
digest_password = "QTpYVL0QKI"                       
digest_realm = "securecloud@trend.com"

# Add broker account information and the API URL to the password manager in the same function.                      
pwd_mgr = urllib2.HTTPPasswordMgr()
pwd_mgr.add_password(digest_realm, api_url, digest_broker_account, digest_password)

# Add the broker account information and the API URL to the API request handler.                       
opener = urllib2.build_opener()
opener.add_handler(urllib2.HTTPDigestAuthHandler(pwd_mgr))

# Request the API using the API URL.
req = urllib2.Request(api_url)
# Set the request data type to XML format.
req.add_header('Content-Type', 'application/xml; charset=utf-8')
# Include the broker account information in the header.
req.add_header('BrokerName', digest_broker_account)