[原創(chuàng)]使用Acegi時(shí)獲取用戶信息的幾個(gè)函數(shù)

          Acegi框架通過ThreadLocal存放用戶信息,因此可以通過以下函數(shù)獲取相關(guān)信息:

            /**
             * 取得當(dāng)前用戶名
             * 
          @return
             
          */

            
          public static String getUsername(){
              Context context
          =ContextHolder.getContext();
              
          if(context!=null){
                
          if(context instanceof SecureContext){
                  SecureContext sc
          =(SecureContext)context;
                  Authentication auth
          =sc.getAuthentication();
                  
          if(auth!=null){
                    Object principal
          =auth.getPrincipal();
                    
          if(principal instanceof UserDetails) {
                      
          return ((UserDetails)principal).getUsername();
                    }
          else{
                      
          return principal.toString();
                    }

                  }

                }

              }

              
          return null;
            }

            
          /**
             * 取得當(dāng)前用戶密碼
             * 
          @return
             
          */

            
          public static String getPassword(){
              Context context
          =ContextHolder.getContext();
              
          if(context!=null){
                
          if(context instanceof SecureContext){
                  SecureContext sc
          =(SecureContext)context;
                  Authentication auth
          =sc.getAuthentication();
                  
          if(auth!=null){
                    Object principal
          =auth.getPrincipal();
                    
          if(principal instanceof UserDetails) {
                      
          return ((UserDetails)principal).getPassword();
                    }
          else{
                      
          return null;
                    }

                  }

                }

              }

              
          return null;
            }

            
          /**
             * 取得當(dāng)前用戶session id
             * 
          @return sessionid or null
             
          */

            
          public static String getSessionID(){
              Context context
          =ContextHolder.getContext();
              
          if(context!=null){
                
          if(context instanceof SecureContext){
                  SecureContext sc
          =(SecureContext)context;
                  Authentication auth
          =sc.getAuthentication();
                  
          if(auth!=null){
                    Object details
          =auth.getDetails();
                    
          if(details instanceof WebAuthenticationDetails) {
                      
          return ((WebAuthenticationDetails)details).getSessionId();
                    }
          else{
                      
          return null;
                    }

                  }

                }

              }

              
          return null;
            }

          posted @ 2006-03-03 16:17 一餐三碗 閱讀(2824) | 評(píng)論 (4)編輯 收藏

          [轉(zhuǎn)載]可重用的AJAX 控件(AJAX Widgets)列表

          出處:

          http://www.maxkiesler.com/index.php/weblog/comments/downloadable_web_20_and_ajax_widgets1/

          Downloadable Web 2.0 and AJAX Widgets

          image It seems as though every other day a new web 2.0 or AJAX widget comes to the attention of del.icio.us or Google. Many user interface elements lend themselves to being "ajaxified". Calendars, image galleries, contact forms and auto-complete search functions are currently very popular. The problem is how to find working and downloadable examples. This post is an attempt to provide a list of the current best of the best web 2.0 and AJAX widgets that can be downloaded and integrated into your website.


          I've been looking at AJAX widgets for about six months now through my own site mHub so these are ones 've downloaded and installed so I've made sure they are understandable by the average designer or developer.

          Before you use the following widgets, it would be a good idea to read the following articles. These articles will guide you on what to do and what not to do with AJAX. Have fun. : )

          Jeffrey Veen posts: Designing for the subtlety of Ajax

          Increasing the Strength of Ajax
          Alex Bosworth posts Ajax Mistakes

          AJAX: Image Galleries
          Zen Photo
          One of the nicest and most complete image gallery with AJAX functions. Features include uploading, comments, AJAX-powered edit-while-you-browse, and a theme engine.

          AJAX Image Gallery Example - Alpha Release
          Both of these are extreme alpha developer releases. These two examples are really mash-ups of existing code to show what is possible.

          AJAX Calendars
          Monket Calendar
          An Ajax enabled online calendar. Drag and drop events to change dates, drag the start/end of an event to create multi-day events, create and edit events without refreshing the page, all with an iCal style interface.The current release works in all major browsers (Firefox, Opera, Safari, and Internet Explorer). IE support still has a few bugs, namely the previous/next month links not working, and the need to click on a multi-day event before you can resize it.

          AJAX Contact Forms
          Dustin's Ajax Contact Form
          At this point this is probably the most used AJAX contact form on the web. I first found it right after he first made one for himself and announced it but had no download or documentation. Now he has a nice page devoted to his easy to use AJAX contact form with a download and documentation.

          AJAX and PHP Form Processing
          This is a nice tutorial, with example file that shows you how to make a php contact form with some easy to understand AJAX effects from Scriptaculous.

          The Zapatec AJAX Forms
          Very nicely executed forms with a stripped down free download. These forms, "perform validation, provide feedback, and display error messages that enrich the user's experience while reducing the communications with the server behind the scenes." The paid versions have some amazing functionality.

          Ajax Keyword Suggest
          Ajax Keyword Suggest Demo
          Want to add Keyword Suggest functionality into your site without installing new software? No Problem. Simply Login to ajaxed.com and create and customize your own Keyword Suggest List. All you have to do is copy and paste a small piece of code into your html page and you'll have the feature running instantly.

          Ajax Suggest box for HTML Forms
          Tutorial explaining how to use Ajax (Asynchronous Javascript and XML) to create a drop-down 'suggest' box for form fields which updates as you type by querying the server in the background. Similar to the 'Google Suggest' application. Full tutorial, code snippets and further reources.

          AJAX Login Systems
          Creating a secure login system using XMLHttpRequest
          This is an example of a login system that does not require page refreshes, but is still very secure.

          AJAX Slideshows
          AJAX Slideshow
          It resizes, it transitions, it fades in and out and it's not flash! The new AJAX slideshow on the homepage of my site comes to you courtesy of Scott Upton at Uptonic.

          AJAX Surveys
          Asynchronous Polling
          This example shows how you can use AJAX to do server-side polling without to update page data without a page refresh.

          Tabbed AJAX Websites
          Make an AJAX Website in Less than 10 Minutes
          I've been toying around with AJAX apps and XMLHttpRequest but have wanted to put up a site that loads all of its content asynchronously. If you're like me and you learn best from working with examples you're only 10 minutes away from your first AJAX website.

          Ajax Project - Tabbed Page Interface

          There are quite a few Javascript implementations of tabbed interfaces out there on the web. How much better, though, to be able to change from pagetab to pagetab without a page refresh? Here's an example of a tabbed interface using Ajax to load the new pages.

          posted @ 2006-02-09 09:24 一餐三碗 閱讀(1284) | 評(píng)論 (0)編輯 收藏

          [轉(zhuǎn)載]How to get (almost) 3 GB heap on Windows!

          介紹如何使用JRockit 5.0 R26突破2G的單進(jìn)程應(yīng)用程序應(yīng)用內(nèi)存限制(最大能擴(kuò)大到3.85 GB )

          原文:http://dev2dev.bea.com/blog/hstahl/archive/2005/12/how_to_get_almo.html
          posted @ 2005-12-08 11:38 一餐三碗 閱讀(997) | 評(píng)論 (0)編輯 收藏

          [原創(chuàng)]實(shí)戰(zhàn)Acegi:使用Acegi作為基于Spring框架的WEB應(yīng)用的安全框架

          實(shí)戰(zhàn)Acegi:使用Acegi作為基于Spring框架的WEB應(yīng)用的安全框架

          最近項(xiàng)目使用Acegi作為安全框架的實(shí)現(xiàn),效果不錯(cuò),就寫了這篇文章作為總結(jié).

          對(duì)于任何一個(gè)完整的應(yīng)用系統(tǒng),完善的認(rèn)證和授權(quán)機(jī)制是必不可少的。在基于SpringFramework的WEB應(yīng)用中,
          我們可以使用Acegi作為安全架構(gòu)的實(shí)現(xiàn)。本文將介紹如何在基于Spring構(gòu)架的Web應(yīng)用中使用Acegi,并且詳細(xì)介
          紹如何配置和擴(kuò)展Acegi框架以適應(yīng)實(shí)際需要。

          文章和代碼下載:

          http://www.aygfsteel.com/Files/youlq/Acegi.zip


          注意:許多朋友在部署上遇到一些麻煩,所以我將可以部署的完整的war文件傳上來,注意:java代碼在acegi-sample.war\WEB-INF 目錄下,例子需要Mysql,建庫腳本在acegi-sample.war\db目錄下。

          acegi-sample.part1.rar
          acegi-sample.part2.rar
          acegi-sample.part3.rar
          acegi-sample.part4.rar

          附注:

          有些朋友詢問我如何部署文中的例子,在此再次說明一下(文章中已經(jīng)有提到):

          Mysql的建表腳本在db目錄下
          為了減小體積,已經(jīng)將WEB-INF\lib下的依賴包刪除,請(qǐng)自行下載以下包,并拷貝至WEB-INF\lib下:
          spring-1.2.4.jar
          acegi-security-0.8.3.jar
          aopalliance-1.0.jar
          c3p0-0.9.0.jar
          commons-logging-1.0.4.jar
          ehcache-1.1.jar
          log4j-1.2.8.jar
          mysql-connector-java-3.1.10-bin.jar
          oro-2.0.8.jar

          提示:
          acegi-security-0.8.3.jar
          aopalliance-1.0.jar
          c3p0-0.9.0.jar
          commons-logging-1.0.4.jar
          ehcache-1.1.jar
          log4j-1.2.8.jar
          oro-2.0.8.jar
          可以在acegi-security-0.8.3.zip所帶的acegi-security-sample-contacts-filter.war中找到。
          spring-1.2.4.jar
          mysql-connector-java-3.1.10-bin.jar
          要分別到springframework和mysql網(wǎng)站下載。



          posted @ 2005-12-06 10:49 一餐三碗 閱讀(50156) | 評(píng)論 (72)編輯 收藏

          鏈接:AWT, Swing, SWT, and JFace: A comparison of Java GUI libraries

          原文見

          http://www.tomlauren.com/weblog/archives/000022.html


          文章橫向比較了AWT, Swing, SWT, and JFace這幾個(gè)java gui 庫,并且給出了比較示例代碼。

          最后給出了比較表格:


          GUI Library Native Speed Native Look Advanced Compontents Available External Jar(s) and java.library.path variable required Manual resource disposal necessary
          AWT Yes Yes No No No
          Swing No Not really Yes No No
          SWT & JFace Yes Yes Yes Yes Yes
          posted @ 2005-11-17 16:00 一餐三碗 閱讀(786) | 評(píng)論 (0)編輯 收藏

          Acegi 0.9.0 發(fā)布

          Acegi 0.9.0發(fā)布有好幾天了,直接從0.8.3跳到0.9.0,應(yīng)該有不小的變化。

          Release Notes


          轉(zhuǎn)一篇文章:

          How to upgrade from Acegi Security 0.8.3 to 0.9.0
          posted @ 2005-11-14 21:22 一餐三碗 閱讀(412) | 評(píng)論 (0)編輯 收藏

          Dojo WYSIWYG web editor

          Dojo 發(fā)布 WYSIWYG web editor

          消息來源:

          http://dojotoolkit.org/docs/rich_text.html

          demo

          posted @ 2005-11-09 09:08 一餐三碗 閱讀(681) | 評(píng)論 (0)編輯 收藏

          采用jxl實(shí)現(xiàn)數(shù)據(jù)庫結(jié)果集導(dǎo)出到excel文件

               摘要: 采用jxl實(shí)現(xiàn)數(shù)據(jù)庫結(jié)果集導(dǎo)出到excel文件 關(guān)鍵字: jxl, excel, servlet代碼:servlet:import?jxl.WorkbookSettings;import?jxl.Workbook;import?jxl.write.WritableWorkbook;import?jxl.write.WritableSheet;import?j...  閱讀全文
          posted @ 2005-11-06 16:04 一餐三碗 閱讀(6721) | 評(píng)論 (4)編輯 收藏
          僅列出標(biāo)題
          共2頁: 上一頁 1 2 
          主站蜘蛛池模板: 阿拉善右旗| 会昌县| 汉中市| 富平县| 浦东新区| 施甸县| 宁远县| 宜兰县| 大宁县| 长葛市| 鄄城县| 平和县| 伊春市| 冀州市| 疏附县| 黄龙县| 璧山县| 分宜县| 定襄县| 韩城市| 浮梁县| 北辰区| 临夏市| 封丘县| 乌拉特后旗| 前郭尔| 襄樊市| 永靖县| 黄山市| 淮滨县| 伊宁市| 西乌珠穆沁旗| 福泉市| 湾仔区| 克东县| 青冈县| 宁德市| 宁海县| 奉化市| 安吉县| 丹东市|