Packagecom.adobe.photoshop.connection
Classpublic class KevlarConnection
InheritanceKevlarConnection Inheritance flash.events.EventDispatcher

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

This Kevlar connection class sets up encryption and handles socket transmission of data and messages to and from Photoshop.



Public Methods
 MethodDefined By
  
Constructor.
KevlarConnection
  
connect(serverName:String, serverPort:int = 49494):void
Opens a Kevlar data connection to Photoshop.
KevlarConnection
  
disconnect():void
Disconnects the connection to Photoshop
KevlarConnection
  
encryptAndSendData(data:ByteArray):Boolean
Will both encrypt and send data to Photoshop.
KevlarConnection
  
encryptData(data:ByteArray):Boolean
Encrypts data such that Photoshop will be able to decrypt it.
KevlarConnection
  
initEncryption(password:String = Swordfish, salt:String = Adobe Photoshop, numIterations:int = 1000, numBytes:int = 24):void
Derives the key necessary for all communication with Photoshop.
KevlarConnection
  
sendDatagram(data:ByteArray):Boolean
Sends raw data to Photoshop, without encrypting it or wrapping it in a properly formatted message.
KevlarConnection
Events
 Event Summary Defined By
  Dispatched when the connection to Photoshop has been establishedKevlarConnection
  Dispatched when the connection is terminatedKevlarConnection
  Dispatched when the key has been encrypted, and the connection is ready to send and receive data.KevlarConnection
  Dispatched when there's been an error in either data transfer, encryption, or connection management.KevlarConnection
  Dispatched when the connection has received an imageKevlarConnection
  Dispatched when a message is received from Photoshop.KevlarConnection
  Dispatched when a message is sent to Photoshop.KevlarConnection
  Dispatched when there is progress in parsing a response or sending a message.KevlarConnection
Public Constants
 ConstantDefined By
  KEVLAR_CONNECTION_API_VERSION : int = 1
[static] The Kevlar API version that this code supports
KevlarConnection
Constructor Detail
KevlarConnection()Constructor
public function KevlarConnection()

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Constructor. Creates a new Kevlar connection. No connection is attempted in this function, nor is the encryption set up. Use the connect() and initEncryption() classes for these tasks.

Method Detail
connect()method
public function connect(serverName:String, serverPort:int = 49494):void

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Opens a Kevlar data connection to Photoshop. You may call this function before you call initEncryption(), but you will have to initialize the encryption before you can successfully communicate with Photoshop.

Parameters

serverName:String — IP address or resolvable hostname of the server
 
serverPort:int (default = 49494) — Port to connect to. Default is 49494

disconnect()method 
public function disconnect():void

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Disconnects the connection to Photoshop

encryptAndSendData()method 
public function encryptAndSendData(data:ByteArray):Boolean

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Will both encrypt and send data to Photoshop. However, it doesn't ensure that your data is properly formatted. If you're interested in creating and dispatching properly formatted messages, look into the KevlarMessageDispatcher class.

Parameters

data:ByteArray — The payload to encrypt and send

Returns
Boolean — Returns true or false based on whether the operations were successful
encryptData()method 
public function encryptData(data:ByteArray):Boolean

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Encrypts data such that Photoshop will be able to decrypt it. This won't ensure that your data is properly formatted, however. If you're interested in creating and dispatching properly formatted messages, look into the KevlarMessageDispatcher class. This function requires that the developer has already initialized the encryption.

Parameters

data:ByteArray — The data to encrypt

Returns
Boolean — Returns true or false based on whether the operations were successful
initEncryption()method 
public function initEncryption(password:String = Swordfish, salt:String = Adobe Photoshop, numIterations:int = 1000, numBytes:int = 24):void

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Derives the key necessary for all communication with Photoshop. This is a costly function. However, it must be called before communication can be successful. It's recommended that you inform the user that initializing enryption will take some time before calling this function.

Parameters

password:String (default = Swordfish) — The pre-shared password between Photoshop and your client.
 
salt:String (default = Adobe Photoshop) — The pre-shared salt between Photoshop and this client. This value should be available in Photoshop SDK documentation.
 
numIterations:int (default = 1000) — The number of iterations the PBKDF2 password hash should use
 
numBytes:int (default = 24) — The length of the derived PBKDF2 key, in bytes.

sendDatagram()method 
public function sendDatagram(data:ByteArray):Boolean

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Sends raw data to Photoshop, without encrypting it or wrapping it in a properly formatted message. If you want to generate your own message and dispatch it, look at the KevlarMessageDispatcher class. If you want to encrypt your data before pushing it to Photoshop, you'll want to use encryptAndSendData(), or encryptData()

Parameters

data:ByteArray — The payload of data

Returns
Boolean — Returns false if the operation failed immediately.
Event Detail
ConnectedEvent Event
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.CONNECTED

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when the connection to Photoshop has been established

DisconnectedEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.DISCONNECTED

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when the connection is terminated

encryptionSuccess Event  
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.ENCRYPTION_SUCCESS

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when the key has been encrypted, and the connection is ready to send and receive data.

ErrorEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.ERROR

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when there's been an error in either data transfer, encryption, or connection management.

ImageReceivedEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.IMAGE_RECEIVED

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when the connection has received an image

KevlarMessageReceivedEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarMessageEvent
KevlarMessageEvent.type property = com.adobe.kevlar.events.KevlarMessageEvent.MESSAGE_RECEIVED

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when a message is received from Photoshop.

KevlarMessageSentEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarMessageEvent
KevlarMessageEvent.type property = com.adobe.kevlar.events.KevlarMessageEvent.MESSAGE_SENT

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when a message is sent to Photoshop.

ProgressEvent Event  
Event Object Type: com.adobe.photoshop.events.KevlarEvent
KevlarEvent.type property = com.adobe.kevlar.events.KevlarEvent.PROGRESS

Language Version : ActionScript 3.0
Runtime Versions : AIR 1.0, Flash Player 10

Dispatched when there is progress in parsing a response or sending a message. Useful for large transfers.

Constant Detail
KEVLAR_CONNECTION_API_VERSIONConstant
public static const KEVLAR_CONNECTION_API_VERSION:int = 1

The Kevlar API version that this code supports