锘??xml version="1.0" encoding="utf-8" standalone="yes"?>综合偷自拍亚洲乱中文字幕,亚洲AV无码成人精品区天堂,亚洲AV无码专区国产乱码4SEhttp://m.tkk7.com/fisher/category/17937.html澶╄鍋ワ紝鍚涘瓙浠ヨ嚜寮轟笉鎭傚湴鍔垮潳錛屽悰瀛愪互鍘氬痙杞界墿銆?/description>zh-cnWed, 28 Feb 2007 03:43:55 GMTWed, 28 Feb 2007 03:43:55 GMT60鐢ˋcegi涓轟綘鐨凷pring搴旂敤鍔犳妸閿侊紒(杞?http://m.tkk7.com/fisher/articles/92379.htmlFisherFisherMon, 08 Jan 2007 07:14:00 GMThttp://m.tkk7.com/fisher/articles/92379.htmlhttp://m.tkk7.com/fisher/comments/92379.htmlhttp://m.tkk7.com/fisher/articles/92379.html#Feedback0http://m.tkk7.com/fisher/comments/commentRss/92379.htmlhttp://m.tkk7.com/fisher/services/trackbacks/92379.html
[綆浠媇
瀵逛簬涓涓吀鍨嬬殑Web搴旂敤錛屽畬鍠勭殑璁よ瘉鍜屾巿鏉冩満鍒舵槸蹇呬笉鍙皯鐨勶紝鍦⊿pringFramework涓紝Juergen Hoeller鎻愪緵鐨勮寖渚婮PetStore緇欎簡涓浜涜繖鏂歸潰鐨勪粙緇嶏紝浣嗚繕榪滆繙涓嶅錛孉cegi鏄竴涓笓闂ㄤ負SpringFramework鎻愪緵瀹夊叏鏈哄埗鐨?欏圭洰錛屽叏縐頒負Acegi Security System for Spring錛屽綋鍓嶇増鏈負0.5.1錛屽氨鍏剁洰鍓嶆彁渚涚殑鍔熻兘錛屽簲璇ュ彲浠ユ弧瓚崇粷澶у鏁板簲鐢ㄧ殑闇姹傘?br />
鏈枃鐨勪富瑕佺洰鐨勬槸甯屾湜鑳藉璇存槑濡備綍鍦ㄥ熀浜嶴pring鏋勬灦鐨刉eb搴旂敤涓嬌鐢ˋcegi錛岃屼笉鏄緇嗕粙緇嶅叾涓殑姣忎釜鎺ュ彛銆佹瘡涓被銆傛敞鎰忥紝鍗充嬌瀵瑰凡緇忓瓨鍦ㄧ殑Spring搴旂敤錛岄氳繃涓嬮潰浠嬬粛鐨勬楠わ紝涔熷彲浠ラ┈涓婁韓鍙楀埌Acegi鎻愪緵鐨勮璇佸拰鎺堟潈銆?/font>

[鍩虹宸ヤ綔]

鍦ㄤ綘鐨刉eb搴旂敤鐨刲ib涓坊鍔燗cegi涓嬭澆鍖呬腑鐨刟cegi-security.jar

[web.xml]
瀹炵幇璁よ瘉鍜屾巿鏉冪殑鏈甯哥敤鐨勬柟娉曟槸閫氳繃filter錛孉cegi浜︽槸濡傛錛岄氬父Acegi闇瑕佸湪web.xml娣誨姞浠ヤ笅5涓猣ilter:

<filter>
聽 <filter-name>Acegi Channel Processing Filter</filter-name>
聽 <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
聽 <init-param>
聽聽聽 <param-name>targetClass</param-name>
聽聽聽 <param-value>net.sf.acegisecurity.securechannel.ChannelProcessingFilter</param-value>
聽 </init-param>
</filter>
<filter>
聽 <filter-name>Acegi Authentication Processing Filter</filter-name>
聽 <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
聽 <init-param>
聽聽聽 <param-name>targetClass</param-name>
聽聽聽 <param-value>net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter</param-value>
聽 </init-param>
</filter>
<filter>
聽 <filter-name>Acegi HTTP BASIC Authorization Filter</filter-name>
聽 <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
聽 <init-param>
聽聽聽 <param-name>targetClass</param-name>
聽聽聽 <param-value>net.sf.acegisecurity.ui.basicauth.BasicProcessingFilter</param-value>
聽 </init-param>
</filter>
<filter>
聽 <filter-name>Acegi Security System for Spring Auto Integration Filter</filter-name>
聽 <filter-class>net.sf.acegisecurity.ui.AutoIntegrationFilter</filter-class>
</filter>
<filter>
聽 <filter-name>Acegi HTTP Request Security Filter</filter-name>
聽 <filter-class>net.sf.acegisecurity.util.FilterToBeanProxy</filter-class>
聽 <init-param>
聽聽聽 <param-name>targetClass</param-name>
聽聽聽 <param-value>net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter</param-value>
聽 </init-param>
</filter>

鏈鍏堝紩璧瘋糠鎯戠殑鏄痭et.sf.acegisecurity.util.FilterToBeanProxy錛孉cegi鑷繁鐨勬枃妗d笂瑙i噴鏄細 鈥淲hat聽 FilterToBeanProxy does is delegate the Filter's methods through to a bean which is obtained from the
Spring application context. This enables the bean to benefit from the Spring application context lifecycle support and configuration flexibility.鈥濓紝濡傚笇鏈涙繁絀剁殑璇濓紝鍘葷湅鐪嬫簮浠g爜搴旇涓嶉毦鐞嗚В銆?br />
鍐嶄笅鏉ュ氨鏄坊鍔爁ilter-mapping浜嗭細
<filter-mapping>
聽 <filter-name>Acegi Channel Processing Filter</filter-name>
聽 <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
聽 <filter-name>Acegi Authentication Processing Filter</filter-name>
聽 <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
聽 <filter-name>Acegi HTTP BASIC Authorization Filter</filter-name>
聽 <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
聽 <filter-name>Acegi Security System for Spring Auto Integration Filter</filter-name>
聽 <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
聽 <filter-name>Acegi HTTP Request Security Filter</filter-name>
聽 <url-pattern>/*</url-pattern>
</filter-mapping>

榪欓噷錛岄渶瑕佹敞鎰忎互涓嬩袱鐐癸細
1) 榪欏嚑涓猣ilter鐨勯『搴忔槸涓嶈兘鏇存敼鐨勶紝欏哄簭涓嶅灝嗘棤娉曟甯稿伐浣滐紱
2) 濡傛灉浣犵殑搴旂敤涓嶉渶瑕佸畨鍏ㄤ紶杈擄紝濡俬ttps錛屽垯灝?Acegi Channel Processing Filter"鐩稿叧鍐呭娉ㄩ噴鎺夊嵆鍙紱
3) 濡傛灉浣犵殑搴旂敤涓嶉渶瑕丼pring鎻愪緵鐨勮繙紼嬭闂満鍒訛紝濡侶essian and Burlap錛屽皢"Acegi HTTP BASIC Authorization
Filter"鐩稿叧鍐呭娉ㄩ噴鎺夊嵆鍙?br />
[applicationContext.xml]
鎺ヤ笅鏉ュ氨鏄娣誨姞applicationContext.xml涓殑鍐呭浜嗭紝浠庡垰鎵岶ilterToBeanFactory鐨勮В閲婂彲浠ョ湅鍑猴紝鐪熸鐨刦ilter閮?br />鍦⊿pring鐨刟pplicationContext涓鐞嗭細

1) 棣栧厛錛屼綘鐨勬暟鎹簱涓繀欏誨叿鏈変繚瀛樼敤鎴峰悕鍜屽瘑鐮佺殑table錛孉cegi瑕佹眰table鐨剆chema蹇呴』濡備笅錛?br />
CREATE TABLE users (
聽聽 聽username VARCHAR(50) NOT NULL PRIMARY KEY,
聽聽 聽password VARCHAR(50) NOT NULL,
聽聽 聽enabled BIT NOT NULL
);
CREATE TABLE authorities (
聽聽 聽username VARCHAR(50) NOT NULL,
聽聽 聽authority VARCHAR(50) NOT NULL
);
CREATE UNIQUE INDEX ix_auth_username ON authorities ( username, authority );
ALTER TABLE authorities ADD CONSTRAINT fk_authorities_users foreign key (username) REFERENCES users
(username);

2) 娣誨姞璁塊棶浣犵殑鏁版嵁搴撶殑datasource鍜孉cegi鐨刯dbcDao錛屽涓嬶細

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
聽 <property name="driverClassName"><value>${jdbc.driverClassName}</value></property>
聽 <property name="url"><value>${jdbc.url}</value></property>
聽 <property name="username"><value>${jdbc.username}</value></property>
聽 <property name="password"><value>${jdbc.password}</value></property>
</bean>
<bean id="jdbcDaoImpl" class="net.sf.acegisecurity.providers.dao.jdbc.JdbcDaoImpl">
聽 <property name="dataSource"><ref bean="dataSource"/></property>
</bean>


3) 娣誨姞DaoAuthenticationProvider:

<bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
聽 <property name="authenticationDao"><ref bean="authenticationDao"/></property>
聽 <property name="userCache"><ref bean="userCache"/></property>
</bean>

<bean id="userCache" class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
聽 <property name="minutesToIdle"><value>5</value></property>
</bean>


濡傛灉浣犻渶瑕佸瀵嗙爜鍔犲瘑錛屽垯鍦╠aoAuthenticationProvider涓姞鍏ワ細<property name="passwordEncoder"><ref
bean="passwordEncoder"/></property>錛孉cegi鎻愪緵浜嗗嚑縐嶅姞瀵嗘柟娉曪紝璇︾粏鎯呭喌鍙湅鍖?br />net.sf.acegisecurity.providers.encoding

4) 娣誨姞authenticationManager:

<bean id="authenticationManager" class="net.sf.acegisecurity.providers.ProviderManager">
聽 <property name="providers">
聽聽聽 <list>
聽聽聽聽聽 <ref bean="daoAuthenticationProvider"/>
聽聽聽 </list>
聽聽 </property>
</bean>


5) 娣誨姞accessDecisionManager:

<bean id="accessDecisionManager" class="net.sf.acegisecurity.vote.AffirmativeBased">
聽 <property name="allowIfAllAbstainDecisions">
聽聽聽 <value>false</value>
聽 </property>
聽 <property name="decisionVoters">
聽聽聽 <list><ref bean="roleVoter"/></list>
聽 </property>
</bean>
<bean id="roleVoter" class="net.sf.acegisecurity.vote.RoleVoter"/>

6) 娣誨姞authenticationProcessingFilterEntryPoint:

<bean id="authenticationProcessingFilterEntryPoint"
class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilterEntryPoint">
聽 <property name="loginFormUrl"><value>/acegilogin.jsp</value></property>
聽 <property name="forceHttps"><value>false</value></property>
</bean>


鍏朵腑acegilogin.jsp鏄櫥闄嗛〉闈紝涓涓渶綆鍗曠殑鐧誨綍欏甸潰濡備笅錛?br />
<%@ taglib prefix='c' uri='http://java.sun.com/jstl/core' %>
<%@ page import="net.sf.acegisecurity.ui.AbstractProcessingFilter" %>
<%@ page import="net.sf.acegisecurity.AuthenticationException" %>
<html>
聽 <head>
聽聽聽 <title>Login</title>
聽 </head>

聽 <body>
聽聽聽 <h1>Login</h1>
聽聽聽 <form action="<c:url value='j_acegi_security_check'/>" method="POST">
聽聽聽聽聽 <table>
聽聽聽聽聽聽聽 <tr><td>User:</td><td><input type='text' name='j_username'></td></tr>
聽聽聽聽聽聽聽 <tr><td>Password:</td><td><input type='password' name='j_password'></td></tr>
聽聽聽聽聽聽聽 <tr><td colspan='2'><input name="submit" type="submit"></td></tr>
聽聽聽聽聽聽聽 <tr><td colspan='2'><input name="reset" type="reset"></td></tr>
聽聽聽聽聽 </table>
聽聽聽 </form>
聽 </body>
</html>


7) 娣誨姞filterInvocationInterceptor:

<bean id="filterInvocationInterceptor"
class="net.sf.acegisecurity.intercept.web.FilterSecurityInterceptor">
聽 <property name="authenticationManager">
聽聽聽 <ref bean="authenticationManager"/>
聽 </property>
聽 <property name="accessDecisionManager">
聽聽聽 <ref bean="accessDecisionManager"/>
聽 </property>
聽 <property name="objectDefinitionSource">
聽聽聽 <value>
聽聽聽聽聽 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
聽聽聽聽聽 \A/sec/administrator.*\Z=ROLE_SUPERVISOR
聽聽聽聽聽 \A/sec/user.*\Z=ROLE_TELLER
聽聽聽 </value>
聽 </property>
</bean>


榪欓噷璇鋒敞鎰忥紝瑕乷bjectDefinitionSource涓畾涔夊摢浜涢〉闈㈤渶瑕佹潈闄愯闂紝闇瑕佹牴鎹嚜宸辯殑搴旂敤闇姹傝繘琛屼慨鏀癸紝鎴戜笂闈㈢粰鍑?br />鐨勫畾涔夌殑鎰忔濇槸榪欐牱鐨勶細
聽a. CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON鎰忔濇槸鍦ㄦ瘮杈冭姹傝礬寰勬椂鍏ㄩ儴杞崲涓哄皬鍐?br />聽b. \A/sec/administrator.*\Z=ROLE_SUPERVISOR鎰忔濇槸鍙湁鏉冮檺涓篟OLE_SUPERVISOR鎵嶈兘璁塊棶/sec/administrator*鐨勯〉闈?br />聽c. \A/sec/user.*\Z=ROLE_TELLER鎰忔濇槸鍙湁鏉冮檺涓篟OLE_TELLER鐨勭敤鎴鋒墠鑳借闂?sec/user*鐨勯〉闈?br />
8) 娣誨姞securityEnforcementFilter:

<bean id="securityEnforcementFilter" class="net.sf.acegisecurity.intercept.web.SecurityEnforcementFilter">
聽 <property name="filterSecurityInterceptor">
聽聽聽 <ref bean="filterInvocationInterceptor"/>
聽 </property>
聽 <property name="authenticationEntryPoint">
聽聽聽 <ref bean="authenticationProcessingFilterEntryPoint"/>
聽 </property>
</bean>

9) 娣誨姞authenticationProcessingFilter:

<bean id="authenticationProcessingFilter"
class="net.sf.acegisecurity.ui.webapp.AuthenticationProcessingFilter">
聽 <property name="authenticationManager">
聽聽聽 <ref bean="authenticationManager"/>
聽 </property>
聽 <property name="authenticationFailureUrl">
聽聽聽 <value>/loginerror.jsp</value>
聽 </property>
聽 <property name="defaultTargetUrl">
聽聽聽 <value>/</value>
聽 </property>
聽 <property name="filterProcessesUrl">
聽聽聽 <value>/j_acegi_security_check</value>
聽 </property>
</bean>

鍏朵腑authenticationFailureUrl鏄璇佸け璐ョ殑欏甸潰銆?br />
10) 濡傛灉闇瑕佷竴浜涢〉闈㈤氳繃瀹夊叏閫氶亾鐨勮瘽錛屾坊鍔犱笅闈㈢殑閰嶇疆:

<bean id="channelProcessingFilter" class="net.sf.acegisecurity.securechannel.ChannelProcessingFilter">
聽 <property name="channelDecisionManager">
聽聽聽 <ref bean="channelDecisionManager"/>
聽 </property>
聽 <property name="filterInvocationDefinitionSource">
聽聽聽 <value>
聽聽聽聽聽 CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
聽聽聽聽聽 \A/sec/administrator.*\Z=REQUIRES_SECURE_CHANNEL
聽聽聽聽聽 \A/acegilogin.jsp.*\Z=REQUIRES_SECURE_CHANNEL
聽聽聽聽聽 \A/j_acegi_security_check.*\Z=REQUIRES_SECURE_CHANNEL
聽聽聽聽聽 \A.*\Z=REQUIRES_INSECURE_CHANNEL
聽聽聽 </value>
聽 </property>
</bean>

<bean id="channelDecisionManager" class="net.sf.acegisecurity.securechannel.ChannelDecisionManagerImpl">
聽 <property name="channelProcessors">
聽聽聽 <list>
聽聽聽聽聽 <ref bean="secureChannelProcessor"/>
聽聽聽聽聽 <ref bean="insecureChannelProcessor"/>
聽聽聽 </list>
聽 </property>
</bean>
<bean id="secureChannelProcessor" class="net.sf.acegisecurity.securechannel.SecureChannelProcessor"/>
<bean id="insecureChannelProcessor" class="net.sf.acegisecurity.securechannel.InsecureChannelProcessor"/>


[緙哄皯浜嗕粈涔堬紵]
Acegi鐩墠鎻愪緵浜嗕袱縐?secure object"錛屽垎鍒欏甸潰鍜屾柟娉曡繘琛屽畨鍏ㄨ璇佺鐞嗭紝鎴戣繖閲屼粙緇嶇殑鍙槸鍒╃敤
FilterSecurityInterceptor瀵硅闂〉闈㈢殑鏉冮檺鎺у埗錛岄櫎姝や箣澶栵紝Acegi榪樻彁渚涗簡鍙﹀涓涓狪nterceptor鈥斺?br />MethodSecurityInterceptor錛屽畠緇撳悎runAsManager鍙疄鐜板瀵硅薄涓殑鏂規硶鐨勬潈闄愭帶鍒訛紝浣跨敤鏂規硶鍙弬鐪婣cegi鑷甫鐨勬枃妗?br />鍜宑ontact鑼冧緥銆?br />
[鏈鍚庤璇寸殑]
鏈潵浠ヤ負鍙槸璇存槑濡備綍浣跨敤Acegi鑰屽凡錛屽簲璇ラ潪甯哥畝鍗曪紝浣嗙湡姝e啓璧鋒潵鎵嶅彂鐜版兂瑕佹潯鐞嗘竻妤氱殑鐞嗛『鎵鏈夐渶瑕佺殑bean榪樻槸寰?br />鍥伴毦鐨勶紝浣嗘効鎴戞病鏈夐仐婕忓お澶氫笢瑗匡紝濡傛灉鎴戠殑鏂囩珷鏈変粈涔堥仐婕忔垨閿欒鐨勮瘽錛岃繕璇峰弬鐪婣cegi鑷甫鐨剄uick-start鑼冧緥錛屼絾璇?br />娉ㄦ剰錛岃繖涓寖渚嬫槸涓嶈兘鐩存帴鎷挎潵鐢ㄧ殑銆?/font>


Fisher 2007-01-08 15:14 鍙戣〃璇勮
]]>
Spring涓瑼pplicationContext鍔犺澆鏈哄埗http://m.tkk7.com/fisher/articles/90130.htmlFisherFisherTue, 26 Dec 2006 07:48:00 GMThttp://m.tkk7.com/fisher/articles/90130.htmlhttp://m.tkk7.com/fisher/comments/90130.htmlhttp://m.tkk7.com/fisher/articles/90130.html#Feedback0http://m.tkk7.com/fisher/comments/commentRss/90130.htmlhttp://m.tkk7.com/fisher/services/trackbacks/90130.htmlSpring涓瑼pplicationContext鍔犺澆鏈哄埗銆?
聽聽聽聽鍔犺澆鍣ㄧ洰鍓嶆湁涓ょ閫夋嫨錛欳ontextLoaderListener鍜孋ontextLoaderServlet銆?
聽聽聽聽榪欎袱鑰呭湪鍔熻兘涓婂畬鍏ㄧ瓑鍚岋紝鍙槸涓涓槸鍩轟簬Servlet2.3鐗堟湰涓柊寮曞叆鐨凩istener鎺ュ彛瀹炵幇錛岃屽彟涓涓熀浜嶴ervlet鎺ュ彛瀹炵幇銆傚紑鍙戜腑鍙牴鎹洰鏍嘩eb瀹瑰櫒鐨勫疄闄呮儏鍐佃繘琛岄夋嫨銆?

閰嶇疆闈炲父綆鍗曪紝鍦╳eb.xml涓鍔狅細
<listener>
聽聽<listener-class>
聽聽聽聽聽聽聽org.springframework.web.context.ContextLoaderListener
聽聽</listener-class>
</listener>
鎴栵細
<servlet>
聽聽聽聽<servlet-name>context</servlet-name>
聽聽聽聽<servlet-class>
聽聽聽聽聽聽聽org.springframework.web.context.ContextLoaderServlet
聽聽聽聽</servlet-class>
聽聽聽聽<load-on-startup>1</load-on-startup>
</servlet>

閫氳繃浠ヤ笂閰嶇疆錛學eb瀹瑰櫒浼氳嚜鍔ㄥ姞杞?WEB-INF/applicationContext.xml鍒濆鍖?
ApplicationContext瀹炰緥錛屽鏋滈渶瑕佹寚瀹氶厤緗枃浠朵綅緗紝鍙氳繃context-param鍔犱互鎸囧畾錛?
<context-param>
聽聽聽聽<param-name>contextConfigLocation</param-name>
聽聽聽聽<param-value>/WEB-INF/myApplicationContext.xml</param-value>
</context-param>

閰嶇疆瀹屾垚涔嬪悗錛屽嵆鍙氳繃
聽WebApplicationContextUtils.getWebApplicationContext鏂規硶鍦╓eb搴旂敤涓幏鍙朅pplicationContext寮曠敤銆?

濡傦細ApplicationContext聽ctx=WebApplicationContextUtils.getWebApplicationContext();
聽聽聽聽LoginAction聽action=(LoginAction)ctx.getBean("action");


杞澆錛?a >http://hi.baidu.com/jgs80/blog/item/307a40a794a7ad95d1435896.html

Fisher 2006-12-26 15:48 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 四虎永久免费地址在线观看| 亚洲国产综合自在线另类| 在线观看免费人成视频色9| a级毛片免费全部播放| 尤物视频在线免费观看| 亚洲日韩看片无码电影| 亚洲国产精品综合久久网各| 亚洲国产精品va在线播放| 亚洲国产黄在线观看| 国产高清免费的视频| 青娱乐免费视频在线观看| 一级毛片成人免费看免费不卡| 国产在线国偷精品产拍免费| 无码少妇精品一区二区免费动态| 亚洲成av人在线视| 久久久久亚洲AV综合波多野结衣 | 国产免费黄色无码视频 | 国产黄在线观看免费观看不卡| 成年男女免费视频网站| 中国一级特黄高清免费的大片中国一级黄色片| 亚洲一区二区三区久久| 亚洲精品综合一二三区在线| 国产精品亚洲精品日韩已满| 最新亚洲成av人免费看| 亚洲男人的天堂在线va拉文| 国产区卡一卡二卡三乱码免费| 一边摸一边爽一边叫床免费视频 | 九九99热免费最新版| 深夜福利在线免费观看| 国产亚洲精品2021自在线| 亚洲爆乳无码专区www| 亚洲AV色吊丝无码| 精品国产日韩久久亚洲| 亚洲日韩中文字幕一区| 亚洲高清乱码午夜电影网| 亚洲成a∨人片在无码2023| 国产精品久久亚洲一区二区| 黄色a三级三级三级免费看| 免费一区二区三区在线视频| 亚洲黄片手机免费观看| 国产偷伦视频免费观看|