[java-identity-provider] 01/02: IDP-692 Introduce SimpleManagedConnection
Rod Widdowson
rdw at steadingsoftware.com
Fri Aug 11 06:11:15 EDT 2017
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch master
in repository java-identity-provider.
View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=f6afb36699df70668095b006e403f28f7fd2d91e
commit f6afb36699df70668095b006e403f28f7fd2d91e
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Aug 9 16:54:47 2017 +0100
IDP-692 Introduce SimpleManagedConnection
https://issues.shibboleth.net/jira/browse/IDP-692
Schema change and test file, plus supressed test.
---
.../dc/rdbms/RDBMSDataConnectorParserTest.java | 39 +++++++++++------
.../rdbms/rdbms-attribute-resolver-v2-simple.xml | 28 ++++++++++++
.../schema/shibboleth-attribute-resolver.xsd | 50 +++++++++++++++++++++-
3 files changed, 101 insertions(+), 16 deletions(-)
diff --git a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
index edb4f9b..e71eaba 100644
--- a/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
+++ b/idp-attribute-resolver-spring/src/test/java/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/RDBMSDataConnectorParserTest.java
@@ -25,20 +25,6 @@ import java.util.Map;
import javax.sql.DataSource;
-import net.shibboleth.ext.spring.config.DurationToLongConverter;
-import net.shibboleth.ext.spring.config.StringToIPRangeConverter;
-import net.shibboleth.ext.spring.config.StringToResourceConverter;
-import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
-import net.shibboleth.idp.attribute.IdPAttribute;
-import net.shibboleth.idp.attribute.resolver.ResolutionException;
-import net.shibboleth.idp.attribute.resolver.dc.impl.ExecutableSearchBuilder;
-import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.DataSourceValidator;
-import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.ExecutableStatement;
-import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.RDBMSDataConnector;
-import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.StringResultMappingStrategy;
-import net.shibboleth.idp.attribute.resolver.spring.dc.rdbms.impl.RDBMSDataConnectorParser;
-import net.shibboleth.idp.testing.DatabaseTestingSupport;
-
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.support.ConversionServiceFactoryBean;
import org.springframework.context.support.GenericApplicationContext;
@@ -56,6 +42,20 @@ import org.testng.annotations.Test;
import com.google.common.cache.Cache;
import com.mchange.v2.c3p0.ComboPooledDataSource;
+import net.shibboleth.ext.spring.config.DurationToLongConverter;
+import net.shibboleth.ext.spring.config.StringToIPRangeConverter;
+import net.shibboleth.ext.spring.config.StringToResourceConverter;
+import net.shibboleth.ext.spring.util.SchemaTypeAwareXMLBeanDefinitionReader;
+import net.shibboleth.idp.attribute.IdPAttribute;
+import net.shibboleth.idp.attribute.resolver.ResolutionException;
+import net.shibboleth.idp.attribute.resolver.dc.impl.ExecutableSearchBuilder;
+import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.DataSourceValidator;
+import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.ExecutableStatement;
+import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.RDBMSDataConnector;
+import net.shibboleth.idp.attribute.resolver.dc.rdbms.impl.StringResultMappingStrategy;
+import net.shibboleth.idp.attribute.resolver.spring.dc.rdbms.impl.RDBMSDataConnectorParser;
+import net.shibboleth.idp.testing.DatabaseTestingSupport;
+
/** Test for {@link RDBMSDataConnectorParser}. */
public class RDBMSDataConnectorParserTest {
@@ -102,6 +102,17 @@ public class RDBMSDataConnectorParserTest {
Assert.assertEquals(mappingStrategy.getResultRenamingMap().get("homephone"), "phonenumber");
}
+ @Test(enabled=false) public void simpleConnector() throws Exception {
+ final RDBMSDataConnector dataConnector =
+ getRdbmsDataConnector("net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/rdbms-attribute-resolver-v2-simple.xml");
+ Assert.assertNotNull(dataConnector);
+ doTest(dataConnector);
+ final StringResultMappingStrategy mappingStrategy = (StringResultMappingStrategy) dataConnector.getMappingStrategy();
+ Assert.assertEquals(mappingStrategy.getResultRenamingMap().size(), 1);
+ Assert.assertEquals(mappingStrategy.getResultRenamingMap().get("homephone"), "phonenumber");
+ }
+
+
@Test public void resolver() throws Exception {
final RDBMSDataConnector dataConnector =
getRdbmsDataConnector("net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/resolver/rdbms-attribute-resolver-v2.xml");
diff --git a/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/rdbms-attribute-resolver-v2-simple.xml b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/rdbms-attribute-resolver-v2-simple.xml
new file mode 100644
index 0000000..b1c4d2b
--- /dev/null
+++ b/idp-attribute-resolver-spring/src/test/resources/net/shibboleth/idp/attribute/resolver/spring/dc/rdbms/rdbms-attribute-resolver-v2-simple.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<AttributeResolver
+ xmlns="urn:mace:shibboleth:2.0:resolver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:mace:shibboleth:2.0:resolver http://shibboleth.net/schema/idp/shibboleth-attribute-resolver.xsd">
+
+ <DataConnector id="myDatabase" xsi:type="RelationalDatabase"
+ noResultIsError="true"
+ multipleResultsIsError="true"
+ readOnlyConnection="false"
+ noRetryDelay="PT5M">
+ <SimpleManagedConnection
+ jdbcDriver="org.hsqldb.jdbc.JDBCDriver"
+ jdbcURL="jdbc:hsqldb:mem:RDBMSDataConnectorStore"
+ jdbcUserName="SA"
+ jdbcPassword=""/>
+ <dc:QueryTemplate>
+ <![CDATA[
+ SELECT * FROM people WHERE userid='%s'
+ ]]>
+ </dc:QueryTemplate>
+
+ <dc:Column columnName="homephone" attributeID="phonenumber" />
+
+ <dc:ResultCache
+ elementTimeToLive="PT10S"/>
+ </resolver:DataConnector>
+
+</resolver:AttributeResolver>
diff --git a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
index d7bdbce..e70e3ff 100644
--- a/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
+++ b/idp-schema/src/main/resources/schema/shibboleth-attribute-resolver.xsd
@@ -127,6 +127,7 @@
<documentation>Defines an encoder for an attribute.</documentation>
</annotation>
</element>
+
<complexType name="BaseAttributeEncoderType">
<annotation>
<documentation>
@@ -240,6 +241,7 @@
</documentation>
</annotation>
</element>
+
<complexType name="BasePrincipalConnectorType">
<annotation>
<documentation>
@@ -1125,6 +1127,13 @@
<element ref="resolver:ApplicationManagedConnection">
<annotation>
<documentation>
+ DEPRECATED A connection, or pool of connections, to the database managed by the data connector.
+ </documentation>
+ </annotation>
+ </element>
+ <element ref="resolver:SimpleManagedConnection">
+ <annotation>
+ <documentation>
A connection, or pool of connections, to the database managed by the data connector.
</documentation>
</annotation>
@@ -1739,7 +1748,6 @@
</attribute>
</complexType>
-
<element name="ContainerManagedConnection" type="resolver:ContainerManagedConnectionType">
<annotation>
<documentation>
@@ -1747,6 +1755,7 @@
</documentation>
</annotation>
</element>
+
<complexType name="ContainerManagedConnectionType">
<sequence>
<element name="JNDIConnectionProperty" type="resolver:PropertyType" minOccurs="0" maxOccurs="unbounded">
@@ -1765,7 +1774,7 @@
</attribute>
</complexType>
- <complexType name="PropertyType">
+ <complexType name="PropertyType">
<attribute name="name" type="string" use="required">
<annotation>
<documentation>The name of the property.</documentation>
@@ -1777,11 +1786,48 @@
</annotation>
</attribute>
</complexType>
+
+ <element name="SimpleManagedConnection" type="resolver:SimpleManagedConnectionType">
+ <annotation>
+ <documentation>
+ Describes a simple database connection source that is managed by the attribute resolver data connector.
+ Included to "get people going" only
+ </documentation>
+ </annotation>
+ </element>
+ <complexType name="SimpleManagedConnectionType">
+ <attribute name="jdbcDriver" type="string" use="required">
+ <annotation>
+ <documentation>
+ This is the full qualified class name of the JDBC driver used to connect to the database.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="jdbcURL" type="string" use="required">
+ <annotation>
+ <documentation>
+ The JDBC URL for the database. These are usually of the form
+ jdbc:databaseProduceName:databaseSpecificInformation. For example, jdbc:hsql:mem:MyDatabase
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="jdbcUserName" type="string">
+ <annotation>
+ <documentation>The user name to use while connecting to the database.</documentation>
+ </annotation>
+ </attribute>
+ <attribute name="jdbcPassword" type="string">
+ <annotation>
+ <documentation>The password to use while connecting to the database.</documentation>
+ </annotation>
+ </attribute>
+ </complexType>
<element name="ApplicationManagedConnection" type="resolver:ApplicationManagedConnectionType">
<annotation>
<documentation>
+ DEPRECATED
Describes a database connection source that is managed by the attribute resolver data connector.
</documentation>
</annotation>
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list