锘??xml version="1.0" encoding="utf-8" standalone="yes"?> 1.cas-server绔紝閰嶇疆鏂囦歡涓?WEB-INFO/cas-servlet.xml涓殑logoutController <bean id="logoutController" class="org.jasig.cas.web.LogoutController"
2.grails鐨剈rlmapping鎻掍歡錛屽鏋滄槧灝?#8220;/”鍒版煇涓猘ction錛岀洰鍓嶅ソ鍍忔槸涓嶆垚鍔熺殑錛屼絾鏄彧瑕佷笉鏄?#8220;/”錛屽垯娌℃湁榪欎釜闂銆傚鏋滈粯璁ょ殑鏍圭洰褰曚笉鏄痠ndex.gsp錛岃繖涓彲鑳介渶瑕佸湪璁塊棶“/”鏃惰繘琛岃煩杞殑澶勭悊銆?br />
]]>
]]>
鑰屽湪oracle涓嬪簲璇ヤ負
select password from user_login where username=? and enabled=1
涓昏鐢變簬oralce鍜宮ysql瀵筨oolean瀛楁鐨勫鐞嗕笉涓鑷村鑷寸殑銆?br />
]]>
p:centralAuthenticationService-ref="centralAuthenticationService"
p:logoutView="casLogoutView"
p:warnCookieGenerator-ref="warnCookieGenerator"
p:ticketGrantingTicketCookieGenerator-ref="ticketGrantingTicketCookieGenerator"
p:followServiceRedirects="true"/>
]]>
鍩烘湰闇姹傦細
1.cas server-3.4.5,casclient-3.2錛堝畼鏂圭増鏈級錛屽潎鍙湪cas瀹樻柟緗戠珯涓嬭澆錛?a >http://www.jasig.org
2.浣跨敤浣庢垚鏈殑http鍗忚榪涜浼犺緭錛屼亢涔頒笉璧穝sl璇佷功
3.閫氳繃jdbc榪涜鐢ㄦ埛楠岃瘉
4.闇瑕侀氳繃casserver鎻愪緵闄ょ櫥褰曠敤鎴峰悕浠ュ鐨勯檮鍔犱俊鎭?/p>
鍙傝冭祫鏂欙細
1.cas瀹樻柟緗戠珯鐨勭敤鎴峰府鍔╂墜鍐屽拰wiki
2.緗戝弸“鍩庡競鐚庝漢”鐨刡log錛?a >http://yuzhwe.javaeye.com/blog/830143
3.緗戝弸“鎮(zhèn)熺┖鎮(zhèn)熼亾”鐨刡log錛?a >http://llhdf.javaeye.com/blog/764385
4.鍏朵粬緗戝弸璐$尞鐨勭浉鍏崇殑blog錛岄兘鏄氳繃google鍑烘潵錛屽氨涓嶄竴涓鍒楀嚭浜嗭紝涓騫惰嚧璋紒錛侊紒
濂戒簡錛屼笅闈㈣繘鍏ユ棰橈紝濡傛灉鎮(zhèn)ㄤ笉鎯蟲祴璇曚腑鍑虹幇寮傚父鎯呭喌錛屾垨鏄幏鍙栦笉鍒扮浉鍏蟲暟鎹紝璇峰叧娉ㄦ枃涓殑綰㈣壊瀛椾綋閮ㄥ垎銆?/p>
錛?錛変嬌鐢╤ttp鍗忚鐨勮緗紝濡傛灉鎮(zhèn)ㄤ篃鍍忔垜涓鏍鳳紝涔頒笉璧穝sl鏁板瓧璇佷功錛屽瀹夊叏鐨勮姹備篃涓嶆槸鐗瑰埆鐨勬悶錛屼笅闈㈢殑閰嶇疆灝卞彲浠ュ府鍔╄В鍐寵繖涓棶棰橈細
鍦╟as-server-webapp涓殑/WEB-INF/spring-configuration/ticketGrantingTicketCookieGenerator.xml鏂囦歡涓湁濡備笅閰嶇疆
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
p:cookieSecure="true" //榛樿涓簍rue錛屼嬌鐢╤ttps,濡傛灉鍙渶瑕乭ttp錛屼慨鏀逛負false鍗沖彲
p:cookieMaxAge="-1"
p:cookieName="CASTGC"
p:cookiePath="/cas" />
錛?錛変嬌鐢╦dbc鏁版嵁婧愯繘琛岀敤鎴瘋璇侊紝闇瑕佷慨鏀筩as鐨刟uthenticationHandlers鏂瑰紡錛屽湪鏂囦歡/WEB-INF/deployerConfigContext.xml鏈夊涓嬮厤緗細
<property name="authenticationHandlers">
<list>
<!--
| This is the authentication handler that authenticates services by means of callback via SSL, thereby validating
| a server side SSL certificate.
+-->
<bean class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
p:httpClient-ref="httpClient" />
<!--
| This is the authentication handler declaration that every CAS deployer will need to change before deploying CAS
| into production. The default SimpleTestUsernamePasswordAuthenticationHandler authenticates UsernamePasswordCredentials
| where the username equals the password. You will need to replace this with an AuthenticationHandler that implements your
| local authentication strategy. You might accomplish this by coding a new such handler and declaring
| edu.someschool.its.cas.MySpecialHandler here, or you might use one of the handlers provided in the adaptors modules.
+-->
<!--<bean class="org.jasig.cas.authentication.handler.support.SimpleTestUsernamePasswordAuthenticationHandler" />-->
<bean class="org.jasig.cas.adaptors.jdbc.QueryDatabaseAuthenticationHandler">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="select password from userInfo where username=? and enabled=true" />
//鐢ㄦ埛瀵嗙爜緙栫爜鏂瑰紡
<property name="passwordEncoder"
ref="passwordEncoderBean"/>
</bean>
</list>
</property>
璇ュ睘鎬т腑鐨刲ist鍙鐢ㄤ竴涓璇侀氳繃鍗沖彲錛屽緩璁皢綰㈣壊閮ㄥ垎鏀懼湪絎竴浣嶏紝濡傛灉紜鍙敤jdbc涓縐嶆柟寮忥紝鍏朵粬璁よ瘉鏂瑰紡鍧囧彲鍒犻櫎銆傚彟澶栭渶瑕佸湪鍦ㄦ枃浠朵腑娣誨姞datasoure鍜宲assordEncoder涓や釜bean錛屽涓?/p>
<!-- Data source definition -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8</value> //濡傛灉浣跨敤mysql鏁版嵁搴擄紝搴旇鍔犱笂鍚庨潰鐨勭紪鐮佸弬鏁幫紝鍚﹀垯鍙兘瀵艱嚧瀹㈡埛绔TGT紲ㄦ嵁鏃犳硶璇嗗埆鐨勯棶棰?br />
</property>
<property name="username"><value>root</value></property>
<property name="password"><value>password</value></property>
</bean>
<bean id="passwordEncoderBean" class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder">
<constructor-arg value="SHA1" /> //cas
server榛樿鏀寔MD5鍜孲HA1涓ょ緙栫爜鏂瑰紡錛屽鏋滈渶瑕佸叾浠栫殑緙栫爜鏂瑰紡渚嬪SHA256,512絳夛紝鍙嚜琛屽疄鐜皁rg.jasig.cas.authentication.handler.PasswordEncoder鎺ュ彛
</bean>
闄勫姞澶囨敞錛氬鏋滄?zhèn)ㄦ槸鋴社敤cas server鐨勬簮鐮佽嚜琛岀紪璇戠殑璇濓紝闇瑕佸湪cas-server-web妯″潡鐨刾om.xml涓坊鍔犲涓嬫ā鍧楃殑渚濊禆錛?/p>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cas-server-support-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
騫舵坊鍔犲搴旀暟鎹簱鐨刯dbc鐨刯ar鍖呫?/p>
錛?錛夎cas server鎻愪緵鏇村鐨勭敤鎴鋒暟鎹叡瀹㈡埛绔嬌鐢?/p>
閫氳繃嫻嬭瘯錛岀敱浜巆as鐨勪唬鐮佹洿鏂拌繃紼嬩腑鐨勫彉鍖栬緝澶э紝鎵浠ュ寘鍏煎鐨勯棶棰樺ソ鍍忎竴鐩村瓨鍦紝鍦ㄦ祴璇曚腑鎴戝氨紕板埌榪囷紝鑺辮垂鏃墮棿姣旇緝澶氾紝寤鴻鍚屽浠湪浣跨敤榪囩▼涓嬌鐢ㄥ畼鏂圭殑鏈鏂扮殑鍙戝竷鐗堟湰銆傚湪鎴戜嬌鐢ㄧ殑榪欎釜鐗堟湰涓紝璇峰弬鑰冨墠闈㈢殑鍏充簬server鍜宑lient绔殑鐗堟湰璇存槑錛屽簲璇ユ病鏈夊寘鍐茬獊鐨勯棶棰橈紝嫻嬭瘯閫氳繃銆備笅闈㈣繘琛岄厤緗紝閰嶇疆鏂囦歡錛?WEB-INF/deployerConfigContext.xml
<property name="credentialsToPrincipalResolvers">
<list>
<!--<bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" />-->
<!-- modify on 2011-01-18,add user info -->
<bean class="org.jasig.cas.authentication.principal.UsernamePasswordCredentialsToPrincipalResolver" >
<property name="attributeRepository" > //涓鴻璇佽繃鐨勭敤鎴風(fēng)殑Principal娣誨姞灞炴?/font>
<ref local="attributeRepository"/>
</property>
</bean>
<bean
class="org.jasig.cas.authentication.principal.HttpBasedServiceCredentialsToPrincipalResolver" />
</list>
</property>
淇敼璇ユ枃浠朵腑榛樿鐨?font color="#ff0000"> attributeRepositorybean閰嶇疆
<!-- 鍦ㄨ繖閲岄厤緗幏鍙栨洿澶氱敤鎴風(fēng)殑淇℃伅 -->
<bean id="attributeRepository" class="org.jasig.services.persondir.support.jdbc.SingleRowJdbcPersonAttributeDao">
<constructor-arg index="0" ref="dataSource" />
<constructor-arg index="1" value="select id as UId, password_hint as ph from userInfo where username=? and enabled=true" />
<property name="queryAttributeMapping">
<map>
<entry key="username" value="uid"/><!-- 榪欓噷蹇呴』榪欎箞鍐欙紝緋葷粺浼氳嚜宸卞尮閰嶏紝璨屼技鍜寃here璇彞鍚庨潰鐨勭敤鎴峰悕瀛楁鐨勬嫾鍐欐病鏈変粈涔堝叧緋?-->
</map>
</property>
<!-- 瑕佽幏鍙栫殑灞炴у湪榪欓噷閰嶇疆 -->
<property name="resultAttributeMapping">
<map>
<entry key="UId" value="userId" /> //key涓哄搴旂殑鏁版嵁搴撳瓧孌靛悕縐幫紝value涓烘彁渚涚粰瀹㈡埛绔幏鍙栫殑灞炴у悕瀛楋紝緋葷粺浼氳嚜鍔ㄥ~鍏呭?br />
<entry key="ph" value="passwordHint" />
</map>
</property>
</bean>
澶囨敞錛氱綉涓婃湁寰堝鐨勫叧浜庤繖涓殑閰嶇疆錛屼絾鏄鏋滄?zhèn)ㄤ娇鐢ㄧ殑鏄垜鎻愪緵鐨勭増鏈垨鏄珮浜帢q欎釜鐗堟湰錛屽氨搴旇璞′笂闈㈣繖鏍烽厤緗紝鏃犵敤璐ㄧ枒錛岀綉涓婂ぇ閮ㄥ垎鐨勯厤緗兘鏄熀浜?br />
person-directory-impl,person-directory-api
1.1宸﹀彸鐨勭増鏈紝鑰屾渶鏂扮殑cas浣跨敤鐨勬槸1.5鐨勭増鏈紝緇忚繃鏌ョ湅婧愪唬鐮佸拰api docs紜畾鏈鏂扮増鏈殑灞炴у弬鏁板涓婇厤緗?/span>
淇敼璇ml鏂囦歡涓渶鍚庝竴涓粯璁ょ殑serviceRegistryDao bean涓殑灞炴у叏閮ㄦ敞閲婃帀錛屾垨鑰呭垹闄わ紝
榪欎釜bean涓殑RegisteredServiceImpl鐨刬gnoreAttributes灞炴у皢鍐沖畾鏄惁娣誨姞attributes灞炴у唴瀹癸紝榛樿涓篺alse:涓嶆坊鍔狅紝鍙湁鍘繪帀榪欎釜閰嶇疆錛?br />
cas server鎵嶄細灝嗚幏鍙栫殑鐢ㄦ埛鐨勯檮鍔犲睘鎬ф坊鍔犲埌璁よ瘉鐢ㄧ殑Principal鐨刟ttributes涓幓錛屾垜鍦ㄨ繖閲岀姱榪囪繖鏍風(fēng)殑閿欒錛屾渶鍚庤繕鏄氳繃璺熻釜婧愮爜鎵嶅彂鐜扮殑銆?/font>
<bean
id="serviceRegistryDao"
class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
<!--
<property name="registeredServices">
<list>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="0" />
<property name="name" value="HTTP" />
<property name="description" value="Only Allows HTTP Urls" />
<property name="serviceId" value="http://**" />
</bean>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="1" />
<property name="name" value="HTTPS" />
<property name="description" value="Only Allows HTTPS Urls" />
<property name="serviceId" value="https://**" />
</bean>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="2" />
<property name="name" value="IMAPS" />
<property name="description" value="Only Allows HTTPS Urls" />
<property name="serviceId" value="imaps://**" />
</bean>
<bean class="org.jasig.cas.services.RegisteredServiceImpl">
<property name="id" value="3" />
<property name="name" value="IMAP" />
<property name="description" value="Only Allows IMAP Urls" />
<property name="serviceId" value="imap://**" />
</bean>
</list>
</property>-->
</bean>
淇敼WEB-INF\view\jsp\protocol\2.0\casServiceValidationSuccess.jsp鏂囦歡錛屽涓嬶細
<%@ page session="false"%>
<%@ taglib prefix="c" uri=">
<%@ taglib uri="
<cas:serviceResponse xmlns:cas='http://www.yale.edu/tp/cas'>
<cas:authenticationSuccess>
<cas:user>${fn:escapeXml(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.id)}</cas:user>
<c:if test="${not empty pgtIou}">
<cas:proxyGrantingTicket>${pgtIou}</cas:proxyGrantingTicket>
</c:if>
<c:if test="${fn:length(assertion.chainedAuthentications) > 1}">
<cas:proxies>
<c:forEach var="proxy" items="${assertion.chainedAuthentications}"
varStatus="loopStatus" begin="0"
end="${fn:length(assertion.chainedAuthentications)-2}" step="1">
<cas:proxy>${fn:escapeXml(proxy.principal.id)}</cas:proxy>
</c:forEach>
</cas:proxies>
</c:if>
<c:if
test="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes)
>
0}">
<cas:attributes>
<c:forEach
var="attr"
items="${assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes}"
varStatus="loopStatus"
begin="0"
end="${fn:length(assertion.chainedAuthentications[fn:length(assertion.chainedAuthentications)-1].principal.attributes)-1}"
step="1">
<cas:${fn:escapeXml(attr.key)}>${fn:escapeXml(attr.value)}</cas:${fn:escapeXml(attr.key)}>
</c:forEach>
</cas:attributes>
</c:if>
</cas:authenticationSuccess>
</cas:serviceResponse>
瀹㈡埛绔厤緗?
1.榪囨護鍣–AS Validation Filter錛?br />
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class> org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>http://domainserver:8081/cas</param-value>
</init-param>
</filter>
鍦ㄥ鎴風(fēng)鑾峰彇淇℃伅
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
String loginName = principal.getName();//鑾峰彇鐢ㄦ埛鍚?br />
Map<String, Object> attributes = principal.getAttributes();
if(attributes != null) {
System.out.println(attributes.get("userId"));
System.out.println(attributes.get("passwordHint"));
}
浠ys鐢ㄦ埛鐧婚檰騫跺垱寤篢rigger:
create or replace TRIGGER ON_CONNECT AFTER LOGON ON DATABASE
DECLARE
guser varchar2(30);
begin
SELECT sys_context('USERENV','SESSION_USER') into guser FROM dual;
if (guser='ofbiz' or guser='OFBIZ') THEN
EXECUTE IMMEDIATE 'alter session set nls_timestamp_format = ''YYYY-MM-DD HH24:MI:SS.FF''';
end if;
end;
娉ㄦ剰瀵圭櫥闄嗙敤鎴峰悕鐨勫垽鏂繀欏誨ぇ灝忓啓閮借鑰冭檻.
鍙︼細ofbiz鐢ㄦ埛涓嶈兘鎷ユ湁dba鐨勬潈闄愶紝鍚屾椂ofbiz鐢ㄦ埛姣旈渶瑕佹湁UNLIMITED TABLESPACE鐨勬潈闄愶紝鍚﹀垯鍦ㄥ垱寤烘暟鎹〃鐨勬椂鍊欎細鎶?#8220;鏁版嵁搴撶┖闂翠笉瓚?#8221;鐨勯敊璇紝瀵艱嚧鏃犳硶鍒涘緩琛ㄣ?br />