Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Date Date
Qty:
Subtotal
Promotions
Estimated Shipping
VAT
Calculated at checkout
Total
Checkout
ColdFusion Help / 

ColdFusion MX: How to pass login credentials to cflogin via Flash Remoting

Adobe Community Help


Products Affected

  • ColdFusion
  • Flash Remoting

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

This TechNote describes how to use Flash Remoting with ColdFusion's built-in authentication mechanism and ColdFusion components. It shows how to use the ActionScriptsetCredentials method on the Flash side to pass credential information to the cflogin tag on the ColdFusion side. This TechNote assumes you are already familiar with using Flash Remoting to pass data between Flash applications and ColdFusion components. It also assumes you are familiar with application security in ColdFusion MX.

Step 1:

Create a function within your Flash application which will use thesetCredentials method to pass a username and password from Flash to a ColdFusion component (cfc). ThesetCredentials method is a method of the NetConnection object. The use of setCredentials in a Flash application is analogous to using an html form with j_username and j_password form fields to pass login information to ColdFusion in a non-Flash application.

For example, if you have an ActionScript function called CallSecureCFC, the following code would pass a userid and password from Flash textboxes to a ColdFusion cfc function called mySecureFunction:

function CallSecureCFC() {   CFCResponse_txt.text = "";   CFCError_txt.text = "";   gatewayConnection.setCredentials      (userid_txt.text, pwd_txt.text);   myCFCService.mySecureFunction();   } function mySecureFunction_Result(result) {   CFCResponse_txt.text = result;   } function mySecureFunction_Status(error) {   CFCError_txt.text = error.description;   }

This code assumes you have previously established a gatewayConnection from Flash to ColdFusion using theNetServices.createGatewayConnection() method. It also assumes you have created a service object called myCFCService which is bound to your CFC. In this example, I have also created two Flash text boxes, CFCResponse_txt and CFCError_txt, to capture the results of calling the ColdFusion function.

Step 2:

Use the cflogin and cfloginuser tags to authenticate the username and password passed with thesetCredentials method and assign one or more roles to the user. For example, the following code, typically included in the Application.cfm, would validate a username and password against security information stored in a database table:

<CFAPPLICATION NAME="FlashCredentials"><CFLOGIN><CFIF isDefined("cflogin")><CFQUERY NAME="qSecurity"        DATASOURCE="UserRolesDb">        SELECT Roles FROM SecurityRoles        WHERE username='#cflogin.name#'        and password='#cflogin.password#'</CFQUERY><CFIF qSecurity.recordcount gt 0><CFLOGINUSER NAME = "#cflogin.name#"           PASSWORD = "#cflogin.password#"           ROLES = "#trim(qSecurity.Roles)#" ></CFIF></CFIF></CFLOGIN>

Step 3:

Create a ColdFusion component with a function that uses the "Roles" attribute to limit access to that specific function. Specify a comma-delimited list of roles which will have access to your function.

<CFCOMPONENT><CFFUNCTION NAME="mySecureFunction"     ACCESS="remote"     RETURNTYPE="string"     ROLES="Dude"><CFRETURN "Hi #getAuthUser()# - Welcome aboard!" ></CFFUNCTION></CFCOMPONENT>

While testing this functionality, it is important to note that the body of the cflogin tag only executes if there is no logged-in user. Therefore, if you try to test intentionally passing a bad password, or changing users, after you have already been successfully authenticated, the cflogin tag will not execute again and ColdFusion will continue to recognize you as the user you logged in as previously. In this scenario, you will have to close the Flash development environment in order to remove your authentication cookie from memory. If you have already published your Flash movie to a .swf file, you will have to close your browser or flash player in order to remove the authentication cookie. An alternative to this would be to code a logout function in your cfc which could be called from Flash. This will remove the authentication cookie from memory without having to close Flash or your browser. For example:

<CFFUNCTION NAME="LogMeOut" ACCESS="remote"  RETURNTYPE="string"><CFSET AuthUser = getAuthUser()><CFLOGOUT><CFRETURN "User #AuthUser# logged out" ></CFFUNCTION>

It is also important to use conditional logic to run cfloginuser only if a valid user has logged in. This example accomplishes this task with <CFIF qSecurity.recordcount gt 0>. This test works because the query returns a result only if the user supplied a valid name-password pair, and all users have at least one role. If this check were not included, the code would log in an invalid user (who would be assigned an empty role list (Roles = "" )). Without this check, if a user accidentally had a typo in the password, they would not have a valid role and not be able to try to log in again until they logged out. Again, this is because the cflogin tag would not execute because a user was logged in (even though the list of roles is empty).

To the top

Additional Information

  • Using Macromedia Flash Remoting MX with Macromedia ColdFusion MX (9938)
  • Enabling access from Macromedia Flash to web services using the Flash Gateway in ColdFusion MX Updater 3 (18608)
  • Documentation for NetConnection.setCredentials
Keywords: tn_18684

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement