Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lmajano committed May 24, 2012
1 parent 624c9e7 commit 0b1afc1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 28 deletions.
3 changes: 3 additions & 0 deletions install/IDE Extras/CFBuilder Dictionary/coldbox.builder.xml
Expand Up @@ -467,6 +467,9 @@
<parameter name="locale" required="false" type="string">
<help><![CDATA[ The locale to validate in ]]></help>
</parameter>
<parameter name="excludeFields" required="false" type="string">
<help><![CDATA[ The fields to exclude in the validation ]]></help>
</parameter>
</function>
<function name="getResource" returns="any">
<help><![CDATA[ Facade to i18n.getResource. Returns a string. (Context: FrameworkSupertype) ]]></help>
Expand Down
3 changes: 3 additions & 0 deletions install/IDE Extras/CFEclipse Dictionary/coldbox.xml
Expand Up @@ -470,6 +470,9 @@
<parameter name="locale" required="false" type="string">
<help><![CDATA[ The locale to validate in ]]></help>
</parameter>
<parameter name="excludeFields" required="false" type="string">
<help><![CDATA[ The fields to exclude in the validation ]]></help>
</parameter>
</function>
<function creator="8" name="getResource" returns="any">
<help><![CDATA[ Facade to i18n.getResource. Returns a string. (Context: FrameworkSupertype) ]]></help>
Expand Down
56 changes: 28 additions & 28 deletions system/plugins/CookieStorage.cfc
Expand Up @@ -8,7 +8,7 @@ Author : Sana Ullah
Date : October 15, 2007
Description :
This is a plugin that enables the setting/getting of permanent variables in the cookie scope.
Usage:
Usage:
set controller.getPlugin("CookieStorage").setVar(name="name1",value="hello1",expires="11")
get controller.getPlugin("CookieStorage").getVar(name="name1")
Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie value
Expand All @@ -24,26 +24,26 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie

<cffunction name="init" access="public" returntype="CookieStorage" output="false" hint="Constructor">
<cfargument name="controller" type="any" required="true" colddoc:generic="coldbox.system.web.Controller">
<cfscript>
<cfscript>
super.init(arguments.controller);

// Plugin Properties
setpluginName("Cookie Storage");
setpluginVersion("2.0");
setpluginDescription("A permanent data storage plugin.");
setpluginAuthor("Sana Ullah & Luis Majano");
setpluginAuthorURL("http://www.coldbox.org");

// set CFML engine encryption CF, BD, Railo
setEncryptionAlgorithm("CFMX_COMPAT");
setEncryptionKey("ColdBoxPlatform");
setEncryption(false);
setEncryptionEncoding("HEX");

// set defautl alogrithm according to CFML engine
if(controller.getCFMLEngine().getEngine() EQ 'BLUEDRAGON'){
setEncryptionAlgorithm("BD_DEFAULT");
}
}
// Do we Encrypt.
if(settingExists('CookieStorage_encryption') and isBoolean(getSetting('CookieStorage_encryption'))){
setEncryption(getSetting('CookieStorage_encryption'));
Expand All @@ -60,7 +60,7 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
if(settingExists('CookieStorage_encryption_encoding') and len(getSetting('CookieStorage_encryption_encoding'))){
setEncryptionEncoding(getSetting('CookieStorage_encryption_encoding'));
}

return this;
</cfscript>
</cffunction>
Expand All @@ -77,26 +77,26 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfargument name="path" type="string" required="false" default="" hint="URL, within a domain, to which the cookie applies; typically a directory. Only pages in this path can use the cookie. By default, all pages on the server that set the cookie can access the cookie.">
<cfargument name="domain" type="string" required="false" default="" hint="Domain in which cookie is valid and to which cookie content can be sent from the user's system.">
<!--- ************************************************************* --->

<cfset var tmpVar = "">
<cfset var args = StructNew()>

<!--- JSON storage --->
<cfset tmpVar = serializeJSON( arguments.value )>

<!--- Encryption? --->
<cfif getEncryption()>
<cfset tmpVar = encryptIt( tmpVar )>
<cfset tmpVar = encryptIt( tmpVar )>
</cfif>

<!--- Store cookie with expiration info --->
<cfset args["name"] = uCase( arguments.name ) />
<cfset args["value"] = tmpVar />
<cfset args["secure"] = arguments.secure />
<cfif arguments.expires GT 0>
<cfset args["expires"] = arguments.expires />
</cfif>
</cfif>

<!--- Store cookie with expiration info --->
<cfif len( arguments.path ) GT 0 and not len( arguments.domain ) GT 0>
<cfthrow type="CookieStorage.MissingDomainArgument" message="If you specify path, you must also specify domain.">
Expand All @@ -106,7 +106,7 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfelseif len( arguments.domain )>
<cfset args["domain"] = arguments.domain />
</cfif>

<cfcookie attributeCollection="#args#" />
</cffunction>

Expand All @@ -115,25 +115,25 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfargument name="name" required="true" hint="The variable name to retrieve.">
<cfargument name="default" required="false" hint="The default value to set. If not used, a blank is returned.">
<cfset var rtnVar = "">

<cfif exists(arguments.name)>
<!--- Get value --->
<cfset rtnVar = cookie[ uCase( arguments.name ) ]>

<!--- Decrypt? --->
<cfif getEncryption() and len( rtnVar )>
<cfset rtnVar = decryptIt( rtnVar )>
</cfif>

<!--- JSON Deserialize? --->
<cfif isJSON( rtnVar )>
<cfset rtnVar = deserializeJSON( rtnVar )>
</cfif>
<!--- Return it --->
<cfreturn rtnVar>
<cfreturn rtnVar>
<cfelseif structKeyExists(arguments, "default")>
<!--- Return the default value --->
<cfset rtnVar = arguments.default>
<cfreturn arguments.default>
<cfelse>
<cfthrow type="CookieStorage.InvalidKey" message="The key you requested: #arguments.name# does not exist">
</cfif>
Expand Down Expand Up @@ -165,7 +165,7 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfreturn false>
</cfif>
</cffunction>

<!--- Get/Set Encryption Key --->
<cffunction name="getEncryptionKey" access="public" output="false" returntype="string" hint="Get the EncryptionKey">
<cfreturn instance.EncryptionKey/>
Expand All @@ -183,7 +183,7 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfargument name="EncryptionAlgorithm" type="string" required="true"/>
<cfset instance.EncryptionAlgorithm = arguments.EncryptionAlgorithm/>
</cffunction>

<!--- Get/set Encrypting values or not. --->
<cffunction name="getEncryption" access="public" output="false" returntype="boolean" hint="Get Encryption flag">
<cfreturn instance.Encryption/>
Expand All @@ -192,11 +192,11 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<cfargument name="Encryption" type="boolean" required="true"/>
<cfset instance.Encryption = arguments.Encryption/>
</cffunction>

<!--- Encryption Encoding --->
<cffunction name="getEncryptionEncoding" access="public" output="false" returntype="string" hint="Get EncryptionEncoding value">
<cfreturn instance.EncryptionEncoding/>
</cffunction>
</cffunction>
<cffunction name="setEncryptionEncoding" access="public" output="false" returntype="void" hint="Set EncryptionEncoding value">
<cfargument name="EncryptionEncoding" type="string" required="true"/>
<cfset instance.EncryptionEncoding = arguments.EncryptionEncoding/>
Expand All @@ -207,13 +207,13 @@ Modification History: March 23,2008 Added new feature to encrypt/decrypt cookie
<!--- Encrypt Data --->
<cffunction name="encryptIt" access="private" returntype="any" hint="Return encrypted value" output="false">
<cfargument name="encValue" hint="string to be encrypted" required="true" type="string" />
<cfreturn encrypt(arguments.encValue,getEncryptionKey(),getEncryptionAlgorithm(),getEncryptionEncoding()) />
<cfreturn encrypt(arguments.encValue,getEncryptionKey(),getEncryptionAlgorithm(),getEncryptionEncoding()) />
</cffunction>

<!--- Decrypt Data --->
<cffunction name="decryptIt" access="private" returntype="any" hint="Return decrypted value" output="false">
<cfargument name="decValue" hint="string to be decrypted" required="true" type="string" />
<cfreturn decrypt(arguments.decValue,getEncryptionKey(),getEncryptionAlgorithm(),getEncryptionEncoding()) />
<cfreturn decrypt(arguments.decValue,getEncryptionKey(),getEncryptionAlgorithm(),getEncryptionEncoding()) />
</cffunction>

</cfcomponent>

0 comments on commit 0b1afc1

Please sign in to comment.