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
BedrockMission!

Learn More

View all

Sign in to view all badges

Getting an authToken from Coldfusion CFCs

Avatar

Avatar
Level 1
Tony_Sykes
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
Tony_Sykes
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile
Tony_Sykes
Level 1

18-05-2009

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>

Replies

Avatar

Avatar
Boost 50
Level 7
Nigel_Pegg
Level 7

Likes

103 likes

Total Posts

909 posts

Correct Reply

81 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile

Avatar
Boost 50
Level 7
Nigel_Pegg
Level 7

Likes

103 likes

Total Posts

909 posts

Correct Reply

81 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 25
Boost 100
View profile
Nigel_Pegg
Level 7

21-05-2009

This is very cool - thanks for sharing it!

nigel