[java-identity-provider COMMIT] in /trunk/idp-saml-impl/src: main/java/net/shibboleth/idp/saml/nameid/impl/StoredPers...
noreply at shibboleth.net
noreply at shibboleth.net
Sun Oct 11 15:49:52 EDT 2015
Author: scantor
Date: Sun Oct 11 15:49:52 2015
New Revision: 7807
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7807&view=rev
Log:
IDP-829 - updated stored ID strategy plugin, and working tests for both old/new config
Modified:
trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/StoredPersistentIdGenerationStrategy.java
trunk/idp-saml-impl/src/test/java/net/shibboleth/idp/saml/nameid/impl/PersistentSAML2NameIDGeneratorTest.java
Modified: trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/StoredPersistentIdGenerationStrategy.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/StoredPersistentIdGenerationStrategy.java?rev=7807&r1=7806&r2=7807&view=diff
==============================================================================
--- trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/StoredPersistentIdGenerationStrategy.java (original)
+++ trunk/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/StoredPersistentIdGenerationStrategy.java Sun Oct 11 15:49:52 2015
@@ -18,11 +18,10 @@
package net.shibboleth.idp.saml.nameid.impl;
import java.io.IOException;
-import java.sql.Timestamp;
-import java.util.UUID;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import javax.sql.DataSource;
import net.shibboleth.idp.saml.nameid.PersistentIdEntry;
import net.shibboleth.idp.saml.nameid.PersistentIdStore;
@@ -42,38 +41,59 @@
* Manages persistent IDs via a {@link PersistentIdStore}, generating them either randomly or via a
* {@link ComputedPersistentIdGenerationStrategy} (for compatibility with existing data).
*/
+ at SuppressWarnings("deprecation")
public class StoredPersistentIdGenerationStrategy extends AbstractInitializableComponent
implements PersistentIdGenerationStrategy {
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(StoredPersistentIdGenerationStrategy.class);
- /** Persistent identifier data store. */
- @NonnullAfterInit private PersistentIdStore pidStore;
+ /** Updated version of persistent identifier data store layer. */
+ @NonnullAfterInit private PersistentIdStoreEx pidStore;
+ /** A DataSource to auto-provision a {@link JDBCPersistentIdStoreEx} instance. */
+ @Nullable private DataSource dataSource;
+
+ /** Deprecated version of persistent identifier data store. */
+ @Nullable private PersistentIdStore deprecatedStore;
+
/** Optional generator of computed ID values. */
@Nullable private ComputedPersistentIdGenerationStrategy computedIdStrategy;
/**
- * Get the {@link PersistentIdStore} used to communicate with the database.
- *
- * @return the {@link PersistentIdStore}.
- */
- @NonnullAfterInit public PersistentIdStore getIDStore() {
- return pidStore;
- }
-
- /**
- * Set the {@link PersistentIdStore} used to store the IDs.
+ * Set a deprecated {@link PersistentIdStore} used to store the IDs.
*
* @param store the ID store to use
*/
public void setIDStore(@Nonnull final PersistentIdStore store) {
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- pidStore = Constraint.isNotNull(store, "PersistentIdStore cannot be null");
+ deprecatedStore = Constraint.isNotNull(store, "Deprecated PersistentIdStore cannot be null");
}
+ /**
+ * Set a {@link PersistentIdStoreEx} used to store the IDs.
+ *
+ * @param store the ID store to use
+ */
+ public void setIDStore(@Nonnull final PersistentIdStoreEx store) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ pidStore = Constraint.isNotNull(store, "PersistentIdStoreEx cannot be null");
+ }
+
+ /**
+ * Set the data source to inject into an auto-provisioned instance of {@link JDBCPersistentIdStoreEx}
+ * to use as the storage strategy.
+ *
+ * @param source the data source
+ */
+ public void setDataSource(@Nonnull final DataSource source) {
+ ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
+
+ dataSource = Constraint.isNotNull(source, "DataSource cannot be null");
+ }
+
/**
* Set a strategy to use to compute IDs for the first time.
*
@@ -88,13 +108,46 @@
/** {@inheritDoc} */
@Override protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
-
+
if (null == pidStore) {
- throw new ComponentInitializationException("PersistentIdStore cannot be null");
+ if (deprecatedStore != null) {
+ if (deprecatedStore instanceof JDBCPersistentIdStore) {
+ log.warn("Transferring settings from deprecated JDBCPersistentStore, please update configuration");
+ final JDBCPersistentIdStoreEx newStore = new JDBCPersistentIdStoreEx();
[... 313 lines stripped ...]
More information about the commits
mailing list