將Java進行到底
          將Java進行到底
          posts - 15,  comments - 66,  trackbacks - 0

          這兩天嘗試整合一下Acegi、Spring和Struts。配置文件如下:
          web.xml文件內容詳細:



          ?Acegi Sample Application

          ?
          ?
          ??contextConfigLocation
          ??
          ???/WEB-INF/applicationContext.xml
          ???/WEB-INF/applicationContext-acegi.xml
          ??

          ?

          ?
          ??log4jConfigLocation
          ??/WEB-INF/classes/log4j.properties
          ?

          ?
          ?
          ??Acegi Filter Chain Proxy
          ??
          ???net.sf.acegisecurity.util.FilterToBeanProxy
          ??

          ??
          ???targetClass
          ???
          ????net.sf.acegisecurity.util.FilterChainProxy
          ???

          ??

          ?

          ?
          ??Acegi Filter Chain Proxy
          ??/*
          ?

          ?
          ?
          ??
          ???org.springframework.web.context.ContextLoaderListener
          ??

          ?

          ?
          ??
          ???org.springframework.web.util.Log4jConfigListener
          ??

          ?

          ?


          ?

          ?
          ??action
          ??
          ???org.apache.struts.action.ActionServlet
          ??

          ??
          ???config
          ???/WEB-INF/struts-config.xml
          ??

          ??
          ???debug
          ???3
          ??

          ??
          ???detail
          ???3
          ??

          ??0
          ?

          ?
          ??action
          ??*.do
          ?


          spring的配置文件我分為兩個:
          一個是applicationContext.xml,配置了spring整合Hibernate的部分,包括Datasource和DAO部分,內容如下:


          ???class="org.apache.commons.dbcp.BasicDataSource"
          ??destroy-method="close">
          ??
          ???com.mysql.jdbc.Driver
          ??

          ??
          ???jdbc:mysql://localhost/lcdis
          ??

          ??
          ???root
          ??

          ??
          ???
          ??

          ?

          ???class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
          ??
          ???
          ????com/laf/bo/Example.hbm.xml
          ???

          ??

          ??
          ???
          ????
          ?????org.hibernate.dialect.MySQLDialect
          ????

          ????true
          ????
          ?????true
          ????

          ???

          ??

          ??
          ???
          ??

          ?

          ???class="org.springframework.orm.hibernate3.HibernateTransactionManager">
          ??
          ???
          ??

          ?

          ???class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
          ??
          ???
          ??

          ??
          ???
          ??

          ??
          ???
          ????
          ?????PROPAGATION_REQUIRED,readOnly,-BusinessException
          ????

          ????
          ?????PROPAGATION_REQUIRED,-BusinessException
          ????

          ????
          ?????PROPAGATION_REQUIRED,-BusinessException
          ????

          ????
          ?????PROPAGATION_REQUIRED,-BusinessException
          ????

          ???

          ??

          ?

          ???class="com.laf.bd.BusinessServiceImpl">
          ??
          ???
          ??

          ?

          ?
          ??
          ???
          ??

          ?




          另外一個.xml,配置了Acegi相關內容:

          ?
          ?

          ?
          ???class="net.sf.acegisecurity.util.FilterChainProxy">
          ??
          ???
          ????CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
          ????PATTERN_TYPE_APACHE_ANT
          ????/**=httpSessionContextIntegrationFilter,authenticationProcessingFilter,?securityEnforcementFilter
          ???

          ??

          ?

          ???class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
          ??
          ???
          ??

          ??
          ???/login.jsp
          ??

          ??
          ???/
          ??

          ??
          ???/j_acegi_security_check.do
          ??

          ?

          ???class="net.sf.acegisecurity.providers.ProviderManager">
          ??
          ???
          ????
          ???

          ??

          ?


          ???class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
          ??
          ???
          ??

          ??
          ???
          ??

          ??
          ?

          ???class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
          ??
          ???
          ??

          ?

          ???class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" />
          ???class="org.springframework.cache.ehcache.EhCacheFactoryBean">
          ??
          ???
          ??

          ??
          ???userCache
          ??

          ?

          ???class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
          ??
          ???
          ??

          ?

          ???class="net.sf.acegisecurity.providers.encoding.Md5PasswordEncoder">
          ?

          ???class="net.sf.acegisecurity.providers.anonymous.AnonymousProcessingFilter">
          ??
          ???foobar
          ??

          ??
          ???anonymousUser,ROLE_ANONYMOUS
          ??

          ?

          ???class="net.sf.acegisecurity.providers.anonymous.AnonymousAuthenticationProvider">
          ??
          ???foobar
          ??

          ?

          ???class="net.sf.acegisecurity.context.HttpSessionContextIntegrationFilter">
          ??
          ???
          ????net.sf.acegisecurity.context.security.SecureContextImpl
          ???

          ??

          ?

          ?

          ???class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
          ??
          ???
          ??

          ??
          ???
          ??

          ?

          ?
          ???class="net.sf.acegisecurity.vote.AffirmativeBased">
          ??
          ???false
          ??

          ??
          ???
          ????
          ???

          ??

          ?

          ?
          ???class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
          ??
          ???
          ??

          ??
          ???
          ??

          ??
          ???
          ????CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
          ????PATTERN_TYPE_APACHE_ANT
          ????/index.jsp=ROLE_SUPERVISOR
          ????/hello.jsp=ROLE_TELLER
          ????/*.do=ROLE_TELLER
          ???

          ??

          ?

          ???class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
          ??
          ???/login.jsp
          ??

          ??
          ???false
          ??

          ?




          注意兩處顏色不同的部分配置,是Acegi需要配合struts的內容。

          Spring的配置我這里就不詳細描述,這里主要談談對Acegi的看法。

          我用的是Acegi0.8.3,目前是最新版。可以到項目主頁下載:http://acegisecurity.sourceforge.net/?

          各位也看到了,Acegi的配置還是比較復雜,要了解幾個主要的類,如下圖:

          applicationContext-acegi.jpg

          如果嫌麻煩,就直接拷貝過去使用就可以了。只要修改objectDefinitionSource部分的權限配置就行。

          再附上登錄頁面login.jsp的片斷:

          ???
          ??? ?
          ??? ??
          ??? ?
          ??? ?
          ??? ??
          ??? ?
          ??? ?
          ??? ??
          ??? ?
          ???

          ??? ???User:
          ??? ??

          ??? ???Password:
          ??? ??

          ??? ???
          ??? ??

          ???


          粗淺研究,首次涂鴉,希望有些可以供人參考之處,上面內容有很多寫的不夠詳盡,各位看官可以留言,或發郵件共同探討。

          posted on 2005-10-27 00:06 風蕭蕭 閱讀(1862) 評論(5)  編輯  收藏 所屬分類: 原創

          FeedBack:
          # re: 整合前臺技術acegi+spring+struts
          2006-12-25 22:42 | yesterday
          現實不正常啊,能正常顯示全部內容么?我現在正在做這樣的一個東西,急需指導,希望能得到你的代碼參考下,謝謝!
          20030704107@cs2.swfc.edu.cn  回復  更多評論
            
          # 我有意見。。。
          2007-03-13 11:49 | 周潤發的大哥
          我有意見。。。
          文章看不清楚,沒有參考價值啊!
          請您再整理一下,ok ?
          謝謝您了!
          交個朋友吧!qq:316451618  回復  更多評論
            
          # re: 整合前臺技術acegi+spring+struts
          2008-04-22 13:47 | waterloovx
          貼出來了,但是不容易看,能不能整理一下呢?這樣的文章參考價值不大  回復  更多評論
            
          # re: 整合前臺技術acegi+spring+struts
          2008-09-19 13:56 | ss
          你真的沒必要忒出來,寫得文章比較差,不過也許你技術很牛  回復  更多評論
            
          # re: 整合前臺技術acegi+spring+struts
          2008-09-19 13:56 | ss
          看來你也不更新自己的blog  回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          <2008年9月>
          31123456
          78910111213
          14151617181920
          21222324252627
          2829301234
          567891011

          常用鏈接

          留言簿(8)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊

          收藏夾

          myfriends

          opensource

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 平武县| 本溪市| 哈尔滨市| 张家界市| 阿城市| 修水县| 崇阳县| 长沙市| 清新县| 高密市| 漯河市| 木兰县| 刚察县| 广安市| 昌邑市| 沙田区| 砀山县| 遵化市| 巴东县| 闻喜县| 澎湖县| 涡阳县| 平武县| 东乡族自治县| 乃东县| 广平县| 桐乡市| 宣汉县| 通渭县| 东乡| 新巴尔虎左旗| 扶沟县| 封丘县| 蒙阴县| 保靖县| 安溪县| 赤峰市| 班玛县| 冕宁县| 吉安县| 建瓯市|