Class CosmosAuthorizationHeaderFromUrl

  • All Implemented Interfaces:
    AdaptrisComponent, ComponentLifecycle, ComponentLifecycleExtension, MessageEventGenerator, Service, StateManagedComponent

    @ComponentProfile(summary="Builds an authorization header for Azure CosmosDB",
                      since="3.9.2",
                      tag="azure,cosmosdb,cosmos")
    public class CosmosAuthorizationHeaderFromUrl
    extends CosmosAuthorizationHeaderImpl
    Builds an authorization header for Azure CosmosDB from a URL.

    This differs from CosmosAuthorizationHeader in that it parses the URL for an appropriate ResourceID and ResourceType. Once it has figured out an appropriate resourceID and ResourceType it builds an instance of CosmosAuthorizationHeader and executes it. Note that if the URL convention changes for Azure CosmosDB, then this service may well generate an incorrect ResourceType/ResourceID; you may still need to use CosmosAuthorizationHeader directly.

    Given this example list of URLS; then then corresponding ResourceType / ResourceIDs will be generated. Essentially if the number of path fragments is even then the ResourceID is full path, and the ResourceType is the penultimate fragment; if the number of path fragments is odd then the ResourceID is everything up to the last / and the ResoucrceType is the last fragment.

    URL example ResourceType ResourceID
    https://azuredb.microsoft.com/ "" (the service will fail; since ResourceType must be set) ""
    https://azuredb.microsoft.com/dbs dbs ""
    https://azuredb.microsoft.com/dbs/tempdb/colls/tempcoll/docs docs dbs/tmpdb/colls/tempcoll
    https://azuredb.microsoft.com/dbs/tempdb/colls/tempcoll/docs/MyName docs dbs/tempdb/colls/tempcoll/docs/MyName
    https://azuredb.microsoft.com/dbs/tempdb/colls colls dbs/tempdb

    In the adapter configuration file this class is aliased as cosmosdb-authorization-header-from-url which is the preferred alternative to the fully qualified classname when building your configuration.