[原创]使用Acegi时获取用户信息的几个函数

Acegi框架通过ThreadLocal存放用户信息,因此可以通过以下函数获取相关信息:

  /**
   * 取得当前用户名
   * 
@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;
  }

  
/**
   * 取得当前用户密码
   * 
@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;
  }

  
/**
   * 取得当前用户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 一餐三碗 阅读(2799) | 评论 (4)编辑 收藏

[转载]可重用的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 一餐三碗 阅读(1266) | 评论 (0)编辑 收藏

[转载]How to get (almost) 3 GB heap on Windows!

介绍如何使用JRockit 5.0 R26突破2G的单进程应用程序应用内存限制(最大能扩大到3.85 GB )

原文:http://dev2dev.bea.com/blog/hstahl/archive/2005/12/how_to_get_almo.html
posted @ 2005-12-08 11:38 一餐三碗 阅读(976) | 评论 (0)编辑 收藏

[原创]实战Acegi:使用Acegi作为基于Spring框架的WEB应用的安全框架

实战Acegi:使用Acegi作为基于Spring框架的WEB应用的安全框架

最近项目使用Acegi作为安全框架的实现,效果不错,就写了这篇文章作为总结.

对于任何一个完整的应用系统,完善的认证和授权机制是必不可少的。在基于SpringFramework的WEB应用中,
我们可以使用Acegi作为安全架构的实现。本文将介绍如何在基于Spring构架的Web应用中使用Acegi,并且详细介
绍如何配置和扩展Acegi框架以适应实际需要。

文章和代码下载:

http://www.blogjava.net/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

附注:

有些朋友询问我如何部署文中的例子,在此再次说明一下(文章中已经有提到):

Mysql的建表脚本在db目录下
为了减小体积,已经将WEB-INF\lib下的依赖包删除,请自行下载以下包,并拷贝至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网站下载。



posted @ 2005-12-06 10:49 一餐三碗 阅读(50028) | 评论 (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这几个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 一餐三碗 阅读(767) | 评论 (0)编辑 收藏

Acegi 0.9.0 发布

Acegi 0.9.0发布有好几天了,直接从0.8.3跳到0.9.0,应该有不小的变化。

Release Notes


转一篇文章:

How to upgrade from Acegi Security 0.8.3 to 0.9.0
posted @ 2005-11-14 21:22 一餐三碗 阅读(397) | 评论 (0)编辑 收藏

Dojo WYSIWYG web editor

Dojo 发布 WYSIWYG web editor

消息来源:

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

demo

posted @ 2005-11-09 09:08 一餐三碗 阅读(669) | 评论 (0)编辑 收藏

采用jxl实现数据库结果集导出到excel文件

     摘要: 采用jxl实现数据库结果集导出到excel文件 关键字: 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 一餐三碗 阅读(6706) | 评论 (4)编辑 收藏
仅列出标题
共2页: 上一页 1 2