[java-identity-provider] branch main updated: JSSH-27 Implement an ensureId method to help with nullability annotation

Rod Widdowson rdw at steadingsoftware.com
Thu May 4 15:31:20 UTC 2023


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=b113ea2034a11d2dfb5352acd94e1228365ff5a0

The following commit(s) were added to refs/heads/main by this push:
     new b113ea203 JSSH-27 Implement an ensureId method to help with nullability annotation
b113ea203 is described below

commit b113ea2034a11d2dfb5352acd94e1228365ff5a0
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu May 4 16:30:30 2023 +0100

    JSSH-27 Implement an ensureId method to help with nullability annotation
    
    https://shibboleth.atlassian.net/browse/JSSH-27
    
    Add appropriate use of ensureId().
---
 .../idp/authn/AbstractCredentialValidator.java        |  4 +---
 .../idp/authn/AuthenticationFlowDescriptor.java       |  4 +---
 .../authn/impl/FinalizeMultiFactorAuthentication.java |  4 +---
 .../idp/authn/impl/PopulateAuthenticationContext.java | 18 +++++++++---------
 .../PopulateMultiFactorAuthenticationContext.java     |  2 +-
 .../impl/PopulateSubjectCanonicalizationContext.java  |  2 +-
 .../idp/authn/impl/SelectAuthenticationFlow.java      | 10 +++++-----
 .../authn/impl/SelectSubjectCanonicalizationFlow.java |  9 +++------
 .../impl/StorageBackedAccountLockoutManager.java      | 19 +++++--------------
 .../idp/authn/impl/ValidateCredentials.java           |  4 ++--
 .../flow/impl/AbstractOutgoingSamlMessageAction.java  |  2 +-
 .../test/flows/saml2/SAML2TestResponseValidator.java  | 15 ++++++++-------
 .../idp/consent/flow/impl/ExtractConsent.java         |  2 +-
 .../flow/storage/impl/CreateGlobalConsentResult.java  |  4 +---
 .../logic/impl/AttributeReleaseConsentFunction.java   |  4 ++--
 .../logic/impl/AttributeValueLookupFunction.java      |  4 +++-
 .../logic/impl/GlobalAttributeConsentPredicate.java   |  2 +-
 .../logic/impl/IsConsentRequiredPredicate.java        |  2 +-
 .../idp/consent/storage/impl/ConsentSerializer.java   |  6 +++---
 .../test/java/net/shibboleth/idp/installer/Test.java  | 14 +++-----------
 .../idp/profile/impl/ReloadServiceConfiguration.java  |  5 ++++-
 .../impl/PopulateProfileInterceptorContext.java       |  4 ++--
 .../impl/SelectProfileInterceptorFlow.java            |  6 ++----
 .../impl/PopulateBindingAndEndpointContexts.java      |  4 ++--
 .../saml/saml2/profile/impl/SAMLAuthnController.java  |  2 +-
 25 files changed, 64 insertions(+), 88 deletions(-)

diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractCredentialValidator.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractCredentialValidator.java
index 6b132c3c8..4007d4cce 100644
--- a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractCredentialValidator.java
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AbstractCredentialValidator.java
@@ -130,14 +130,12 @@ public abstract class AbstractCredentialValidator extends AbstractIdentifiedInit
             @Nullable final WarningHandler warningHandler,
             @Nullable final ErrorHandler errorHandler) throws Exception {
         checkComponentActive();
-        final String id = getId();
-        assert id!=null;
         
         if (!activationCondition.test(profileRequestContext)) {
             log.debug("{} Activation condition was false, ignoring request", getLogPrefix());
             return null;
         } else if (!isAcceptable(authenticationContext.getSubcontext(RequestedPrincipalContext.class),
-                customPrincipals, id)) {
+                customPrincipals, ensureId())) {
             return null;
         }
         
diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java
index c1d277379..f803e4abc 100644
--- a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/AuthenticationFlowDescriptor.java
@@ -584,9 +584,7 @@ public class AuthenticationFlowDescriptor extends AbstractIdentifiableInitializa
      * @return the new result
      */
     @Nonnull public AuthenticationResult newAuthenticationResult(@Nonnull final Subject subject) {
-        final String id = getId();
-        assert id != null;
-        final AuthenticationResult result = new AuthenticationResult(id, subject);
+        final AuthenticationResult result = new AuthenticationResult(ensureId(), subject);
 
         if (proxyRestrictionsEnforced) {
             result.setReuseCondition(PredicateSupport.and(reuseCondition, result.new ProxyRestrictionReusePredicate()));
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/FinalizeMultiFactorAuthentication.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/FinalizeMultiFactorAuthentication.java
index 1f6cff7e3..e6f9a6526 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/FinalizeMultiFactorAuthentication.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/FinalizeMultiFactorAuthentication.java
@@ -296,9 +296,7 @@ public class FinalizeMultiFactorAuthentication extends AbstractAuthenticationAct
                             
                             final AuthenticationFlowDescriptor afd = mfaContext.getAuthenticationFlowDescriptor();
                             assert afd != null;
-                            final String afdId = afd.getId();
-                            assert afdId != null;
-                            final AuthenticationResult merged = new AuthenticationResult(afdId, subject);
+                            final AuthenticationResult merged = new AuthenticationResult(afd.ensureId(), subject);
                             merged.setPreviousResult(allPreviousResults);
                             if (ts != null) {
                                 merged.setAuthenticationInstant(ts);
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateAuthenticationContext.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateAuthenticationContext.java
index 104de559d..49109bce1 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateAuthenticationContext.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateAuthenticationContext.java
@@ -167,7 +167,7 @@ public class PopulateAuthenticationContext extends AbstractAuthenticationAction
         
         // Install all the available flows for reference.
         for (final AuthenticationFlowDescriptor desc : availableFlows) {
-            authenticationContext.getAvailableFlows().put(desc.getId(), desc);
+            authenticationContext.getAvailableFlows().put(desc.ensureId(), desc);
         }
         
         // Now we have to filter the potential flows against the available and active flows and
@@ -177,26 +177,26 @@ public class PopulateAuthenticationContext extends AbstractAuthenticationAction
 
         if (activeFlows != null && !activeFlows.isEmpty()) {
             for (final AuthenticationFlowDescriptor desc : potentialFlowsLookupStrategy.apply(profileRequestContext)) {
-                final String flowId = desc.getId().substring(desc.getId().indexOf('/') + 1);
+                final String flowId = desc.ensureId().substring(desc.ensureId().indexOf('/') + 1);
                 if (activeFlows.contains(flowId)) {
-                    if (authenticationContext.getAvailableFlows().containsKey(desc.getId())
+                    if (authenticationContext.getAvailableFlows().containsKey(desc.ensureId())
                             && desc.test(profileRequestContext)) {
-                        authenticationContext.getPotentialFlows().put(desc.getId(), desc);
+                        authenticationContext.getPotentialFlows().put(desc.ensureId(), desc);
                     } else {
-                        log.debug("{} Filtered out authentication flow {}", getLogPrefix(), desc.getId());
+                        log.debug("{} Filtered out authentication flow {}", getLogPrefix(), desc.ensureId());
                     }
                 } else {
                     log.debug("{} Filtered out authentication flow {} due to profile configuration", getLogPrefix(),
-                            desc.getId());
+                            desc.ensureId());
                 }
             }
         } else {
             for (final AuthenticationFlowDescriptor desc : potentialFlowsLookupStrategy.apply(profileRequestContext)) {
-                if (authenticationContext.getAvailableFlows().containsKey(desc.getId())
+                if (authenticationContext.getAvailableFlows().containsKey(desc.ensureId())
                         && desc.test(profileRequestContext)) {
-                    authenticationContext.getPotentialFlows().put(desc.getId(), desc);
+                    authenticationContext.getPotentialFlows().put(desc.ensureId(), desc);
                 } else {
-                    log.debug("{} Filtered out authentication flow {}", getLogPrefix(), desc.getId());
+                    log.debug("{} Filtered out authentication flow {}", getLogPrefix(), desc.ensureId());
                 }
             }
         }
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java
index 8497de567..c3457df7c 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateMultiFactorAuthenticationContext.java
@@ -192,7 +192,7 @@ public class PopulateMultiFactorAuthenticationContext extends AbstractAuthentica
                 }
                 if (acf != null) {
                     assert ac != null;
-                    final AuthenticationResult mfaResult = ac.getActiveResults().get(acf.getId());
+                    final AuthenticationResult mfaResult = ac.getActiveResults().get(acf.ensureId());
                     if (mfaResult != null) {
                         if (ac.isForceAuthn()) {
                             log.debug("{} Ignoring active result due to forced authentication requirement",
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateSubjectCanonicalizationContext.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateSubjectCanonicalizationContext.java
index 511bf6b33..df5562346 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateSubjectCanonicalizationContext.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/PopulateSubjectCanonicalizationContext.java
@@ -72,7 +72,7 @@ public class PopulateSubjectCanonicalizationContext extends AbstractSubjectCanon
         log.debug("{} Installing {} canonicalization flows into SubjectCanonicalizationContext", getLogPrefix(),
                 availableFlows.size());
         for (final SubjectCanonicalizationFlowDescriptor desc : availableFlows) {
-            c14nContext.getPotentialFlows().put(desc.getId(), desc);
+            c14nContext.getPotentialFlows().put(desc.ensureId(), desc);
         }
     }
     
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectAuthenticationFlow.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectAuthenticationFlow.java
index 4b18104a9..fef0155d3 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectAuthenticationFlow.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectAuthenticationFlow.java
@@ -196,7 +196,7 @@ public class SelectAuthenticationFlow extends AbstractAuthenticationAction {
         
         AuthenticationResult activeResult = null;
         if (!authenticationContext.isForceAuthn()) {
-            activeResult = authenticationContext.getActiveResults().get(flow.getId());
+            activeResult = authenticationContext.getActiveResults().get(flow.ensureId());
             if (!activeResult.test(profileRequestContext)) {
                 log.debug("{} Active result for flow {} not reusable, ignoring", getLogPrefix(),
                         activeResult.getAuthenticationFlowId());
@@ -338,7 +338,7 @@ public class SelectAuthenticationFlow extends AbstractAuthenticationAction {
         AuthenticationFlowDescriptor selectedFlow = null;
         
         for (final AuthenticationFlowDescriptor flow : authenticationContext.getPotentialFlows().values()) {
-            if (!authenticationContext.getIntermediateFlows().containsKey(flow.getId())) {
+            if (!authenticationContext.getIntermediateFlows().containsKey(flow.ensureId())) {
                 if (!authenticationContext.isPassive() || flow.isPassiveAuthenticationSupported()) {
                     if (!noProxying || !flow.isProxyScopingEnforced()) {
                         if (flow.test(profileRequestContext)) {
@@ -440,7 +440,7 @@ public class SelectAuthenticationFlow extends AbstractAuthenticationAction {
             final PrincipalEvalPredicate predicate = rpCtx.getPredicate(p);
             if (predicate != null) {
                 for (final AuthenticationFlowDescriptor descriptor : potentialFlows.values()) {
-                    if (!authenticationContext.getIntermediateFlows().containsKey(descriptor.getId())
+                    if (!authenticationContext.getIntermediateFlows().containsKey(descriptor.ensureId())
                             && predicate.test(descriptor) && descriptor.test(profileRequestContext)) {
                         if (!authenticationContext.isPassive() || descriptor.isPassiveAuthenticationSupported()) {
                             if (!noProxying || !descriptor.isProxyScopingEnforced()) {
@@ -525,12 +525,12 @@ public class SelectAuthenticationFlow extends AbstractAuthenticationAction {
             final PrincipalEvalPredicate predicate = rpCtx.getPredicate(p);
             if (predicate != null) {
                 for (final AuthenticationFlowDescriptor descriptor : potentialFlows.values()) {
-                    if (!authenticationContext.getIntermediateFlows().containsKey(descriptor.getId())
+                    if (!authenticationContext.getIntermediateFlows().containsKey(descriptor.ensureId())
                             && predicate.test(descriptor) && descriptor.test(profileRequestContext)) {
                         
                         // Now check for an active result we can use from this flow. Not all results from a flow
                         // will necessarily match the request just because the flow might.
-                        final AuthenticationResult result = activeResults.get(descriptor.getId());
+                        final AuthenticationResult result = activeResults.get(descriptor.ensureId());
                         if (result == null || !result.test(profileRequestContext)
                                 || !predicate.test(result)) {
                             if (result != null) {
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectSubjectCanonicalizationFlow.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectSubjectCanonicalizationFlow.java
index b56b3949a..8d1d9c887 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectSubjectCanonicalizationFlow.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/SelectSubjectCanonicalizationFlow.java
@@ -80,11 +80,8 @@ public class SelectSubjectCanonicalizationFlow extends AbstractSubjectCanonicali
             ActionSupport.buildEvent(profileRequestContext, AuthnEventIds.NO_POTENTIAL_FLOW);
             return;
         }
-        final String flowId = flow.getId();
-        assert flowId != null;
-
-        log.debug("{} Selecting canonicalization flow {}", getLogPrefix(), flowId);
-        ActionSupport.buildEvent(profileRequestContext, flowId);
+        log.debug("{} Selecting canonicalization flow {}", getLogPrefix(), flow.ensureId());
+        ActionSupport.buildEvent(profileRequestContext, flow.ensureId());
     }
 
     /**
@@ -99,7 +96,7 @@ public class SelectSubjectCanonicalizationFlow extends AbstractSubjectCanonicali
             @Nonnull final ProfileRequestContext profileRequestContext,
             @Nonnull final SubjectCanonicalizationContext c14nContext) {
         for (final SubjectCanonicalizationFlowDescriptor flow : c14nContext.getPotentialFlows().values()) {
-            if (!c14nContext.getIntermediateFlows().containsKey(flow.getId())) {
+            if (!c14nContext.getIntermediateFlows().containsKey(flow.ensureId())) {
                 log.debug("{} Checking canonicalization flow {} for applicability...", getLogPrefix(),
                         flow.getId());
                 c14nContext.setAttemptedFlow(flow);
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/StorageBackedAccountLockoutManager.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/StorageBackedAccountLockoutManager.java
index 04512b0b2..7486e6ffe 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/StorageBackedAccountLockoutManager.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/StorageBackedAccountLockoutManager.java
@@ -226,14 +226,11 @@ public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInit
             log.warn("No lockout key returned for request");
             return false;
         }
-        final String id = getId();
-        assert id != null;
-
         // Read back account state. No state obviously means no lockout, but in the case of errors
         // that does fail open. Of course, in-memory won't fail...
         StorageRecord<?> sr = null;
         try {
-            sr = storageService.read(id, key);
+            sr = storageService.read(ensureId(), key);
         } catch (final IOException e) {
             sr = null;
             log.error("Error reading back account lockout state for '{}'", key, e);
@@ -289,10 +286,8 @@ public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInit
         try {
             final String key = getLockoutKeyStrategy().apply(profileRequestContext);
             if (key != null) {
-                final String id = getId();
-                assert id != null;
                 log.debug("Clearing lockout state for '{}'", key);
-                storageService.delete(id, key);
+                storageService.delete(ensureId(), key);
                 return true;
             }
             log.warn("No lockout key returned for request");
@@ -326,9 +321,7 @@ public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInit
         int counter = 0;
         StorageRecord<?> sr = null;
         try {
-            final String id = getId();
-            assert id != null;
-            sr = storageService.read(id, key);
+            sr = storageService.read(ensureId(), key);
             if (sr != null) {
                 counter = Integer.parseInt(sr.getValue());
             }
@@ -365,12 +358,10 @@ public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInit
         log.debug("Invalid login count for '{}' will be {}, expiring at {}", key, counter,
                 Instant.ofEpochMilli(expiration));
 
-        final String id = getId();
-        assert id != null;
         // Create or update as required. Retry on errors.
         if (sr == null) {
             try {
-                if (storageService.create(id, key, Integer.toString(counter), expiration)) {
+                if (storageService.create(ensureId(), key, Integer.toString(counter), expiration)) {
                     return true;
                 }
             } catch (final IOException e) {
@@ -378,7 +369,7 @@ public class StorageBackedAccountLockoutManager extends AbstractIdentifiableInit
             }
         } else {
             try {
-                if (storageService.update(id, key, Integer.toString(counter), expiration)) {
+                if (storageService.update(ensureId(), key, Integer.toString(counter), expiration)) {
                     return true;
                 }
             } catch (final IOException e) {
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateCredentials.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateCredentials.java
index ff3807ed4..f4a003b47 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateCredentials.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateCredentials.java
@@ -131,7 +131,7 @@ public class ValidateCredentials extends AbstractAuditingValidationAction implem
     @Nonnull @NotEmpty public String getMetricName() {
         // only called in execute when we know the field is non-null
         assert currentValidator != null;
-        final String cvId = currentValidator.getId();
+        final String cvId = currentValidator. getId();
         return super.getMetricName() + '.' + cvId;
     }
        
@@ -270,7 +270,7 @@ public class ValidateCredentials extends AbstractAuditingValidationAction implem
     
     /** {@inheritDoc} */
     @Override
-    @Nullable @NonnullElements protected Map<String,String> getAuditFields(
+    @Nonnull @NonnullElements protected Map<String,String> getAuditFields(
             @Nonnull final ProfileRequestContext profileRequestContext) {
         // only called in execute when we know the field is non-null
         assert currentValidator!=null;
diff --git a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/AbstractOutgoingSamlMessageAction.java b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/AbstractOutgoingSamlMessageAction.java
index 00260884b..21ac99a6c 100644
--- a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/AbstractOutgoingSamlMessageAction.java
+++ b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/AbstractOutgoingSamlMessageAction.java
@@ -113,7 +113,7 @@ public abstract class AbstractOutgoingSamlMessageAction extends
             return;
         }
         final SAMLBindingContext bindingContext = new SAMLBindingContext();
-        bindingContext.setBindingUri(outgoingBinding.getId());
+        bindingContext.setBindingUri(outgoingBinding.ensureId());
         bindingContext.setBindingDescriptor(outgoingBinding);
         msgContext.addSubcontext(bindingContext);
 
diff --git a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
index 3d546b039..c125bc083 100644
--- a/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
+++ b/idp-conf/src/test/java/net/shibboleth/idp/test/flows/saml2/SAML2TestResponseValidator.java
@@ -30,6 +30,7 @@ import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
 import net.shibboleth.idp.test.flows.AbstractFlowTest;
+import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.net.IPRange;
 
 import org.opensaml.core.xml.XMLObjectBuilder;
@@ -134,13 +135,13 @@ public class SAML2TestResponseValidator extends SAML2TestStatusResponseTypeValid
 
         buildExpectedAttributes();
         // fool code analyzer
-        uidAttribute = uidAttribute;
-        homeOrgAttribute = homeOrgAttribute;
-        eppnAttribute = eppnAttribute;
-        mailAttribute = mailAttribute;
-        eduPersonScopedAffiliationAttribute = eduPersonScopedAffiliationAttribute;
-        expectedDesignatedAttributes = expectedDesignatedAttributes;
-        expectedAttributes = expectedAttributes;
+        uidAttribute = Constraint.isNotNull(uidAttribute, "");
+        homeOrgAttribute = Constraint.isNotNull(homeOrgAttribute, "");
+        eppnAttribute = Constraint.isNotNull(eppnAttribute, "");
+        mailAttribute = Constraint.isNotNull(mailAttribute, "");
+        eduPersonScopedAffiliationAttribute = Constraint.isNotNull(eduPersonScopedAffiliationAttribute, "");
+        expectedDesignatedAttributes = Constraint.isNotNull(expectedDesignatedAttributes, "");
+        expectedAttributes = Constraint.isNotNull(expectedAttributes, "");
     }
 
     /** Build expected attributes. */
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ExtractConsent.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ExtractConsent.java
index 19e76b22b..6c3a55be1 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ExtractConsent.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/impl/ExtractConsent.java
@@ -83,7 +83,7 @@ public class ExtractConsent extends AbstractConsentAction {
 
         final Map<String, Consent> currentConsents = consentContext.getCurrentConsents();
         for (final Consent consent : currentConsents.values()) {
-            if (consentIds.contains(consent.getId())) {
+            if (consentIds.contains(consent.ensureId())) {
                 consent.setApproved(Boolean.TRUE);
             } else {
                 consent.setApproved(Boolean.FALSE);
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
index 53c0870d2..3f4d4fd05 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/flow/storage/impl/CreateGlobalConsentResult.java
@@ -56,10 +56,8 @@ public class CreateGlobalConsentResult extends AbstractConsentIndexedStorageActi
             final Consent globalConsent = new Consent();
             globalConsent.setId(Consent.WILDCARD);
             globalConsent.setApproved(true);
-            final String id = globalConsent.getId();
-            assert id!= null;
             final String value =
-                    getStorageSerializer().serialize(CollectionSupport.singletonMap(id, globalConsent));
+                    getStorageSerializer().serialize(CollectionSupport.singletonMap( globalConsent.ensureId(), globalConsent));
             final ConsentFlowDescriptor flowDescriptor = getConsentFlowDescriptor();
             final String storageContext = getStorageContext();
             final String storageKey = getStorageKey();
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunction.java
index 1f7ff792b..c0d0417c9 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeReleaseConsentFunction.java
@@ -141,7 +141,7 @@ public class AttributeReleaseConsentFunction implements Function<ProfileRequestC
             }
 
             // Remember previous choice.
-            final Consent previousConsent = consentContext.getPreviousConsents().get(consent.getId());
+            final Consent previousConsent = consentContext.getPreviousConsents().get(consent.ensureId());
             if (previousConsent != null) {
                 if (consentFlowDescriptor.compareValues()) {
                     if (Objects.equals(consent.getValue(), previousConsent.getValue())) {
@@ -154,7 +154,7 @@ public class AttributeReleaseConsentFunction implements Function<ProfileRequestC
                 }
             }
 
-            currentConsents.put(consent.getId(), consent);
+            currentConsents.put(consent.ensureId(), consent);
         }
 
         return currentConsents;
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java
index 500980139..332cc4fa5 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AttributeValueLookupFunction.java
@@ -65,9 +65,11 @@ public class AttributeValueLookupFunction implements ContextDataLookupFunction<P
                 Constraint.isNotNull(StringSupport.trimOrNull(userAttributeId),
                         "User attribute ID cannot be null nor empty");
 
-        attributeContextLookupStrategy =
+        final Function<ProfileRequestContext,AttributeContext> acls =
                 new ChildContextLookup<>(AttributeContext.class).compose(
                         new ChildContextLookup<>(RelyingPartyContext.class));
+        assert acls!=null;
+        attributeContextLookupStrategy = acls;
         
         useUnfilteredAttributes = true;
     }
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/GlobalAttributeConsentPredicate.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/GlobalAttributeConsentPredicate.java
index f9420f995..abc367f61 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/GlobalAttributeConsentPredicate.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/GlobalAttributeConsentPredicate.java
@@ -58,7 +58,7 @@ public class GlobalAttributeConsentPredicate implements Predicate<ProfileRequest
 
         final Map<String, Consent> previousConsents = consentContext.getPreviousConsents();
         for (final Consent consent : previousConsents.values()) {
-            if (consent.getId().equals(Consent.WILDCARD) && consent.isApproved()) {
+            if (consent.ensureId().equals(Consent.WILDCARD) && consent.isApproved()) {
                 return true;
             }
         }
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicate.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicate.java
index 08cf8b91b..db44b5772 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicate.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/IsConsentRequiredPredicate.java
@@ -108,7 +108,7 @@ public class IsConsentRequiredPredicate implements Predicate<ProfileRequestConte
         }
 
         for (final Consent currentConsent : currentConsents.values()) {
-            final Consent previousConsent = previousConsents.get(currentConsent.getId());
+            final Consent previousConsent = previousConsents.get(currentConsent.ensureId());
             if (previousConsent == null) {
                 log.debug("Consent is required, no previous consent for '{}'", currentConsent);
                 return true;
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
index 99d84b75e..f47b34b5b 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/storage/impl/ConsentSerializer.java
@@ -156,7 +156,7 @@ public class ConsentSerializer extends AbstractInitializableComponent implements
                         consent.setValue(o.getString(VALUE_FIELD));
                     }
                     consent.setApproved(o.getBoolean(IS_APPROVED_FIELD, true));
-                    consents.put(consent.getId(), consent);
+                    consents.put(consent.ensureId(), consent);
                 }
             }
 
@@ -184,11 +184,11 @@ public class ConsentSerializer extends AbstractInitializableComponent implements
             gen.writeStartArray();
             for (final Consent consent : filteredConsents) {
                 gen.writeStartObject();
-                final Integer symbol = symbolics.get(consent.getId());
+                final Integer symbol = symbolics.get(consent.ensureId());
                 if (symbol != null) {
                     gen.write(ID_FIELD, symbol);
                 } else {
-                    gen.write(ID_FIELD, consent.getId());
+                    gen.write(ID_FIELD, consent.ensureId());
                 }
                 if (consent.getValue() != null) {
                     gen.write(VALUE_FIELD, consent.getValue());
diff --git a/idp-installer/src/test/java/net/shibboleth/idp/installer/Test.java b/idp-installer/src/test/java/net/shibboleth/idp/installer/Test.java
index 0123f2323..2a0e23d9b 100644
--- a/idp-installer/src/test/java/net/shibboleth/idp/installer/Test.java
+++ b/idp-installer/src/test/java/net/shibboleth/idp/installer/Test.java
@@ -19,22 +19,14 @@ package net.shibboleth.idp.installer;
 
 import java.io.IOException;
 
-import javax.annotation.Nonnull;
-
-import org.slf4j.Logger;
-
 import net.shibboleth.idp.installer.impl.CurrentInstallStateImpl;
 import net.shibboleth.idp.installer.metadata.impl.MetadataGeneratorImpl;
 import net.shibboleth.shared.component.ComponentInitializationException;
-import net.shibboleth.shared.primitive.LoggerFactory;
 /**
  *
  */
 public class Test {
 
-    /** Class logger. */
-    @Nonnull private final Logger log = LoggerFactory.getLogger(Test.class);
-   
     /**
      * @param args ...
      * 
@@ -43,11 +35,11 @@ public class Test {
      */
     public static void main(String[] args) throws IOException, ComponentInitializationException {
 
-        System.setProperty(InstallerPropertiesImpl.TARGET_DIR,"H:\\Downloads\\idp");
+        //System.setProperty(InstallerPropertiesImpl.TARGET_DIR,"H:\\Downloads\\idp");
         System.setProperty(InstallerPropertiesImpl.SOURCE_DIR,
-                "h:\\Perforce\\Juno\\New\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-4.1.1-SNAPSHOT");
+                "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT");
         System.setProperty(InstallerPropertiesImpl.ANT_BASE_DIR,
-                "h:\\Perforce\\Juno\\New\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-4.1.1-SNAPSHOT\\bin");
+                "h:\\Perforce\\Juno\\V5\\java-identity-provider\\idp-distribution\\target\\shibboleth-identity-provider-5.0.0-SNAPSHOT\\bin");
         System.setProperty(InstallerPropertiesImpl.KEY_STORE_PASSWORD, "p1");
         System.setProperty(InstallerPropertiesImpl.SEALER_PASSWORD, "p1");
         System.setProperty(InstallerPropertiesImpl.HOST_NAME, "machine.org.uk");
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ReloadServiceConfiguration.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ReloadServiceConfiguration.java
index 733416366..dacd6ace6 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ReloadServiceConfiguration.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/impl/ReloadServiceConfiguration.java
@@ -34,6 +34,7 @@ import net.shibboleth.idp.profile.AbstractProfileAction;
 import net.shibboleth.idp.profile.context.SpringRequestContext;
 import net.shibboleth.shared.annotation.constraint.NonnullBeforeExec;
 import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
 import net.shibboleth.shared.component.IdentifiedComponent;
 import net.shibboleth.shared.logic.Constraint;
 import net.shibboleth.shared.primitive.LoggerFactory;
@@ -116,7 +117,9 @@ public class ReloadServiceConfiguration extends AbstractProfileAction {
     @Override protected void doExecute(final @Nonnull ProfileRequestContext profileRequestContext) {
         
         final String id;
-        if (service instanceof IdentifiedComponent) {
+        if (service instanceof AbstractIdentifiableInitializableComponent) {
+            id = ((AbstractIdentifiableInitializableComponent) service).ensureId();
+        } else if (service instanceof IdentifiedComponent) {
             id = ((IdentifiedComponent) service).getId();
         } else {
             id = "(unnamed)";
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContext.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContext.java
index dba5f94f1..f5da6578b 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContext.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/PopulateProfileInterceptorContext.java
@@ -125,12 +125,12 @@ public class PopulateProfileInterceptorContext extends AbstractProfileIntercepto
             for (final String id : activeFlows) {
                 final String flowId = ProfileInterceptorFlowDescriptor.FLOW_ID_PREFIX + id;
                 final Optional<ProfileInterceptorFlowDescriptor> flow =
-                        availableFlows.stream().filter(fd -> fd.getId().equals(flowId)).findFirst();
+                        availableFlows.stream().filter(fd -> fd.ensureId().equals(flowId)).findFirst();
                 
                 if (flow.isPresent()) {
                     log.debug("{} Installing {} flow {} into interceptor context", getLogPrefix(), loggingLabel,
                             flowId);
-                    interceptorContext.getAvailableFlows().put(flow.orElseThrow().getId(), flow.orElseThrow());
+                    interceptorContext.getAvailableFlows().put(flow.orElseThrow().ensureId(), flow.orElseThrow());
                 } else {
                     log.error("{} Configured {} interceptor flow {} not available for use", getLogPrefix(),
                             loggingLabel, flowId);
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlow.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlow.java
index ab4641564..9ecc43843 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlow.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/profile/interceptor/impl/SelectProfileInterceptorFlow.java
@@ -81,10 +81,8 @@ public class SelectProfileInterceptorFlow extends AbstractProfileInterceptorActi
             log.debug("{} No flows available to choose from", getLogPrefix());
             return;
         }
-        final String id = flow.getId();
-        assert id != null;
-        log.debug("{} Selecting flow {}", getLogPrefix(), id);
-        ActionSupport.buildEvent(profileRequestContext, id);
+        log.debug("{} Selecting flow {}", getLogPrefix(), flow.ensureId());
+        ActionSupport.buildEvent(profileRequestContext, flow.ensureId());
     }
 
     /**
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContexts.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContexts.java
index ef9fda6c8..cd661ddd2 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContexts.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/PopulateBindingAndEndpointContexts.java
@@ -472,7 +472,7 @@ public class PopulateBindingAndEndpointContexts extends AbstractProfileAction {
         bindingCtx.setRelayState(SAMLBindingSupport.getRelayState(imc));
         
         final Optional<BindingDescriptor> bindingDescriptor =
-                bindingDescriptors.stream().filter(b -> b.getId().equals(bindingURI)).findFirst();
+                bindingDescriptors.stream().filter(b -> b.ensureId().equals(bindingURI)).findFirst();
 
         if (bindingDescriptor.isPresent()) {
             bindingCtx.setBindingDescriptor(bindingDescriptor.orElseThrow());
@@ -520,7 +520,7 @@ public class PopulateBindingAndEndpointContexts extends AbstractProfileAction {
                 assert bindingDescriptors!=null;
                 final Optional<BindingDescriptor> binding =
                         bindingDescriptors.stream().filter(
-                                b -> b.getId().equals(bindingCtx.getBindingUri())
+                                b -> b.ensureId().equals(bindingCtx.getBindingUri())
                                 ).findFirst();
                 if (binding.isPresent() && binding.orElseThrow().isSynchronous()) {
                     log.debug("{} Handling request via synchronous binding, preparing outbound binding context for {}",
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/SAMLAuthnController.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/SAMLAuthnController.java
index ce4d6648f..07df74328 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/SAMLAuthnController.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/SAMLAuthnController.java
@@ -185,7 +185,7 @@ public class SAMLAuthnController extends AbstractInitializableComponent {
                     url.substring(0, url.lastIndexOf("/start")));
             final BindingDescriptor bd = bindingMap.get(binding);
             if (bd != null) {
-                authnRequest.setProtocolBinding(bd.getId());
+                authnRequest.setProtocolBinding(bd.ensureId());
             }
         } else {
             log.error("Outbound AuthnContext message not found");

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list