Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Namespace: urn:mace:shibboleth:2.0:resolver
Schema: http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd

Overview

The <BeanManagedConnection> element specifies an externally-defined bean which defines a DataSource.

This is the most effective way to control connection properties, implement robust pooling support, and share connections across connectorscomponents. The content of the element is the name of the externally-defined bean, and it carries defines no other attributes or child elementsXML Attributes or Elements.

Examples

The example illustrates a an Oracle data source using via the DBCP pooling library (version 1.4), which is a well-tested optionincluded with the software. The Oracle JDBC driver would have to added by hand to the edit-webapp tree and the WAR rebuilt.

Code Block
Code Block
languagexml
titleDataSource defined as a Spring Bean
languagexml
<BeanManagedConnection>MyDataSource</BeanManagedConnection>
titleOracle Backend Example
collapsetrue
<!-- NoteOracle thatSpring someconnection ofpooling thedata settingssource below are defined as properties, which is optional.configuration, e.g., in global.xml -->
  <bean id="MyDataSourceOracleDataSource" class="org.apache.commons.dbcpdbcp2.BasicDataSource" destroy-method="close"
    	p:driverClassName="%{datasource.driverClass}"
    p:url="%{datasource.jdbcUrl}"
	p:username="%{datasource.user}"
	p:password="%{datasource.password}"
    p:maxActiveinitialSize="10" p:maxIdle="5"
	p:maxWaitmaxTotal="200050"
	p:testOnBorrowmaxIdle="true5"
    	p:validationQuerymaxWaitMillis="select 12000"
	p:validationQueryTimeouttestOnBorrow="5" />
Code Block
languagexml
titleOracle Backend Example
collapse
true
<!-- Oracle database data source needs commons-dbcp-1.4.jar, commons-pool-1.x.jar, ojdbcx.jar in edit-webapp/WEB-INF/lib/ -->
<!-- global.xml needs a new Oracle DB bean as in the previous example, but validationQuery needs to be modified in "select 1 from dual" -->

<!-- Oracle Spring connection pooling data source configuration -->
<bean id="OracleDataSource"
class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
    p:driverClassNametestWhileIdle="%{datasource.driverClass}true"
    	p:urltestOnReturn="%{datasource.jdbcUrl}true"
	p:usernametimeBetweenEvictionRunsMillis="%{datasource.user}" p:password="%{datasource.password}"120000" 
    p:maxActiveminEvictableIdleTimeMillis="10" p:maxIdle="5" p:maxWait="2000" p:testOnBorrow="true"
    120000"
	p:validationQuery="select 1 from dual"
	p:validationQueryTimeout="54" />

<!-- AttributesProperties indefined idp.propertiesseparately -->
datasource.driverClass = oracle.jdbc.OracleDriver
datasource.jdbcUrl = jdbc:oracle:thin:@<serverFQDN>:1521:<dbmame>
datasource.user = <USER>
datasource.password = <PASS>

<!-- exampleExample of attribute-resolver.xml portion for an attribute resolution using principalName as keyusage -->
<DataConnector xsi:type="dc:RelationalDatabase" id="oracledbcf" >
    <BeanManagedConnection>OracleDataSource<<BeanManagedConnection>MyDataSource</dc:BeanManagedConnection>
    <QueryTemplate>
       <![CDATA[
             SELECT CF from DB.TABLE where USER_ID='$resolutionContext.principal'
       ]]>
    </QueryTemplate>
    <Column columnName="CF" attributeID="personalUniqueID_it_CF" />
</DataConnector>

Code Block
languagexml
titleAlternate Oracle Backend Example
collapsetrue
<!-- Similar to the above, an Oracle database can also use commons-dbcp2.jar, commons-pool2.jar, ojdbc7.jar with java 8 -->
<!-- global.xml needs a new Oracle DB bean as in the previous example, but validationQuery needs to be modified in "select 1 from dual" -->

<!-- Oracle Spring connection pooling data source configuration -->
  <bean id="OracleDataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"
    p:driverClassName="%{datasource.driverClass}"
    p:url="%{datasource.jdbcUrl}" p:username="%{datasource.user}" p:password="%{datasource.password}"
    p:initialSize="5" p:maxTotal="50" p:maxIdle="5" p:maxWaitMillis="2000" p:testOnBorrow="true"
    p:testWhileIdle="true" p:testOnReturn="true" p:timeBetweenEvictionRunsMillis="120000" 
   
p:minEvictableIdleTimeMillis="120000" p:validationQuery="select 1 from dual" p:validationQueryTimeout="4" />

...