Get a signed token

The Flash Runtime PSDK needs a signed token to validate that you have the right to call the PSDK API on the domain where your application resides.

  1. Get a signed token from your Adobe representative for each of your domains (where a domain could be for a specific domain or for a wildcard domain). To get a token, provide Adobe with either the domain where your application will be stored or loaded, or, preferably, the domain as a SHA256 hash. In return, Adobe provides you with a signed token for each domain. These tokens take one of these forms:
    • An .xml file acting as the token for a single domain or wildcard domain.
      Note: A token for a wildcard domain covers that domain and all of its subdomains. For example, a wildcard token for the domain mycompany.com would also cover vids.mycompany.com and private.vids.mycompany.com; a wildcard token for vids.mycompany.com would also cover private.vids.mycompany.com. Wildcard domain tokens are supported only for certain Flash Player versions.
    • A .swf file containing token information for multiple domains (not including wildcards), which your application can load dynamically.
  2. Store the token file in the same location or domain as your application. By default, the PSDK looks for the token in this location. Alternatively, you can specify the token's name and location in flash_vars in your HTML file.
  3. If your token file is a single XML file:
    1. Use the AuthorizedFeaturesHelper utility class to load the token and extract the authorizedFeatures information from it.

      This class includes the loadFrom method which, when invoked, downloads the data stored at the specified URL (the token file) and tries to extract authorizedFeatures objects from it.

      This step can vary. For example, you might want perform authentication before starting the application, or you might receive the token directly from your content management system (CMS).

    2. The PSDK dispatches a COMPLETE event if the load is successful or an ERROR event otherwise. Take appropriate action when you detect either event.

      This must be successful for your application to provide the required authorizedFeatures objects to the PSDK in the form of a MediaPlayerContext.

    This example shows how you could use a single-token .xml file.

    private function loadDirectTokenURL():void {
        var url:String = constructAuthorizedFeatureTokenURL();
        _logger.debug("#onApplicationComplete Loading token from [{0}].", url);
        _authorizedFeatureHelper = new AuthorizedFeaturesHelper();
        _authorizedFeatureHelper.addEventListener(Event.COMPLETE, onFeatureComplete);
        _authorizedFeatureHelper.addEventListener(ErrorEvent.ERROR, onFeatureError);
         _authorizedFeatureHelper.loadFrom(url);
     }
  4. If your token is a .swf file:
    1. Define a Loader class to dynamically load the .swf file.
    2. Set the LoaderContext to specify the loading to be in the current application domain, which allows the PSDK to choose the correct token within the .swf file. If LoaderContext is not specified, the default action of Loader.load is to load the .swf in the child domain of the current domain.
    3. Listen for the COMPLETE event, which the PSDK dispatches if the load is successful. Also listen for the ERROR event and take appropriate action.
    4. If the load is successful, use the AuthorizedFeaturesHelper to get a ByteArray that contains the PCKS-7 encoded security data. This data is used through AVE V11 API to get authorization acknowledgment from the Flash Runtime Player. If the byte array has no content, instead use the procedure to look for a single-domain token file.
    5. Use AuthorizedFeatureHelper.loadFeatureFromData to get the required data from the byte array.
    6. Unload the .swf file.

    This example shows how you could use a multiple-token .swf file.

    private function onApplicationComplete(event:FlexEvent):void {
            var url:String = constructAuthorizedFeatureTokenURLFromSwf();  
            _loader = new Loader();
            var swfUrl:URLRequest = new URLRequest(url);
            var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, modEventHandler);
            _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errEventHandler);
            _loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
            _loader.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtEventHandler);
            _logger.debug("# Loading token swf with context from [{0}].", url);
            _loader.load(swfUrl, loaderContext);
    }
     
    private function modEventHandler(e:Event):void {
            _logger.debug("loadSWF with domainID {0}", SecurityDomain.currentDomain.domainID);
            var loader : Loader = e.currentTarget.loader as Loader;
            var myAuthorizedTokensLoaderClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("AuthorizedTokensLoader") as Class;
            var myTokens:Object = new myAuthorizedTokensLoaderClass();
            _authorizedFeatureHelper = new AuthorizedFeaturesHelper();
            _authorizedFeatureHelper.addEventListener(Event.COMPLETE, onFeatureComplete);
            _authorizedFeatureHelper.addEventListener(ErrorEvent.ERROR, onFeatureError);
            var byteArray:ByteArray = myTokens.FetchToken(SecurityDomain.currentDomain.domainID);
            if (myTokens == null || byteArray == null || byteArray.length == 0)
                loadDirectTokenURL();
            else {
                _logger.debug("token bytearry size {0}", byteArray.length);
                _authorizedFeatureHelper.loadFeatureFromData(byteArray);
            }
            _loader.unload();
     }