Adobe COLDFUSION 9 Manual page 210

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Type
Description
private
Available only to the component that declares the method and any components that extend the component in
which it is defined. This usage is like the Java protected keyword, not the Java private keyword.
package
Available only to the component that declares the method, components that extend the component, or any other
components in the package. A package consists of all components defined in a single directory. For more
information on packages, see
public
Available to any locally executing ColdFusion page or component method.
remote
Available to a locally or remotely executing ColdFusion page or component method, or to a local or remote client
through a URL, form submission, Flash Remoting, or as a web service.
Using role-based security
If you specify a
attribute in a
roles
execute the method. When a user tries to invoke a method without authorization, an exception is returned.
The following example creates a component method that deletes files:
<cfcomponent>
<cffunction
name="deleteFile" access="remote" roles="admin,manager" output="no">
<cfargument name="filepath" required="yes">
<cffile action="DELETE" file=#arguments.filepath#>
</cffunction>
</cfcomponent>
In the example, the
cffunction
example, only users in the role
a comma.
For information on ColdFusion security, including the cflogin tag and role-based security in ColdFusion, see
"Securing
Applications" on page 339.
Using programmatic security
You can implement your own security within a method to protect resources. For example you can use the ColdFusion
function
IsUserInAnyRole
<cffunction name="foo">
<cfif IsUserInRole("admin")>
... do stuff allowed for admin
<cfelseif IsUserInRole("user")>
... do stuff allowed for user
<cfelse>
<cfoutput>unauthorized access</cfoutput>
<cfabort>
</cfif>
</cffunction>
Using introspection to get information about components
ColdFusion provides several ways for you to get information about components:
• Request a component page from the browser
• Use the ColdFusion component browser
• Use the Adobe® Dreamweaver® Components panel
"Using component
tag, only users who are logged in with one of the specified roles can
cffunction
tag includes the
attribute to specify the user roles allowed to access it. In this
roles
and
can access the function. Notice that multiple roles are delimited by
admin
manager
to determine if a user is in particular role, as the following example shows:
Last updated 8/5/2010
packages" on page 203.
205

Advertisement

Table of Contents
loading

Table of Contents