[java-shib-attribute] branch main updated: JSATTR-34 Log contents of primary contexts at start of execution
Rod Widdowson
rdw at steadingsoftware.com
Thu Oct 17 12:53:20 UTC 2024
This is an automated email from the git hooks/post-receive script.
rdw pushed a commit to branch main
in repository java-shib-attribute.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-attribute.git;a=commit;h=0c544d81c20439fbb3009bf7639ae7c8c5925a5f
The following commit(s) were added to refs/heads/main by this push:
new 0c544d81c JSATTR-34 Log contents of primary contexts at start of execution
0c544d81c is described below
commit 0c544d81c20439fbb3009bf7639ae7c8c5925a5f
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Thu Oct 17 13:42:15 2024 +0100
JSATTR-34 Log contents of primary contexts at start of execution
https://shibboleth.atlassian.net/issues/JSATTR-34
filtering
---
.../attribute/filter/impl/AttributeFilterImpl.java | 37 ++++++++++++++++++++++
.../resolver/impl/AttributeResolverImpl.java | 2 +-
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
index 1f1e7dd48..05162e5da 100644
--- a/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
+++ b/shib-attribute-filter-impl/src/main/java/net/shibboleth/idp/attribute/filter/impl/AttributeFilterImpl.java
@@ -29,6 +29,7 @@ import javax.annotation.concurrent.ThreadSafe;
import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.messaging.context.navigate.RootContextLookup;
import org.opensaml.profile.context.MetricContext;
+import org.opensaml.profile.context.ProxiedRequesterContext;
import org.slf4j.Logger;
import net.shibboleth.idp.attribute.IdPAttribute;
@@ -113,6 +114,7 @@ public class AttributeFilterImpl extends AbstractIdentifiableInitializableCompon
log.debug("{} Beginning process of filtering the following {} attributes: {}", new Object[] {getLogPrefix(),
prefilteredAttributes.size(), prefilteredAttributes.keySet(),});
+ logContext(filterContext);
final List<AttributeFilterPolicy> policies = getFilterPolicies();
for (final AttributeFilterPolicy policy : policies) {
@@ -148,6 +150,41 @@ public class AttributeFilterImpl extends AbstractIdentifiableInitializableCompon
}
}
+ /** Code to replace (null) with <Not Supplied> in the log
+ * @param input an input String
+ * @return the input or a fixed string
+ */
+ private @Nonnull String notProvidedOr(@Nullable String input) {
+ return input == null?"<Not Supplied>":input;
+ }
+
+ /** Return whether an object is null.
+ * @param input an input String
+ * @return {@literal "present"} or {@literal "not present"}
+ */
+ private @Nonnull String present(@Nullable Object input) {
+ return input != null?"present":"not present";
+ }
+
+ /** Before we start log all we know about the resolver and context (at {@link Logger#debug(String)}).
+ * @param filterContext the context
+ */
+ private void logContext(final @Nonnull AttributeFilterContext filterContext) {
+
+ log.debug("{} Principal {}, IssuerID {}, RecipientID {}, RecipientGroupId {}",
+ logPrefix, notProvidedOr(filterContext.getPrincipal()), notProvidedOr(filterContext.getAttributeIssuerID()),
+ notProvidedOr(filterContext.getAttributeRecipientID()), notProvidedOr(filterContext.getAttributeRecipientGroupID()));
+ log.debug("{} Direction {}", logPrefix, filterContext.getDirection());
+ log.debug("{} Issuer MetadataContext {}, Requester MetadataContext {}, Proxied MetadataContext {}", logPrefix,
+ present(filterContext.getIssuerMetadataContext()), present(filterContext.getRequesterMetadataContext()),
+ present(filterContext.getProxiedRequesterMetadataContext()));
+ final ProxiedRequesterContext proxiedContext = filterContext.getProxiedRequesterContext();
+ final @Nonnull Collection<String> requesters = proxiedContext != null ? proxiedContext.getRequesters() : CollectionSupport.emptyList();
+ if (!requesters.isEmpty()) {
+ log.debug("{} Proxy requesters {}", logPrefix, requesters);
+ }
+ }
+
/**
* Gets the permitted values for the given attribute from the
* {@link AttributeFilterWorkContext#getPermittedIdPAttributeValues()} and removes all denied values given in the
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 c202dc6ab..f081fa5ff 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
@@ -270,7 +270,7 @@ public class AttributeResolverImpl extends AbstractIdentifiableInitializableComp
/** 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) {
+ private void logContext(final @Nonnull AttributeResolutionContext resolutionContext) {
log.debug("{} Initiating attribute resolution with label: {}", logPrefix,
notProvidedOr(resolutionContext.getResolutionLabel()));
if (!preRequestedAttributes.isEmpty()) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list