Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Getting an authToken from Coldfusion CFCs

Tony_Sykes
Level 1
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">
<cfoutput>
<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>
</cffunction>

</cfoutput>
</cfcomponent>

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 = "">
 
        <cftry>
           <cfset jSess = VARIABLES.accountmanager.getSession(room)>
        <cfcatch>
          <cfreturn "">
        </cfcatch>
        </cftry>
       
        <cfif isdefined("jSess")>
         <cfset retSession = createObject("component", "AFCSSession")>
         <cfset retSession.setSession(jSess)>
         <cfset authToken = retSession.getAuthenticationToken(accountSecret, name, id, role)>
            <cfreturn authToken>
        </cfif>
               
        <cfreturn "">
     </cffunction>

1 Reply
Nigel_Pegg
Level 10
Level 10

This is very cool - thanks for sharing it!

nigel