Expand my Community achievements bar.

Getting an authToken from Coldfusion CFCs


Level 1

Thought this might be helpful for people who wanted to use ColdFusion CFCs to get an 'authToken' from within their application as you would in a production system. The example assumes you know how to interact with CFCs via Flash Remoting (<mx:RemoteObject>).

This additional CFC (AFCSServices.cfc) complements the Coldfusion samples that come with the v0.92 SDK. It acts as a wrapper that allows you to just call the 'connect' function and it returns an authToken that you can use to pass to AdobeHSAuthenticator -

<cfcomponent name="AFCSServices" access="remote">
<cffunction name="connect" access="remote" returntype="any">
  <cfargument name="accounturl" type="string">
  <cfargument name="username" type="string">
  <cfargument name="password" type="string">
  <cfargument name="room" type="string">
  <cfargument name="UserID" type="string">
  <cfargument name="UserRole" type="string">
  <cfargument name="SharedSecret" type="string">
  <cfset accountManager = createObject("component", "AFCSAccountManager").init(accounturl)>
  <cfset accountManager.login(#username#, #password#)>

     <cfset session = accountManager.getSession("#room#")>
  <cfset authToken = accountManager.getAuthenticationToken(#room#, #SharedSecret#, #username#, #UserID#, #UserRole#) >

  <cfreturn authToken>


You also need to add a function to the extisting AFCSAccountManager.cfc that comes with the SDK -

<cffunction name="getAuthenticationToken" returntype="any" access="public" output="false" hint="get auth token">
        <cfargument name="room" type="string" required="yes"/>
        <cfargument name="accountSecret" type="string" required="yes">
        <cfargument name="name" type="string" required="yes">
        <cfargument name="id" type="string" required="yes">
        <cfargument name="role" type="numeric" required="yes">
        <cfset var jSess = "">
        <cfset var retSession = "">
        <cfset var authToken = "">
           <cfset jSess = VARIABLES.accountmanager.getSession(room)>
          <cfreturn "">
        <cfif isdefined("jSess")>
         <cfset retSession = createObject("component", "AFCSSession")>
         <cfset retSession.setSession(jSess)>
         <cfset authToken = retSession.getAuthenticationToken(accountSecret, name, id, role)>
            <cfreturn authToken>
        <cfreturn "">

1 Reply


Not applicable

This is very cool - thanks for sharing it!


page footer