2008-10-14

Single Sign On (SSO) with Flex in J2EE container

I've saw this question asked a couple times about a month ago and I tried to answer the question but thought it best to create an example. The question is, how do you prevent a Flex application from showing the login page after the user hit F5 in the browser (or refresh for that matter), after he/she just logged in.

So the main question here is how do you know someone has logged in successfully and don't need to present them with a login view. This is also how to handle the Single Sign On (SSO) case, where you know the user has authenticated himself successfully under host.com/app1 context but is now at your Flex application under the host.com/app2 context and you don't want him to have to re-authenticate himself. Of course we talking here about a Java back-end, so either using BlazeDS or LiveCycle Data Services.

So in my example I used BlazeDS and assuming you configured the security properly, a typical Flex application will display a login view to the user before they can do anything. But if the user has already been authenticated in this web context or another context on the same server, how do we prevent this default behavior? Here is how I do it in some simple words.

When the LoginView initializes, call the server to load the user's information (you will most likely need it at some point anyways). If you get a success response, you have the data and it means the user is already authenticated, so broadcast the LoginSuccessEvent event and you are done! The application will now display its main content. If you get an error response, the most likely cause is that the user is not authenticated and you should remain at the LoginView. It could also mean there is some server-side error (like config issue) which your technical department will have to look into.

If you do have to present the user with the LoginView, then once they click on the Login button, call the setCredentials() method of your RemoteObject and then make the same call to load the user's information.

But there is no better way to see this than to look at an example. So I recommend you download my example using the link below and take a look at the LoginView.mxml file where most of the work is done. The example deploys easily into Tomcat, so I recommend reading the readme.txt file contained within the archive for some installation details. The complete source is included as well.

You can download my example from here. Enjoy!

48 comments:

Ross Phillips said...

Have you thought about using a Shared Object to store the "login"? Unless I'm missing something with the Flash Security model both apps should be able to access the same Shared Object since it's on the same domain. Also I would recommending store a session id or similar hash key to identify the user and not a actual login and password.

This should allow you to have a SSO.

Dimitrios "Jimmy" Gianninas said...

Why should I write code to read/write info to a Shared Object to use for SSO when all the security stuff is already implemented for me using BlazeDS/LCDS? And I don't store anything anywhere btw, just look at the example.

Ross Phillips said...

Sheesh - BladeDS/LCDS is not the only way backend for Flex apps. Shared Objects is alternative way to solve this problem if you don't have BladeDS/LCDS.

Also to note in your suggested solution. The apps destination(s) would need to have the same security setup.

I'm not saying your solution is invalid/bad just highlighting another solution to "Single Sign On (SSO) with Flex".

Dimitrios "Jimmy" Gianninas said...

Well my example was for Java web container, so its probably what most people will do. But if you dont use Java, then yes, using Shared Object is probably a solution. No sheeshing required.

111 said...

WoW shares many wow gold of its features with previously launched games. Essentially, you battle with Cheapest wow gold monsters and traverse the countryside, by yourself or as a buy cheap wow gold team, find challenging tasks, and go on to higher Cheap Wow Gold levels as you gain skill and experience. In the course of your journey, you will be gaining new powers that are increased as your skill rating goes up. All the same, in terms of its features and quality, that is a ture stroy for this.WoW is far ahead of all other games of the genre the wow power leveling game undoubtedly is in a league of its own and cheapest wow gold playing it is another experience altogether.
Even though WoW is a wow gold cheap rather complicated game, the controls and interface are done in buy warhammer gold such a way that you don't feel the complexity. A good feature of the game is that it buy wow items does not put off people with lengthy manuals. The instructions cannot be simpler and the pop up tips can help you start playing the game World Of Warcraft Gold immediately. If on the other hand, you need a detailed manual, the instructions are there for you to access. Buy wow gold in this site,good for you ,WoW Gold, BUY WOW GOLD.

shdh said...

It was not long cheap wow goldbefore some one knocked at wow gold for salethe house-door and called, open the door, dear children, your mother is here, and wow gold cheap has brought something back with her for each of you. But the little cheapest wow goldkids knew that it was the wolf, by the rough voice. We will fastgg not open the door, cried they, you are not our mother. She has a soft, pleasant voice, but your voice is rough, you are the wolf.

Then the wolf went World Of Warcraft Goldaway to a shopkeeper and bought himself a great lump of chalk, ate this and made mmogap his voice soft with it. The he came back, knocked at the door of the house, and igsky called, open the door, dear children, your mother is here and Cheapest Wow Goldhas brought something back with her for each of you.

elextra said...

Hey Dimitrios,

thanks for your example. I run your sample and it does not seem to keep the session info across webapp context in within the same server.
i.e:
/sso-login/main.swf and
/sso-login/admin/index.html
do share it..and login into 1 is enough.
However if you change webcontext
/sso-login/main.swf and
/sso-login2/admin/index.html

you are prompted to re-login.

Any idea on how to obtain that..although I think the solution lays more into an app container solution than into flex...

wow gold said...

Weekends to peopleig2tmean that they can have a two-day wowgold4europe good rest. For example, people gameusdcan go out to enjoy themselves or get meinwowgoldtogether with relatives and friends to talk with each storeingameother or watch interesting video tapes with the speebiewhole family.
Everyone spends agamegoldweekends in his ownmmoflyway. Within two days,some people can relax themselves by listening to music, reading novels,or watchingogeworld films. Others perhaps are more active by playing basketball,wimming ormmorpgvipdancing. Different people have different gamesavorrelaxations.
I often spend weekends withoggsalemy family or my friends. Sometimes my parents take me on a visit to their old friends. Sometimesgamersell I go to the library to study or borrow some books tommovirtexgain much knowledge. I also go to see various exhibition to broadenrpg tradermy vision. An excursion to seashore or mountain resorts is my favorite way of spending weekends. Weekends are always enjoyable for me.
igxe swagvaultoforu wowgold-usaignmax wowgoldlivebrogame thsaleGoldRockU

World of Warcraft Gold Guides said...

good post :)

Anonymous said...

出会い喫茶出会いカフェテレクラ不倫セックスフレンドセフレ出会い出会い出会い掲示板出会い出会い出会い人妻風俗デリヘルデリバリーヘルス出会い出会い無料フィリピンライブチャットアダルトライブチャットデリヘル

Anonymous said...

不動産ソープランドアクセスカウンターコレステロール中性脂肪花粉症在宅ワーク内職在宅アルバイト乾燥肌ダイエット 食事サプリメント無料占い出会い山口クレジットカード現金化クレジット現金化ライブチャットフィリピンチャットレディパソコン在宅ワーク

Anonymous said...

出会い豊島区出会い北区出会い荒川区出会い板橋区出会い練馬区出会い足立区出会い葛飾区出会い江戸川区ニキビCholesterol水虫冷え性むくみ産後わきが車買取転職加齢臭

Anonymous said...

出会い愛知出会い秋田出会い青森出会い千葉出会い愛媛出会い福井出会い福岡出会い福島出会い岐阜出会い群馬出会い広島出会い北海道出会い兵庫出会い茨城出会い石川出会い岩手出会い香川出会い鹿児島出会い神奈川出会い高知

Anonymous said...

出会い熊本出会い京都出会い三重出会い宮城出会い宮崎出会い長野出会い長崎出会い奈良出会い新潟出会い大分出会い岡山出会い沖縄出会い大阪出会い佐賀出会い埼玉出会い滋賀出会い島根出会い静岡出会い栃木出会い徳島

Anonymous said...

出会い東京出会い鳥取出会い富山出会い和歌山出会い山形出会い山口出会い山梨出会い北九州出会い下関出会い川崎出会い神戸出会い久留米出会い水戸出会い名古屋出会い大牟田出会い埼玉出会い堺出会い仙台出会い横浜出会い横須賀出会い札幌出会い川崎

Anonymous said...

出会い堺出会い仙台出会い横浜出会い横須賀出会い札幌出会い千代田区出会い中央区出会い港区出会い新宿区出会い文京区出会い台東区出会い墨田区出会い江東区出会い品川区出会い目黒区出会い大田区出会い世田谷区出会い渋谷区出会い中野区出会い杉並区

Anonymous said...

福井出会い愛知出会い岐阜出会い静岡出会い三重出会い兵庫出会い大阪出会い和歌山出会い滋賀出会い京都出会い奈良出会い山口出会い鳥取出会い島根出会い岡山出会い広島出会い徳島出会い香川出会い愛媛出会い高知出会い

Anonymous said...

出会い札幌出会い函館出会い北海道出会い秋田出会い青森出会い岩手出会い東京出会い八王子出会い府中出会い調布出会い銀座出会い仙台出会い優良出会いサイトアダルト盗撮素人熟女エロアニメAV女優

Anonymous said...

出会い愛知出会い秋田出会い青森出会い千葉出会い愛媛出会い福井出会い福岡出会い福島出会い岐阜出会い群馬出会い広島出会い北海道出会い兵庫出会い茨城出会い石川出会い岩手出会い香川出会い鹿児島出会い神奈川出会い高知

Anonymous said...

出会い熊本出会い京都出会い三重出会い宮城出会い宮崎出会い長野出会い長崎出会い奈良出会い新潟出会い大分出会い岡山出会い沖縄出会い大阪出会い佐賀出会い埼玉出会い滋賀出会い島根出会い静岡出会い栃木出会い徳島

Anonymous said...

出会い東京出会い大阪出会い福岡出会い兵庫出会い神奈川出会い宮城出会い千葉出会い愛知出会い埼玉出会い青森出会い岩手出会い秋田出会い山形出会い山口出会い東京出会い鳥取出会い富山出会い和歌山出会い山形

Anonymous said...

出会い奈良出会い滋賀出会い三重出会い和歌山出会い愛知出会い静岡出会い岐阜出会い広島出会い岡山出会い山口出会い島根出会い鳥取出会い富山出会い石川出会い福井出会い徳島出会い香川出会い愛媛出会い高知出会い福岡

Anonymous said...

セフレ奈良セフレ滋賀セフレ三重セフレ和歌山セフレ愛知セフレ静岡セフレ岐阜セフレ広島セフレ岡山セフレ山口セフレ島根セフレ鳥取セフレ富山セフレ石川セフレ福井セフレ徳島セフレ香川セフレ愛媛セフレ高知セフレ福岡

Anonymous said...

福井テレクラ愛知テレクラ岐阜テレクラ静岡テレクラ三重テレクラ兵庫テレクラ大阪テレクラ和歌山テレクラ滋賀テレクラ京都テレクラ奈良テレクラ山口テレクラ鳥取テレクラ島根テレクラ岡山テレクラ広島テレクラ徳島テレクラ香川テレクラ愛媛テレクラ高知テレクラ

Anonymous said...

福井セフレ愛知セフレ岐阜セフレ静岡セフレ三重セフレ兵庫セフレ大阪セフレ和歌山セフレ滋賀セフレ京都セフレ奈良セフレ山口セフレ鳥取セフレ島根セフレ岡山セフレ広島セフレ徳島セフレ香川セフレ愛媛セフレ高知セフレ

セフレ 不倫 出会い メル友 said...

無料 出会い 競馬予想 無料 競馬予想 競馬予想 無料 競馬予想 無料 競馬予想 無料 近視 手術 メル友 出会い 出会い 出会い 出会い メル友 メル友 人妻 メル友 ギャンブル依存症 AV女優 無料 出会い 出逢い 掲示板 出会い系 無料 出会い 人妻 出会い 人妻 出会い セフレ 人妻 出会い セックスフレンド メル友 出会い SM 愛人 不倫 セフレ 無料 出会い 出会い系 無料 無料 出会い 富士山 写真 富士山 メル友 無臭性動画 カリビアムコム 一本堂 出会い 人妻 セックスフレンド ハメ撮り エッチな0930 メル友 無料 出会い 無料 出会い セフレ セフレ セフレ セックスフレンド セックスフレンド セックスフレンド 人妻 出会い 人妻 出会い 人妻 出会い 出会い系 出会い系 出会い系 カリビアンカム カリビアンカム

大大 said...

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . .
This article is very good,I like it !

大大 said...

. . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . good!

good!

大大 said...

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . good,very good!

大大 said...

. . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . .

. . . . . . .

. . . . . . . . . . . . . . . .

. . . . . . . . . . . . .

. I like it

酒店上班請找艾葳 said...

艾葳酒店經紀公司提供專業的酒店經紀, 酒店上班小姐,八大行業,酒店兼職,傳播妹,或者想要打工兼差打工,兼差,八大行業,酒店兼職,想去酒店上班, 日式酒店,便服店,制服酒店,ktv酒店,禮服店,整天穿得水水漂漂的,還是想去制服店日領上班小姐,水水們如果想要擁有打工工作、晚上兼差工作兼差打工假日兼職兼職工作酒店兼差兼差打工兼差日領工作晚上兼差工作酒店工作酒店上班酒店打工兼職兼差兼差工作酒店上班等,想了解酒店相關工作特種行業內容,想兼職工作日領假日兼職兼差打工、或晚班兼職想擁有鋼琴酒吧又有保障的工作嗎???又可以現領請找專業又有保障的艾葳酒店經紀公司!

艾葳酒店經紀是合法的公司工作環境高雅時尚,無業績壓力,無脫秀無喝酒壓力,高層次會員制客源,工作輕鬆,可日領現領
一般的酒店經紀只會在水水們第一次上班和領薪水時出現而已,對水水們的上班安全一點保障都沒有!艾葳酒店經紀公司的水水們上班時全程媽咪作陪,不需擔心!只提供最優質的酒店上班,酒店上班,酒店打工環境、上班條件給水水們。心動嗎!? 趕快來填寫你的酒店上班履歷表

水水們妳有缺現領、想要兼職、有缺錢的煩腦嗎?想到日本留學缺錢嗎?妳是傳播妹??想要擁有高時薪又輕鬆的賺錢,酒店和,假日打工,假日兼職賺錢的機會嗎??想實現夢想卻又缺錢沒錢嗎!??
艾葳酒店台北酒店經紀招兵買馬!!徵專業的酒店打工,想要去酒店的水水,想要短期日領,酒店日領,禮服酒店,制服店,酒店經紀,ktv酒店,便服店,酒店工作,禮服店,酒店小姐,酒店經紀人,
等相關服務 幫您快速的實現您的夢想~!!

Anonymous said...

JK人妻アニメ巨乳SM痴女熟女ナース盗撮素人エロ動画JK人妻アニメ巨乳熟女痴女ナースSM盗撮素人芸能芸能人芸能yourfilehostyourfilehostyourfilehost動画ファイルナビゲーターyourfilehostグラビアアイドルイラマチオyourfilehost
yourfilehostyourfilehostyourfilehostyourfilehost無修正yourfilehostyourfilehostアゲサゲパンチラパンストおっぱいYouTubeYouTubeYouTubeYouTubeYouTubeYouTubeYouTube

Anonymous said...

痴女熟女おっぱいおしりロリ手こき素人エロ動画おまんこおまんこおまんこおまんこおまんこおまんこおまんこおまんこ下着フェチ芸能麻美ゆまAV女優浜崎りお吉沢明歩桜木凛大沢佑香Rio高坂保奈美佐藤美紀つぼみ大橋未久佳山三花川上ゆう橘れもんアダルト動画エロ動画エロ動画ニコ動画ようつべようつべdmmユーチューブエロ動画えろつべ無料アダルト無修正月野りさ三村翔子希崎ジェシカ大塚咲JK人妻

KM said...

手島優大堀恵杉原杏璃川奈栞ロリエロ10代エロ華彩なな次原かな風間ゆみ風間ゆみ立花里子鮎川なおAV女優フェラフェラチオフェラフェラフェラフェラフェラフェラチオフェラチオフェラチオエッチエッチエッチエッチエッチアダルト無料アダルトアダルト無料アダルトアダルトアダルト動画エロアニメえろアニメ堤さやか及川奈央小林ひとみ長瀬愛グラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアアイドルグラビアヌード

KM said...

眞鍋かをり高部知子長谷川ちひろ有川知里杉原杏璃西田麻衣松金洋子森下悠里滝沢乃南篠崎愛桜田さくら真木よう子次原かな浅野光ほしのあき原幹恵南結衣花井美理中川杏奈河中あい池田夏希中村静香岡本果奈美秦みずほ三井麻由磯山さやか松岡音々前田敦子石原さとみ釈由美子浜田翔子浜田コウ黒田知永子上戸彩加護亜依サイン競馬南明奈優木まおみ川村ゆきえ佐々木希スザンヌ山本梓ゴランジェリー岡崎美女飯島愛樹まり子近親相姦朝岡実嶺高樹マリアあいだもも夏目ナナ紅音ほたる無料版無料版無料版

KM said...

アダルト無料アダルトアダルト無料アダルトアダルトアダルト動画エロアニメえろアニメエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログ

KM said...

エログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログ

KM said...

エログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログエログアダルトサイン競馬無修正

Bruce said...

Today,we are proud to announce the launch of the new wedding support service sell ffxi gil,packed with features sure to sell ffxi gils delight adventurers across Vana'diel looking to exchange eternal vows with their beloved!Responding to player demands for greater customization,the new service will grant brides and grooms freedom in choosing location,timing,dialogue,and sell Final Fantasy XI Gil more for their ceremony,allowing them to create a truly memorable event all their own.Information on all the features,including in-game sell ffxi gil item vendors and wedding certificates,can be found on the new wedding support site,so head on over sell ffxi gils and get started planning the wedding of your dreams sell Final Fantasy XIGil!

Anonymous said...

よろしくおねがいします。good good nice
逆援助

Anonymous said...

pay pal order diflucan lasix surgery eye generic Clomid cost Lexapro drug no prescription Keflex Overnight Fed Ex No Prescription keflex and acne keflex symptoms in dog alesse overnight delivery order cheap Clomid online amoxil and aspirin buy lexapo and side effects

Anonymous said...

diflucan cost Generic Augmentin and weight loss buy cialis online USA Flagyl ER buy Easily online buy flagyl drugs Cheap Ditropan Over Night Amoxil prescription ordering buy Augmentin online scams diflucan vytorin Clomid in USA Online Pharmacy

kiril said...

I am not able to login using: jimmy, test as user credentials.

What credentials should I use and where do I set up them up in order to test out the application?

Thank you.

Anonymous said...

We should be chary and particular in all the information we give. We should be especially careful in giving advice that we would not think of following ourselves. Most of all, we ought to refrain from giving advisor which we don't follow when it damages those who depreciate us at our word.

air compressor

[url=http://air-compressor-48.webs.com/apps/blog/]air compressor[/url]

Anonymous said...

酒店打工 酒店兼職
台北酒店 打工兼差 酒店工作 禮服酒店
酒店兼差 酒店上班 酒店應徵 酒店 酒店經紀

Anonymous said...

A man begins cutting his wisdom teeth the senior without surcease he bites on holiday more than he can chew.

Anonymous said...

アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト
アダルト

Anonymous said...

oZzy moved away some time ago, I miss his cock, for
always hungry for sex.
FUCK MY PUSSY!

my site - hcg injections
my webpage > hcg injections