Showing posts with label actionscript. Show all posts
Showing posts with label actionscript. Show all posts

Saturday, January 16, 2010

Strong Password Validator

Recently I was needed to create a password strength validator, which will basically info user how strong is the entered password. There are different standards for the strong password, I decided to go on with these:

- Must contain eight characters or more
- Should not contain spaces

Previous two are required criteria, it means that if the entered password doesn't match this requirements it is not valid.

Contain characters from one or more of the following three character classes:
- Alphabetic (e.g., a-z, A-Z)
- Numeric (i.e. 0-9)
- Punctuation and other characters (e.g., !@#$%^&*()_+|~-=\`{}[]:";'<>?,./)

It is pretty easy to validate password based on those requirements, but sometimes we don't want requirements to be hard-coded. That's why I decided to store requirements as regular expressions. You can store each requirement as a separate reg exp in DB, you can also store additional "required" flag (if password doesn't match required criteria it is invalid). In my demo regular expressions are hard-coded, but they can be easily retrieved from DB.


Wednesday, August 6, 2008

Little hint concerning Flickr API from Flexosaurus

If you are trying to use ActionScript 3.0 API for Flickr and while creating FlickrService you are getting following error:

1017: The definition of base class URLLoaderBase was not found.



Or following exception run-time:

Error #1014: Class com.adobe.webapis::URLLoaderBase could not be found.



Do not panic. You just need to download as3corelib . There are number of classes in as3corelib that are getting used by ActionScript 3.0 API for Flickr.

Thursday, July 17, 2008

Flexosaurus about Blogger API for ActionScript

Yesterday I was trying to get authenticating to the Blogger service, but I was getting following error. Error: [IOErrorEvent type="ioError" bubbles=false cancelable=false
eventPhase=2 text="Error #2032: Stream Error. URL:
https://www.google.com/accounts/ClientLogin"]. URL:
https://www.google.com/accounts/ClientLogin.

I found out that Google currently do not support cross-domain requests to Google Accounts from Flash. There is currently an issue filed against this here: http://code.google.com/p/gdata-issues/issues/detail?id=406 .

Anyhow I was able to get authorization token(it worked for Mozilla FireFox, but not for IE6), but not more than that. But it may be able to work around this by proxying requests through own domain, however. So maybe I will try.


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
applicationComplete="authotize()">

<mx:Script><![CDATA[

import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.http.mxml.HTTPService;

//Authorization Token
private var _auth:String;

public function authotize():void
{
var urlLoader:URLLoader = new URLLoader();
var urlRequest:URLRequest = new URLRequest();
var urlVariables:URLVariables = new URLVariables();

urlVariables.Email = {you_e-mail_here}
urlVariables.Passwd = {your_password_here}
urlVariables.service = "blogger";
urlVariables.source = "exampleCo-exampleApp-1";

urlRequest.url = "https://www.google.com/accounts/ClientLogin";
urlRequest.data = urlVariables;
urlRequest.method = URLRequestMethod.POST;

urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlLoader.addEventListener(IOErrorEvent.IO_ERROR, onError);
urlLoader.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHTTPStatus);
urlLoader.addEventListener(Event.COMPLETE, onComplete);

urlLoader.load(urlRequest);
}

private function onComplete(event:Event):void
{
var str:String = event.currentTarget.data;
var index:int = str.indexOf("Auth=");
_auth = str.substring(index + 5, str.length - 1);
}

private function onHTTPStatus(event:HTTPStatusEvent):void
{
trace(event);
}

private function onError(event:Event):void
{
trace(event);
}

]]></mx:Script>

</mx:Application>