Packagecom.esri.bao.tasks.authentication
Classpublic final class AuthenticationTask
InheritanceAuthenticationTask Inheritance AbstractTask Inheritance flash.events.EventDispatcher

The AuthenticationTask class is used to get a string-based response containing a short-lived token. This token, while valid, may be used in the token property of Community Analyst tasks inheriting from the BAOnlineTask class.

View the examples

See also

BAOnlineTask


Public Properties
 PropertyDefined By
 Inheritedconcurrency : String
Value that indicates how to handle multiple calls to the same task.
AbstractTask
 InheriteddisableClientCaching : Boolean
If true, adds a timestamp parameter ("_ts") to the REST request to prevent the request from being loaded from the browser's cache.
AbstractTask
 InheritedproxyURL : String
The URL to proxy the request through.
AbstractTask
 InheritedrequestTimeout : Number
The request timeout in seconds.
AbstractTask
 InheritedshowBusyCursor : Boolean
If true, a busy cursor is displayed while a service is executing.
AbstractTask
  token : String
[override] Authentication token received during the last execution of this task.
AuthenticationTask
 Inheritedurl : String
URL of the task.
AbstractTask
Public Methods
 MethodDefined By
  
AuthenticationTask(url:String)
Creates a new instance of the AuthenticationTask class.
AuthenticationTask
  
execute(username:String, password:String, responder:IResponder = null):AsyncToken
Sends a request to the authentication service for getting a short-lived authentication token.
AuthenticationTask
Events
 Event Summary Defined By
  The fault event is dispatched when an asynchronous execution of a Community Analyst Task fails.AuthenticationTask
  The taskCompleted event is dispatched when an asynchronous execution of a Community Analyst Task completes successfully.AuthenticationTask
Public Constants
 ConstantDefined By
  name : String = authentication
[static] Task name.
AuthenticationTask
Property Detail
tokenproperty
token:String[override]

Authentication token received during the last execution of this task.


Implementation
    public function get token():String
    public function set token(value:String):void
Constructor Detail
AuthenticationTask()Constructor
public function AuthenticationTask(url:String)

Creates a new instance of the AuthenticationTask class.

The base URL for the Community Analyst authentication Web Service looks as follows:

https://{host}:{port}

The {host} and {port} parameters in this URL should be substituted with valid Community Analyst host name and port, respectively.

If the base URL is null or empty, the "https://baoapi.esri.com" value is assigned as the base URL.

Parameters
url:String — The base URL to the Community Analyst REST Authentication Service.
Method Detail
execute()method
public function execute(username:String, password:String, responder:IResponder = null):AsyncToken

Sends a request to the authentication service for getting a short-lived authentication token.

A response can be received in two ways—in an optional responder object passed in parameters of this method and/or in listeners of fault and taskCompleted events registered for this task.

The responder is notified first when a response is received and parsed. Its fault method receives a parameter of the FaultEvent type and its result method receives a parameter of the BATaskCompletedEvent type whose result property contains the authentication token received. After that the received event is dispatched to the listeners of this task.

If response is succesfully received and parsed, a new authentication token is saved in the token property of this task.

Parameters

username:String — Valid Community Analyst REST API user name.
 
password:String — User password.
 
responder:IResponder (default = null) — A responder to call on result or fault.

Returns
AsyncToken — Asynch token associated with the response.
Event Detail
fault Event
Event Object Type: mx.rpc.events.FaultEvent
FaultEvent.type property = mx.rpc.events.FaultEvent.FAULT

The fault event is dispatched when an asynchronous execution of a Community Analyst Task fails.

taskCompleted Event  
Event Object Type: com.esri.bacore.BATaskCompletedEvent
BATaskCompletedEvent.type property = com.esri.bacore.BATaskCompletedEvent.COMPLETE

The taskCompleted event is dispatched when an asynchronous execution of a Community Analyst Task completes successfully.

The BATaskCompletedEvent.COMPLETE constant defines the value of the type property of the event object for a taskCompleted event.

The properties of the event object have the following values:

PropertyValue
babblesfalse
cancelablefalse
currentTargetThe Object that defines the event listener that handles the event.
targetThe BATask object that dispatched the event. This is an instance of a Community Analyst Task that was executed.
taskNameName of a Community Analyst Task that was executed.
resultTask execution result object.
messagesOptional array of TaskMessage objects received.

The currentTarget and target properties are specified after the event was dispatched. A responder object passed in parameters of a Community Analyst Task execute method receives the event before it is dispatched.

Constant Detail
nameConstant
public static const name:String = authentication

Task name.

Examples
ActionScript to get a string-based response containing a short-lived token. This token, while valid, may be used in the token property of Community Analyst tasks inheriting from the BAOnlineTask class.
                 
     var task:AuthenticationTask = new AuthenticationTask();
     
     // "https://baoapi.esri.com" is the default value for the AuthenticationTask url.
     //task.url = "https://baoapi.esri.com";
     
     task.execute(username, password, new Responder(resultHandler, faultHandler));