<caching-scheme-mapping>
<!--
The clustered cache used to store Session management data.
-->
<cache-mapping>
<cache-name>session-management</cache-name>
<scheme-name>replicated</scheme-name>
</cache-mapping>
<!--
The clustered cache used to store ServletContext attributes.
-->
<cache-mapping>
<cache-name>servletcontext-storage</cache-name>
<scheme-name>replicated</scheme-name>
</cache-mapping>
<!--
The clustered cache used to store Session attributes.
-->
<cache-mapping>
<cache-name>session-storage</cache-name>
<scheme-name>session-near</scheme-name>
</cache-mapping>
<!--
The clustered cache used to store the "overflowing" (split-out due to size)
Session attributes. Only used for the "Split" model.
-->
<cache-mapping>
<cache-name>session-overflow</cache-name>
<scheme-name>session-distributed</scheme-name>
</cache-mapping>
<!--
The clustered cache used to store IDs of "recently departed" Sessions.
-->
<cache-mapping>
<cache-name>session-death-certificates</cache-name>
<scheme-name>session-certificate</scheme-name>
</cache-mapping>
<!--
The local cache used to store Sessions that are not yet distributed (if
there is a distribution controller).
-->
<cache-mapping>
<cache-name>local-session-storage</cache-name>
<scheme-name>unlimited-local</scheme-name>
</cache-mapping>
<!--
The local cache used to store Session attributes that are not distributed
(if there is a distribution controller or attributes are allowed to become
local when serialization fails).
-->
<cache-mapping>
<cache-name>local-attribute-storage</cache-name>
<scheme-name>unlimited-local</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<!--
Replicated caching scheme used by the Session management and ServletContext
attribute caches.
-->
<replicated-scheme>
<scheme-name>replicated</scheme-name>
<service-name>ReplicatedSessionsMisc</service-name>
<request-timeout>30s</request-timeout>
<backing-map-scheme>
<local-scheme>
<scheme-ref>unlimited-local</scheme-ref>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</replicated-scheme>
<!--
Near caching scheme used by the Session attribute cache. The front cache
uses a Local caching scheme and the back cache uses a Distributed caching
scheme.
-->
<near-scheme>
<scheme-name>session-near</scheme-name>
<front-scheme>
<local-scheme>
<scheme-ref>session-front</scheme-ref>
</local-scheme>
</front-scheme>
<back-scheme>
<distributed-scheme>
<scheme-ref>session-distributed</scheme-ref>
</distributed-scheme>
</back-scheme>
<invalidation-strategy>present</invalidation-strategy>
</near-scheme>
<!--
Local caching scheme definition used by all caches that do not require an
eviction policy.
-->
<local-scheme>
<scheme-name>unlimited-local</scheme-name>
<service-name>LocalSessionCache</service-name>
</local-scheme>
<!--
Clustered invocation service that manages sticky session ownership.
-->
<invocation-scheme>
<service-name>SessionOwnership</service-name>
<request-timeout>30s</request-timeout>
</invocation-scheme>
</caching-schemes>
</cache-config>
4. 测试
(1)运行session-cache-server.cmd,启动Coherence Cache Server。
(2)启动Admin Server
(3)启动Managed Server:ServerA和ServerB。
(4)启动counter应用
这时,在ServerA和ServerB的Console中会输出如下信息:
2012-10-18 15:39:09.907/108.408 Oracle Coherence 3.7.1.0 <Info> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', member=n
/a): Loaded operational configuration from "zip:C:/Oracle/wls1211_dev/user_projects/domains/dev_domain/servers/ServerA/tmp/_WL_user/counter/m4egcu/war/WEB-INF/l
ib/coherence.jar!/tangosol-coherence.xml"
2012-10-18 15:39:10.143/108.644 Oracle Coherence 3.7.1.0 <Info> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', member=n
/a): Loaded operational overrides from "zip:C:/Oracle/wls1211_dev/user_projects/domains/dev_domain/servers/ServerA/tmp/_WL_user/counter/m4egcu/war/WEB-INF/lib/c
oherence.jar!/tangosol-coherence-override-dev.xml"
2012-10-18 15:39:10.145/108.646 Oracle Coherence 3.7.1.0 <D5> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a
): Optional configuration override "/tangosol-coherence-override.xml" is not specified
2012-10-18 15:39:10.213/108.714 Oracle Coherence 3.7.1.0 <D5> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', member=n/a
): Optional configuration override "/custom-mbeans.xml" is not specified
Oracle Coherence Version 3.7.1.0 Build 27797
Grid Edition: Development mode
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
2012-10-18 15:39:11.114/109.615 Oracle Coherence GE 3.7.1.0 <Info> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', membe
r=n/a): Loaded cache configuration from "zip:C:/Oracle/wls1211_dev/user_projects/domains/dev_domain/servers/ServerA/tmp/_WL_user/coherence-web-spi/14iuoc/WEB-IN
F/lib/coherence-web.jar!/session-cache-config.xml"
2012-10-18 15:39:12.659/111.160 Oracle Coherence GE 3.7.1.0 <Info> (thread=[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', membe
r=n/a): Loaded Reporter configuration from "zip:C:/Oracle/wls1211_dev/user_projects/domains/dev_domain/servers/ServerA/tmp/_WL_user/counter/m4egcu/war/WEB-INF/l
ib/coherence.jar!/reports/report-group.xml"
<Oct 18, 2012 3:39:14 PM CST> <Warning> <com.oracle.wls> <BEA-000000> <2012-10-18 15:39:14.624/113.125 Oracle Coherence GE 3.7.1.0 <Warning> (thread=Cluster, me
mber=n/a): This member is configured with a multicast TTL of 0; the senior Member(Id=1, Timestamp=2012-10-18 15:36:33.028, Address=10.191.10.83:8088, MachineId=
46446, Location=site:,machine:PMMA-CN,process:6384, Role=CoherenceServer) is configured with a TTL of 4. It is strongly recommended to use the same TTL setting
for all cluster members.>
<Oct 18, 2012 3:39:15 PM CST> <Warning> <WorkManager> <BEA-002919> <Unable to find a Work Manager with name wm/CoherenceWorkManager. Dispatch policy wm/Coherenc
eWorkManager will map to the default Work Manager for the application counter>
Oct 18, 2012 3:39:16 PM com.tangosol.coherence.servlet.AbstractHttpSessionCollection configure
INFO: Configured session model "SplitHttpSessionCollection":
Clustered Session Cache Name=session-storage
Local Session Cache Name=local-session-storage
Local Session Attribute Cache Name=local-attribute-storage
Death Certificate Cache Name=session-death-certificates
SessionDistributionController Class Name=
AttributeScopeController Class Name=com.tangosol.coherence.servlet.AbstractHttpSessionCollection$ApplicationScopeController
Maximum Session Inactive Seconds=3600
Session ID Character Length=52
Session Locking Enforced=false
Member Session Locking Enforced=false
Application Session Locking Enforced=false
Thread Session Locking Enforced=false
Session Get Lock Timeout=300
Suspect Attribute Detection=true
Strict "Servlet Specification" Exception Handling=true
Sticky Session Ownership=false
Sticky Session Ownership Service Name=SessionOwnership
Assume Session Locality for Reaping=false
Parallel Session Reaping=true
Allow Local Attributes=false
Use Default Session ID Decoding=true
Use Default Session ID Encoding=false
Session ID Affinity Token=null
Session Expiry Filter Factory=
Session Access Debug Logging Enabled=false
Session Access Debug Logging Filter=
Oct 18, 2012 3:39:16 PM com.tangosol.coherence.servlet.SessionHelper registerMBean
INFO: Registering MBean using object name "type=WebLogicHttpSessionManager,nodeId=2,appId=countercounter.war"
3:8092, MachineId=46446, Location=site:,machine:PMMA-CN,process:296, Role=WeblogicServer) joined Cluster with senior member 1
2012-10-18 15:39:15.326/165.106 Oracle Coherence GE 3.7.1.0 <D5> (thread=Cluster, member=1): Member 3 joined Service Management with senior member 1
2012-10-18 15:39:15.904/165.684 Oracle Coherence GE 3.7.1.0 <D5> (thread=Cluster, member=1): Member 3 joined Service DistributedSessions with senior member 1
2012-10-18 15:39:15.966/165.746 Oracle Coherence GE 3.7.1.0 <D5> (thread=Cluster, member=1): Member 2 joined Service DistributedSessions with senior member 1
参考文献:
1. Tutorial for Oracle Coherence Release 3.7.1 之 Caching Sessions with Coherence and WebLogic Server
2. http://blog.ipnweb.com/2012/02/member-specified-cluster-name-which-did.html
8. 在dev_domain中,为Admin Server配置SAML 2.0 General
Contact Person Given Name:Ping
Contact Person Surname:Ma
Contact Person Type:technical
Contact Person Company:Oracle
Contact Person Telephone Number:
Contact Person Email Address:
Organization Name:
Organization URL:http://www.oracle.com
Published Site URL:http://localhost:7001/saml2
Entity ID:SAML2CredentialMapper
Recipient Check Enabled:勾上
Transport Layer Security Key Alias:server
Transport Layer Security Key Passphrase:123456
ConfirmTransport Layer Security Key Passphrase:123456
Only Accept Signed Artifact Request:勾上
Artifact Cache Size:10000
Artifact Cache Timeout:300
Single Sign-on Signing Key Alias:server
Single Sign-on Signing Key Pass Phrase:123456
Confirm Single Sign-on Signing Key Pass Phrase:123456
10. 在dev2_domain中,为Admin Server配置SAML 2.0 Service Provider
Enabled:勾上
Always Sign Authentication Requests:勾上
Force Authentication:勾上
Only Accept Signed Assertions:勾上
Authentication Request Cache Size:10000
Authentication Request Cache Timeout:300
POST One Use Check Enabled:勾上
POST Binding Enabled:勾上
Artifact Binding Enabled:勾上
11. 在dev2_domain中,为Admin Server配置SAML 2.0 General
Contact Person Given Name:Ping
Contact Person Surname:Ma
Contact Person Type:technical
Contact Person Company:Oracle
Contact Person Telephone Number:
Contact Person Email Address:
Organization Name:
Organization URL:http://www.oracle.com
Published Site URL:http://localhost:8001/saml2
Entity ID:SAML2IdentityAsserter
Recipient Check Enabled:勾上
Transport Layer Security Key Alias:server
Transport Layer Security Key Passphrase:123456
ConfirmTransport Layer Security Key Passphrase:123456
Only Accept Signed Artifact Request:勾上
Artifact Cache Size:10000
Artifact Cache Timeout:300
Single Sign-on Signing Key Alias:server
Single Sign-on Signing Key Pass Phrase:123456
Confirm Single Sign-on Signing Key Pass Phrase:123456
点击Publish Meta Data按钮,导出dev2_metadata.xml。
12. 在dev_domain中,为SAML2CredentialMapper导入Service Provider Partners:dev2_metadata.xml
(1)点击New,选择New Web Single Sign-On Service Proider Partner
(2)选择dev2_metadata.xml
(2)点击dev2,配置如下:
Enabled:勾上
Key Info Included:勾上
Only Accept Signed Artifact Requests:勾上
13. 在dev2_domain中,为SAML2IdentityAsserter导入Identity Provider Partners:dev_metadata.xml
(1)点击New,选择New Web Single Sign-On Indentity Provider Partner
1. 开发应用
(1)appA
这是appA的web.xml文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Saml Source Site Application</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <security-constraint> <web-resource-collection> <web-resource-name>SecurePages</web-resource-name> <description>These pages are only accessible by authorized users.</description>
<url-pattern>/admin/*</url-pattern>
<http-method>GET</http-method> </web-resource-collection> <auth-constraint> <description>These are the roles who have access.</description> <role-name>admin</role-name> </auth-constraint> <user-data-constraint> <description>This is how the user data must be transmitted.</description> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>FORM</auth-method> <realm-name>myrealm</realm-name> <form-login-config> <form-login-page>/login.jsp</form-login-page> <form-error-page>/fail_login.htm</form-error-page> </form-login-config> </login-config> <security-role> <description>These are the roles who have access</description> <role-name>admin</role-name> </security-role>
</web-app>
这是appA的weblogic.xml文件内容:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <security-role-assignment> <role-name>admin</role-name> <principal-name>ssouser</principal-name> </security-role-assignment> <context-root>/appA</context-root>
</weblogic-web-app>
(2)appB
这是appB的web.xml文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>SAML Destination Site Application</display-name> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <security-constraint> <web-resource-collection> <web-resource-name>SecurePages</web-resource-name> <description>These pages are only accessible by authorized users.</description>
<url-pattern>/admin/*</url-pattern>
<http-method>GET</http-method> </web-resource-collection> <auth-constraint> <description>These are the roles who have access.</description> <role-name>admin</role-name> </auth-constraint> <user-data-constraint> <description>This is how the user data must be transmitted.</description> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <login-config> <auth-method>CLIENT-CERT</auth-method> <realm-name>myrealm</realm-name> </login-config> <security-role> <description>These are the roles who have access.</description> <role-name>admin</role-name> </security-role>
</web-app>
这是appB的weblogic.xml文件内容:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-web-app xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <security-role-assignment> <role-name>admin</role-name> <principal-name>ssouser</principal-name> </security-role-assignment> <context-root>/appB</context-root>
</weblogic-web-app> 2. 创建Domain
(1)创建dev_domain,作为SAML的source一方。
(2)创建dev2_domain,作为SAML的target一方。
4. 测试应用
访问http://localhost:7001/appA,会出现欢迎页面,输入ssouser/welcome1,成功登陆后
点击链接:Application - appB on domainB,会报错,这是因为appB需要通过数字证书认证,因为没有得到相关信息所以报错。
当配置好SSO后,点击该链接应该可以进入appB中的受保护页面。
5. 配置SSL
(1) 在dev_domain中,为Admin Server 配置SSL。
(2) 在dev2_domain中,为Admin Server 配置SSL。
具体步骤请参考《配置双向SSL认证》,这里我配置的是单向SSL认证:Two Way Client Cert Behavior:Client Certs Not Required。
Issuer URI:http://www.bea.com/demoSAML
Name Qualifier:bea.com
Default Time To Live:120
Default Time To Live Offset:0
Signing Key Alias:server
Signing Key Pass Phrase:123456
Confirm Signing Key Pass Phrase:123456
(5)Two Way Client Cert Behavior:Client Certs Requested and Enforced
3.3 General Tab
(1)勾上SSL Listen Port Enabled
(2)SSL Listen Port:8082
4. 重启Admin Server 和Managed Server
Console中输出如下内容:
Loading the identity certificate and private key stored under the alias server from the PKCS12 keystore file C:\Oracle\wls1211_dev\user_projects\domains\dev_domain\server.p12.
Loading trusted certificates from the JKS keystore file C:\Oracle\wls1211_dev\user_projects\domains\dev_domain\truststore.jks.