[java-shib-attribute] 08/11: JSATTR-34 Log contents of primary contexts at start of execution
Scott Cantor
cantor.2 at osu.edu
Mon Mar 17 13:58:53 UTC 2025
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch maint-5.1
in repository java-shib-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=609b728a550db910cbdc0be520d2596631d3917e
commit 609b728a550db910cbdc0be520d2596631d3917e
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Oct 16 13:52:10 2024 +0100
JSATTR-34 Log contents of primary contexts at start of execution
https://shibboleth.atlassian.net/browse/JSATTR-34
---
.../resolver/impl/AttributeResolverImpl.java | 32 ++++++++++++++++++++--
.../impl/EntityAttributesDataConnector.java | 10 +++++--
2 files changed, 37 insertions(+), 5 deletions(-)
diff --git a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
index ec82e7e33..c202dc6ab 100644
--- a/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
+++ b/shib-attribute-resolver-impl/src/main/java/net/shibboleth/idp/attribute/resolver/impl/AttributeResolverImpl.java
@@ -193,8 +193,7 @@ public class AttributeResolverImpl extends AbstractIdentifiableInitializableComp
final boolean timerStarted = startTimer(resolutionContext);
try {
- log.debug("{} Initiating attribute resolution with label: {}", logPrefix,
- resolutionContext.getResolutionLabel());
+ logContext(resolutionContext);
if (!preRequestedAttributes.isEmpty()) {
log.debug("Resolving pre-requested Attributes");
@@ -259,6 +258,35 @@ public class AttributeResolverImpl extends AbstractIdentifiableInitializableComp
}
}
}
+
+ /** Code to replace (null) with <Not Supplied> in the log
+ * @param input an input
+ * @return the input or a fixed string
+ */
+ private @Nonnull String notProvidedOr(@Nullable String input) {
+ return input == null?"<Not Supplied>":input;
+ }
+
+ /** Before we start log all we know about the resolver and context (at {@link Logger#debug(String)}).
+ * @param resolutionContext the context
+ */
+ private void logContext(AttributeResolutionContext resolutionContext) {
+ log.debug("{} Initiating attribute resolution with label: {}", logPrefix,
+ notProvidedOr(resolutionContext.getResolutionLabel()));
+ if (!preRequestedAttributes.isEmpty()) {
+ log.debug("{} PrerequestAttributes {}", logPrefix, preRequestedAttributes);
+ }
+ final Collection<String> requestedNames = resolutionContext.getRequestedIdPAttributeNames();
+ if (requestedNames.isEmpty()) {
+ log.debug("{} No attributes requested, resolving everything", logPrefix);
+ } else {
+ log.debug("{} Attributes requested {}", logPrefix, requestedNames);
+ }
+ log.debug("{} Principal {}, IssuerID {}, RecipientID {}, RecipientGroupId {}",
+ logPrefix, notProvidedOr(resolutionContext.getPrincipal()), notProvidedOr(resolutionContext.getAttributeIssuerID()),
+ notProvidedOr(resolutionContext.getAttributeRecipientID()), notProvidedOr(resolutionContext.getAttributeRecipientGroupID()));
+ }
+
// CheckStyle: CyclomaticComplexity|MethodLength ON
/**
diff --git a/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/EntityAttributesDataConnector.java b/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/EntityAttributesDataConnector.java
index 9ef334389..0e99c6286 100644
--- a/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/EntityAttributesDataConnector.java
+++ b/shib-saml-attribute-impl/src/main/java/net/shibboleth/idp/saml/attribute/resolver/impl/EntityAttributesDataConnector.java
@@ -68,9 +68,12 @@ public class EntityAttributesDataConnector extends AbstractDataConnector {
/** Constructor. */
public EntityAttributesDataConnector() {
// Default is inbound -> SAMLPeerEntityContext -> SAMLMetadataContext.
- metadataContextLookupStrategy = new ChildContextLookup<>(SAMLMetadataContext.class).compose(
- new ChildContextLookup<>(SAMLPeerEntityContext.class).compose(
- new InboundMessageContextLookup()));
+ final Function<ProfileRequestContext,SAMLMetadataContext> strat =
+ new ChildContextLookup<>(SAMLMetadataContext.class).compose(
+ new ChildContextLookup<>(SAMLPeerEntityContext.class).compose(
+ new InboundMessageContextLookup()));
+ assert strat != null;
+ metadataContextLookupStrategy = strat;
}
/**
@@ -91,6 +94,7 @@ public class EntityAttributesDataConnector extends AbstractDataConnector {
final SAMLMetadataContext metadataContext = metadataContextLookupStrategy.apply(
resolutionContext.getProfileRequestContextLookupStrategy().apply(resolutionContext));
+ log.debug("Metadata Context {}", metadataContext == null ? "absent" : "present");
final EntityDescriptor entity = metadataContext != null ? metadataContext.getEntityDescriptor() : null;
if (entity == null) {
log.debug("Specified metadata source was absent.");
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list