[java-identity-provider] branch main updated: Fix up null service component handling.
Scott Cantor
cantor.2 at osu.edu
Mon Nov 28 20:12:49 UTC 2022
This is an automated email from the git hooks/post-receive script.
scantor 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=923d2970de1577c6bcfa95fa23795ff016833599
The following commit(s) were added to refs/heads/main by this push:
new 923d2970d Fix up null service component handling.
923d2970d is described below
commit 923d2970de1577c6bcfa95fa23795ff016833599
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Mon Nov 28 15:12:46 2022 -0500
Fix up null service component handling.
---
.../authn/impl/ValidateExternalAuthentication.java | 21 ++++++-------
.../PrepareTicketValidationResponseAction.java | 11 ++++---
.../cas/service/impl/ReloadingServiceRegistry.java | 17 +++++-----
.../impl/AbstractAttributeDisplayFunction.java | 7 +++--
.../impl/EncryptionCredentialsResolver.java | 23 +++++++-------
...ReloadingRelyingPartyConfigurationResolver.java | 36 +++++++++-------------
.../impl/SigningCredentialsResolver.java | 24 +++++++--------
.../impl/ProxySAML1NameIdentifierGenerator.java | 8 ++---
.../nameid/impl/ProxySAML2NameIDGenerator.java | 6 ++--
.../idp/saml/profile/impl/ReloadMetadata.java | 13 ++++++--
.../impl/AddAttributeStatementToAssertion.java | 10 +++---
.../impl/FilterByQueriedAttributeDesignators.java | 14 ++++-----
.../impl/AddAttributeStatementToAssertion.java | 9 +++---
.../profile/impl/FilterByQueriedAttributes.java | 14 ++++-----
.../profile/impl/ValidateSAMLAuthentication.java | 29 ++++++++---------
15 files changed, 119 insertions(+), 123 deletions(-)
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java
index 4440c3274..7744c37fa 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ValidateExternalAuthentication.java
@@ -48,6 +48,7 @@ import net.shibboleth.idp.authn.principal.ProxyAuthenticationPrincipal;
import net.shibboleth.idp.authn.principal.UsernamePrincipal;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -298,21 +299,17 @@ public class ValidateExternalAuthentication extends AbstractValidationAction {
populateFilterContext(filterContext);
- try (final ServiceableComponent<AttributeFilter> component
- = attributeFilterService.getServiceableComponent()) {
- if (null == component) {
- log.error("{} Error while filtering inbound attributes: Invalid Attribute Filter configuration",
- getLogPrefix());
- attributeContext.setIdPAttributes(null);
- } else {
- final AttributeFilter filter = component.getComponent();
- filter.filterAttributes(filterContext);
- filterContext.getParent().removeSubcontext(filterContext);
- attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
- }
+ try (final ServiceableComponent<AttributeFilter> component = attributeFilterService.getServiceableComponent()) {
+ final AttributeFilter filter = component.getComponent();
+ filter.filterAttributes(filterContext);
+ filterContext.getParent().removeSubcontext(filterContext);
+ attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
} catch (final AttributeFilterException e) {
log.error("{} Error while filtering inbound attributes", getLogPrefix(), e);
attributeContext.setIdPAttributes(null);
+ } catch (final ServiceException e) {
+ log.error("{} Invalid AttributeFilter configuration", getLogPrefix(), e);
+ attributeContext.setIdPAttributes(null);
}
}
diff --git a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/PrepareTicketValidationResponseAction.java b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/PrepareTicketValidationResponseAction.java
index 0cece63e4..7246b7b49 100644
--- a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/PrepareTicketValidationResponseAction.java
+++ b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/flow/impl/PrepareTicketValidationResponseAction.java
@@ -60,6 +60,7 @@ import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -214,11 +215,6 @@ public class PrepareTicketValidationResponseAction extends
try (final ServiceableComponent<AttributeTranscoderRegistry> component =
transcoderRegistry.getServiceableComponent()) {
- if (component == null) {
- log.error("{} Attribute transoding service unavailable", getLogPrefix());
- ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_ENCODE_ATTRIBUTE);
- return;
- }
for (final IdPAttribute attribute : inputAttributes) {
if (consentedAttributeIds == null || consentedAttributeIds.contains(attribute.getId())) {
encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
@@ -227,7 +223,12 @@ public class PrepareTicketValidationResponseAction extends
attribute.getId());
}
}
+ } catch (final ServiceException e) {
+ log.error("{} Attribute transoding service unavailable", getLogPrefix(), e);
+ ActionSupport.buildEvent(profileRequestContext, IdPEventIds.UNABLE_ENCODE_ATTRIBUTE);
+ return;
}
+
encodedAttributes.forEach(a -> response.addAttribute(a));
}
// Checkstyle: CyclomaticComplexity ON
diff --git a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/service/impl/ReloadingServiceRegistry.java b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/service/impl/ReloadingServiceRegistry.java
index f3adfd71b..0516c6129 100644
--- a/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/service/impl/ReloadingServiceRegistry.java
+++ b/idp-cas-impl/src/main/java/net/shibboleth/idp/cas/service/impl/ReloadingServiceRegistry.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -54,16 +55,14 @@ public class ReloadingServiceRegistry extends AbstractIdentifiableInitializableC
service = Constraint.isNotNull(delegate, "ReloadableService cannot be null");
}
- @Nullable
@Override
- public Service lookup(@Nonnull final String serviceURL) {
- try (final ServiceableComponent<ServiceRegistry>
- component = service.getServiceableComponent()) {
- if (null == component) {
- log.error("ServiceRegistry '{}': error looking up service registry: Invalid configuration.", getId());
- return null;
- }
+ @Nullable public Service lookup(@Nonnull final String serviceURL) {
+ try (final ServiceableComponent<ServiceRegistry> component = service.getServiceableComponent()) {
return component.getComponent().lookup(serviceURL);
+ } catch (final ServiceException e) {
+ log.error("ServiceRegistry '{}': Invalid CAS service registry configuration.", getId(), e);
+ return null;
}
}
-}
+
+}
\ No newline at end of file
diff --git a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AbstractAttributeDisplayFunction.java b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AbstractAttributeDisplayFunction.java
index b8664d47c..547cfe31b 100644
--- a/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AbstractAttributeDisplayFunction.java
+++ b/idp-consent-impl/src/main/java/net/shibboleth/idp/consent/logic/impl/AbstractAttributeDisplayFunction.java
@@ -35,6 +35,7 @@ import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
import net.shibboleth.shared.spring.util.SpringSupport;
@@ -95,9 +96,9 @@ public abstract class AbstractAttributeDisplayFunction implements Function<IdPAt
if (displayInfo == null) {
try (final ServiceableComponent<AttributeTranscoderRegistry> component =
transcoder.getServiceableComponent()) {
- if (component != null) {
- displayInfo = getDisplayInfo(component.getComponent(), input);
- }
+ displayInfo = getDisplayInfo(component.getComponent(), input);
+ } catch (final ServiceException e) {
+ // Ignore.
}
cachedInfo.put(input, displayInfo);
}
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
index 3e5b48f52..be16a4440 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/EncryptionCredentialsResolver.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
import net.shibboleth.shared.spring.service.ReloadableSpringService;
@@ -85,20 +86,18 @@ public class EncryptionCredentialsResolver implements CredentialResolver, Identi
@Nonnull public Iterable<Credential> resolve(@Nullable final CriteriaSet criteria)
throws ResolverException {
try(final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
- if (null == component) {
- log.error("EncryptionCredentialsResolver '{}': error looking up relying party configuration service:"
- + " Invalid configuration.", getId());
- } else {
- final RelyingPartyConfigurationResolver resolver = component.getComponent();
- if (resolver instanceof DefaultRelyingPartyConfigurationResolver) {
- log.trace("Saw expected instance of DefaultRelyingPartyConfigurationResolver");
- return ((DefaultRelyingPartyConfigurationResolver)resolver).getEncryptionCredentials();
- }
- log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
- return Collections.emptyList();
+ final RelyingPartyConfigurationResolver resolver = component.getComponent();
+ if (resolver instanceof DefaultRelyingPartyConfigurationResolver) {
+ log.trace("Saw expected instance of DefaultRelyingPartyConfigurationResolver");
+ return ((DefaultRelyingPartyConfigurationResolver)resolver).getEncryptionCredentials();
}
+ log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
+ return Collections.emptyList();
+ } catch (final ServiceException e) {
+ log.error("EncryptionCredentialsResolver '{}': Invalid RelyingPartyResolver configuration", getId(), e);
}
- return null;
+
+ return Collections.emptyList();
}
}
\ No newline at end of file
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
index dcec734fc..f511466c2 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/ReloadingRelyingPartyConfigurationResolver.java
@@ -37,6 +37,7 @@ import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponen
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.resolver.ResolverException;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -72,18 +73,16 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
@Nullable final ProfileRequestContext context) throws ResolverException {
checkComponentActive();
try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
- if (null == component) {
- log.error("RelyingPartyResolver '{}': error looking up Relying Party: Invalid configuration", getId());
- } else {
- final RelyingPartyConfigurationResolver resolver = component.getComponent();
- final List<RelyingPartyConfiguration> results = new ArrayList<>();
- for (final RelyingPartyConfiguration result : resolver.resolve(context)) {
- results.add(result);
- }
- return results;
+ final RelyingPartyConfigurationResolver resolver = component.getComponent();
+ final List<RelyingPartyConfiguration> results = new ArrayList<>();
+ for (final RelyingPartyConfiguration result : resolver.resolve(context)) {
+ results.add(result);
}
+ return results;
} catch (final ResolverException e) {
log.error("RelyingPartyResolver '{}': error in resolution", getId(), e);
+ } catch (final ServiceException e) {
+ log.error("RelyingPartyResolver '{}': Invalid RelyingPartyResolver configuration", getId(), e);
}
return Collections.emptySet();
}
@@ -93,14 +92,11 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
throws ResolverException {
checkComponentActive();
try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()){
- if (null == component) {
- log.error("RelyingPartyResolver '{}': error looking up Relying Party: Invalid configuration", getId());
- } else {
- final RelyingPartyConfigurationResolver resolver = component.getComponent();
- return resolver.resolveSingle(context);
- }
+ return component.getComponent().resolveSingle(context);
} catch (final ResolverException e) {
log.error("RelyingPartyResolver '{}': error in resolution", getId(), e);
+ } catch (final ServiceException e) {
+ log.error("RelyingPartyResolver '{}': Invalid RelyingPartyResolver configuration", getId(), e);
}
return null;
}
@@ -109,13 +105,9 @@ public class ReloadingRelyingPartyConfigurationResolver extends AbstractIdentifi
@Override public SecurityConfiguration getDefaultSecurityConfiguration(final String profileId) {
checkComponentActive();
try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()){
- if (null == component) {
- log.error("RelyingPartyResolver '{}': error looking up default security config:"
- + " Invalid configuration", getId());
- } else {
- final RelyingPartyConfigurationResolver resolver = component.getComponent();
- return resolver.getDefaultSecurityConfiguration(profileId);
- }
+ return component.getComponent().getDefaultSecurityConfiguration(profileId);
+ } catch (final ServiceException e) {
+ log.error("RelyingPartyResolver '{}': Invalid RelyingPartyResolver configuration", getId(), e);
}
return null;
}
diff --git a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
index 59d813d7e..de1476090 100644
--- a/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
+++ b/idp-profile-impl/src/main/java/net/shibboleth/idp/relyingparty/impl/SigningCredentialsResolver.java
@@ -29,6 +29,7 @@ import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.resolver.CriteriaSet;
import net.shibboleth.shared.resolver.ResolverException;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
import net.shibboleth.shared.spring.service.ReloadableSpringService;
@@ -84,21 +85,20 @@ public class SigningCredentialsResolver implements CredentialResolver, Identifia
/** {@inheritDoc} */
@Nonnull public Iterable<Credential> resolve(@Nullable final CriteriaSet criteria)
throws ResolverException {
+
try (final ServiceableComponent<RelyingPartyConfigurationResolver> component = service.getServiceableComponent()) {
- if (null == component) {
- log.error("SigningCredentialsResolver '{}': error looking up relying party configuration service:"
- + " Invalid configuration.", getId());
- } else {
- final RelyingPartyConfigurationResolver resolver = component.getComponent();
- if (resolver instanceof DefaultRelyingPartyConfigurationResolver) {
- log.trace("Saw expected instance of DefaultRelyingPartyConfigurationResolver");
- return ((DefaultRelyingPartyConfigurationResolver)resolver).getSigningCredentials();
- }
- log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
- return Collections.emptyList();
+ final RelyingPartyConfigurationResolver resolver = component.getComponent();
+ if (resolver instanceof DefaultRelyingPartyConfigurationResolver) {
+ log.trace("Saw expected instance of DefaultRelyingPartyConfigurationResolver");
+ return ((DefaultRelyingPartyConfigurationResolver)resolver).getSigningCredentials();
}
+ log.trace("Did NOT see expected instance of DefaultRelyingPartyConfigurationResolver");
+ return Collections.emptyList();
+ } catch (final ServiceException e) {
+ log.error("SigningCredentialsResolver '{}': Invalid RelyingPartyResolver configuration", getId(), e);
}
- return null;
+
+ return Collections.emptyList();
}
}
\ No newline at end of file
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML1NameIdentifierGenerator.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML1NameIdentifierGenerator.java
index 5b7aa0d1b..aa8530c44 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML1NameIdentifierGenerator.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML1NameIdentifierGenerator.java
@@ -24,6 +24,7 @@ import net.shibboleth.idp.saml.nameid.NameIdentifierGenerationService;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
import org.opensaml.profile.context.ProfileRequestContext;
@@ -43,7 +44,7 @@ public class ProxySAML1NameIdentifierGenerator implements SAML1NameIdentifierGen
/**
* Constructor.
*
- * @param service the service providing the generator to proxy
+ * @param service the service providing the generators to proxy
*/
public ProxySAML1NameIdentifierGenerator(
@Nonnull final ReloadableService<NameIdentifierGenerationService> service) {
@@ -57,10 +58,9 @@ public class ProxySAML1NameIdentifierGenerator implements SAML1NameIdentifierGen
try (final ServiceableComponent<NameIdentifierGenerationService> component
= generatorService.getServiceableComponent()) {
- if (component == null) {
- throw new SAMLException("Invalid NameIdentifierGenerationService configuration");
- }
return component.getComponent().getSAML1NameIdentifierGenerator().generate(profileRequestContext, format);
+ } catch (final ServiceException e) {
+ throw new SAMLException("Invalid NameIdentifierGenerationService configuration", e);
}
}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML2NameIDGenerator.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML2NameIDGenerator.java
index a82df6a07..c33771573 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML2NameIDGenerator.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/nameid/impl/ProxySAML2NameIDGenerator.java
@@ -24,6 +24,7 @@ import net.shibboleth.idp.saml.nameid.NameIdentifierGenerationService;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
import org.opensaml.profile.context.ProfileRequestContext;
@@ -57,10 +58,9 @@ public class ProxySAML2NameIDGenerator implements SAML2NameIDGenerator {
try (final ServiceableComponent<NameIdentifierGenerationService>
component = generatorService.getServiceableComponent()) {
- if (component == null) {
- throw new SAMLException("Invalid NameIdentifierGenerationService configuration");
- }
return component.getComponent().getSAML2NameIDGenerator().generate(profileRequestContext, format);
+ } catch (final ServiceException e) {
+ throw new SAMLException("Invalid NameIdentifierGenerationService configuration", e);
}
}
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/ReloadMetadata.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/ReloadMetadata.java
index b3327bad3..c452c5372 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/ReloadMetadata.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/profile/impl/ReloadMetadata.java
@@ -43,6 +43,7 @@ import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.resolver.ResolverException;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -154,8 +155,8 @@ public class ReloadMetadata extends AbstractProfileAction {
@Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext) {
log.debug("{} Reloading metadata from '{}'", getLogPrefix(), id);
- try (final ServiceableComponent<MetadataResolver>
- component = metadataResolverService.getServiceableComponent()) {
+ try (final ServiceableComponent<MetadataResolver> component =
+ metadataResolverService.getServiceableComponent()) {
final MetadataResolver toProcess = findProvider(component.getComponent());
@@ -182,6 +183,14 @@ public class ReloadMetadata extends AbstractProfileAction {
log.error("{} I/O error responding to request", getLogPrefix(), e2);
ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
}
+ } catch (final ServiceException e) {
+ log.error("{} Invalid metadata resolver configuration: '{}'", getLogPrefix(), id, e);
+ try {
+ getHttpServletResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ } catch (final IOException e2) {
+ log.error("{} I/O error responding to request", getLogPrefix(), e2);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
+ }
} catch (final IOException e) {
log.error("{} I/O error responding to request", getLogPrefix(), e);
ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR);
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
index 9ab038c91..4171de196 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/AddAttributeStatementToAssertion.java
@@ -48,6 +48,7 @@ import net.shibboleth.idp.saml.profile.impl.BaseAddAttributeStatementToAssertion
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NullableElements;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -135,16 +136,15 @@ public class AddAttributeStatementToAssertion extends BaseAddAttributeStatementT
final ArrayList<Attribute> encodedAttributes = new ArrayList<>(attributes.size());
- try (final ServiceableComponent<AttributeTranscoderRegistry>
- component = getTranscoderRegistry().getServiceableComponent()) {
- if (component == null) {
- throw new AttributeEncodingException("Attribute transoding service unavailable");
- }
+ try (final ServiceableComponent<AttributeTranscoderRegistry> component =
+ getTranscoderRegistry().getServiceableComponent()) {
for (final IdPAttribute attribute : attributes) {
if (attribute != null && !attribute.getValues().isEmpty()) {
encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
}
}
+ } catch (final ServiceException e) {
+ throw new AttributeEncodingException("Attribute transoding service unavailable", e);
}
if (encodedAttributes.isEmpty()) {
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/FilterByQueriedAttributeDesignators.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/FilterByQueriedAttributeDesignators.java
index 883d60f80..193f26477 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/FilterByQueriedAttributeDesignators.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml1/profile/impl/FilterByQueriedAttributeDesignators.java
@@ -53,6 +53,7 @@ import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -170,13 +171,8 @@ public class FilterByQueriedAttributeDesignators extends AbstractProfileAction {
final Set<String> decodedAttributeIds = new HashSet<>();
- try (final ServiceableComponent<AttributeTranscoderRegistry>
- component = transcoderRegistry.getServiceableComponent()) {
- if (component == null) {
- log.error("Attribute transcoder service unavailable");
- ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
- return;
- }
+ try (final ServiceableComponent<AttributeTranscoderRegistry> component =
+ transcoderRegistry.getServiceableComponent()) {
for (final AttributeDesignator designator : query.getAttributeDesignators()) {
try {
@@ -186,6 +182,10 @@ public class FilterByQueriedAttributeDesignators extends AbstractProfileAction {
log.warn("{} Error decoding AttributeDesignators", getLogPrefix(), e);
}
}
+ } catch (final ServiceException e) {
+ log.error("Attribute transcoder service unavailable", e);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
+ return;
}
final Collection<IdPAttribute> keepers = new ArrayList<>(query.getAttributeDesignators().size());
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
index ff4f21178..6c64409c8 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/AddAttributeStatementToAssertion.java
@@ -48,6 +48,7 @@ import net.shibboleth.idp.saml.profile.impl.BaseAddAttributeStatementToAssertion
import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NullableElements;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -137,15 +138,15 @@ public class AddAttributeStatementToAssertion extends BaseAddAttributeStatementT
final ArrayList<Attribute> encodedAttributes = new ArrayList<>(attributes.size());
- try (final ServiceableComponent<AttributeTranscoderRegistry> component = getTranscoderRegistry().getServiceableComponent()) {
- if (component == null) {
- throw new AttributeEncodingException("Attribute transoding service unavailable");
- }
+ try (final ServiceableComponent<AttributeTranscoderRegistry> component =
+ getTranscoderRegistry().getServiceableComponent()) {
for (final IdPAttribute attribute : attributes) {
if (attributes != null && !attribute.getValues().isEmpty()) {
encodeAttribute(component.getComponent(), profileRequestContext, attribute, encodedAttributes);
}
}
+ } catch (final ServiceException e) {
+ throw new AttributeEncodingException("Attribute transoding service unavailable", e);
}
if (encodedAttributes.isEmpty()) {
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributes.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributes.java
index b9c2ba8d3..e7fe74c14 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributes.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/FilterByQueriedAttributes.java
@@ -55,6 +55,7 @@ import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -169,13 +170,8 @@ public class FilterByQueriedAttributes extends AbstractProfileAction {
final Multimap<String,IdPAttribute> mapped = HashMultimap.create();
- try (final ServiceableComponent<AttributeTranscoderRegistry>
- component = transcoderRegistry.getServiceableComponent()) {
- if (component == null) {
- log.error("Attribute transcoder service unavailable");
- ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
- return;
- }
+ try (final ServiceableComponent<AttributeTranscoderRegistry> component =
+ transcoderRegistry.getServiceableComponent()) {
for (final Attribute designator : query.getAttributes()) {
try {
@@ -184,6 +180,10 @@ public class FilterByQueriedAttributes extends AbstractProfileAction {
log.error("{} Error decoding queried Attribute", getLogPrefix(), e);
}
}
+ } catch (final ServiceException e) {
+ log.error("Attribute transcoder service unavailable", e);
+ ActionSupport.buildEvent(profileRequestContext, EventIds.MESSAGE_PROC_ERROR);
+ return;
}
log.debug("{} Query content mapped to attribute IDs: {}", getLogPrefix(), mapped.keySet());
diff --git a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ValidateSAMLAuthentication.java b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ValidateSAMLAuthentication.java
index b084d8da6..dcdfb9726 100644
--- a/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ValidateSAMLAuthentication.java
+++ b/idp-saml-impl/src/main/java/net/shibboleth/idp/saml/saml2/profile/impl/ValidateSAMLAuthentication.java
@@ -77,6 +77,7 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.service.ReloadableService;
+import net.shibboleth.shared.service.ServiceException;
import net.shibboleth.shared.service.ServiceableComponent;
/**
@@ -446,12 +447,8 @@ public class ValidateSAMLAuthentication extends AbstractValidationAction {
final Multimap<String,IdPAttribute> mapped = HashMultimap.create();
- try (final ServiceableComponent<AttributeTranscoderRegistry>
- component = transcoderRegistry.getServiceableComponent()) {
- if (component == null) {
- log.error("Attribute transcoder service unavailable");
- return;
- }
+ try (final ServiceableComponent<AttributeTranscoderRegistry> component =
+ transcoderRegistry.getServiceableComponent()) {
final Response response = (Response) profileRequestContext.getInboundMessageContext().getMessage();
for (final Assertion assertion : response.getAssertions()) {
@@ -465,6 +462,9 @@ public class ValidateSAMLAuthentication extends AbstractValidationAction {
}
}
}
+ } catch (final ServiceException e) {
+ log.error("Attribute transcoder service unavailable", e);
+ return;
}
log.debug("{} Incoming SAML Attributes mapped to attribute IDs: {}", getLogPrefix(), mapped.keySet());
@@ -527,18 +527,15 @@ public class ValidateSAMLAuthentication extends AbstractValidationAction {
populateFilterContext(profileRequestContext, filterContext);
try (final ServiceableComponent<AttributeFilter> component = attributeFilterService.getServiceableComponent()) {
- if (null == component) {
- log.error("{} Error while filtering inbound attributes: Invalid Attribute Filter configuration",
- getLogPrefix());
- } else {
- final AttributeFilter filter = component.getComponent();
- filter.filterAttributes(filterContext);
- filterContext.getParent().removeSubcontext(filterContext);
- attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
- }
+ final AttributeFilter filter = component.getComponent();
+ filter.filterAttributes(filterContext);
+ filterContext.getParent().removeSubcontext(filterContext);
+ attributeContext.setIdPAttributes(filterContext.getFilteredIdPAttributes().values());
} catch (final AttributeFilterException e) {
log.error("{} Error while filtering inbound attributes", getLogPrefix(), e);
- }
+ } catch (final ServiceException e) {
+ log.error("{} Invalid AttributeFilter configuration", getLogPrefix(), e);
+ }
}
/**
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list