[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersis...

noreply at shibboleth.net noreply at shibboleth.net
Tue Oct 13 15:54:28 EDT 2015


Author: scantor
Date: Tue Oct 13 15:54:28 2015
New Revision: 7813

URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7813&view=rev
Log:
IDP-829 - Update JDBC test, add database verify (off by default), default retry codes to 23505

Modified:
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStore.java
    trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStoreEx.java
    trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/DatabaseBackedIDStoreTest.java
    trunk/idp-saml-impl/src/test/resources/net/shibboleth/idp/saml/impl/nameid/StoredIdStore.sql

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStore.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStore.java?rev=7813&r1=7812&r2=7813&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStore.java	(original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStore.java	Tue Oct 13 15:54:28 2015
@@ -357,6 +357,8 @@
         idEntrySelectSQL = "SELECT * FROM " + tableName + " WHERE ";
         deactivateSQL = "UPDATE " + tableName + " SET " + deactivationTimeColumn + "= ? WHERE "
                 + persistentIdColumn + "= ?";
+        
+        log.error("{} This is a deprecated class and should have been swapped out at runtime", getLogPrefix());
     }
 
     /** {@inheritDoc} */

Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStoreEx.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStoreEx.java?rev=7813&r1=7812&r2=7813&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStoreEx.java	(original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/JDBCPersistentIdStoreEx.java	Tue Oct 13 15:54:28 2015
@@ -81,6 +81,9 @@
     /** Error messages that signal a transaction should be retried. */
     @Nonnull @NonnullElements private Collection<String> retryableErrors;
 
+    /** Whether to fail if the database cannot be verified.  */
+    private boolean verifyDatabase;
+    
     /** Name of the database table. */
     @Nonnull @NotEmpty private String tableName;
 
@@ -122,11 +125,14 @@
 
     /** Parameterized update statement used to attach an alias to an ID. */
     @NonnullAfterInit private String attachSQL;
+    
+    /** Parameterized delete statement used to clear dummy rows after verification. */
+    @NonnullAfterInit private String deleteSQL;
 
     /** Constructor. */
     public JDBCPersistentIdStoreEx() {
         transactionRetry = 3;
-        retryableErrors = Collections.emptyList();
+        retryableErrors = Collections.singletonList("23505");
         queryTimeout = 5000;
         
         tableName = "shibpid";
@@ -203,6 +209,20 @@
         
         retryableErrors = new ArrayList(StringSupport.normalizeStringCollection(errors));
     }
+    
+    /**
+     * Set whether to allow startup if the database cannot be verified.
+     * 
+     * <p>Verification consists not only of a liveness check, but the successful insertion of
+     * a dummy row, a failure to insert a duplicate, and then deletion of the row.</p>
+     * 
+     * @param flag flag to set
+     */
+    public void setVerifyDatabase(final boolean flag) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        verifyDatabase = flag;
+    }
 
     /**
      * Set the table name.
@@ -367,6 +387,17 @@
         ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
         
         attachSQL = Constraint.isNotNull(StringSupport.trimOrNull(sql), "SQL statement cannot be null or empty");
+    }
+
+    /**
+     * Set the DELETE statement used to clear dummy row(s) created during verification.
+     * 
+     * @param sql statement text, which must contain one parameter (NameQualifier)
+     */
+    public void setDeleteSQL(@Nonnull @NotEmpty final String sql) {
+        ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+        
+        deleteSQL = Constraint.isNotNull(StringSupport.trimOrNull(sql), "SQL statement cannot be null or empty");
     }
     
     /** {@inheritDoc} */
@@ -414,6 +445,24 @@
         if (attachSQL == null) {
             attachSQL = "UPDATE " + tableName + " SET " + peerProvidedIdColumn + "= ? WHERE "
                     + issuerColumn + "= ? AND " + recipientColumn + "= ? AND " + persistentIdColumn + "= ?";
+        }
+        
+        if (deleteSQL == null) {
+            deleteSQL = "DELETE FROM " + tableName + " WHERE " + issuerColumn + "= ?";
+        }
+        
+        try {

[... 371 lines stripped ...]


More information about the commits mailing list