[java-identity-provider] branch main updated: Add strategy hook for location of UsernamePasswordContext.
Scott Cantor
cantor.2 at osu.edu
Tue May 21 14:43:03 UTC 2024
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=a9001d5f581bde7e283a019618fa10adb5183b69
The following commit(s) were added to refs/heads/main by this push:
new a9001d5f5 Add strategy hook for location of UsernamePasswordContext.
a9001d5f5 is described below
commit a9001d5f581bde7e283a019618fa10adb5183b69
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue May 21 10:43:00 2024 -0400
Add strategy hook for location of UsernamePasswordContext.
---
.../impl/ExtractUsernamePasswordFromBasicAuth.java | 33 +++++++++++++++++++---
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromBasicAuth.java b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromBasicAuth.java
index 3c74fed79..99c5addc7 100644
--- a/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromBasicAuth.java
+++ b/idp-authn-impl/src/main/java/net/shibboleth/idp/authn/impl/ExtractUsernamePasswordFromBasicAuth.java
@@ -15,10 +15,12 @@
package net.shibboleth.idp.authn.impl;
import java.util.Enumeration;
+import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import org.opensaml.messaging.context.navigate.ChildContextLookup;
import org.opensaml.profile.action.ActionSupport;
import org.opensaml.profile.context.ProfileRequestContext;
import org.slf4j.Logger;
@@ -34,6 +36,7 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.codec.Base64Support;
import net.shibboleth.shared.codec.DecodingException;
import net.shibboleth.shared.collection.Pair;
+import net.shibboleth.shared.logic.Constraint;
import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
@@ -56,14 +59,37 @@ public class ExtractUsernamePasswordFromBasicAuth extends AbstractExtractionActi
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(ExtractUsernamePasswordFromBasicAuth.class);
+ /** Creation strategy for UsernamePasswordContext. */
+ @Nonnull private Function<ProfileRequestContext,UsernamePasswordContext> contextCreationStrategy;
+
+ /** Constructor. */
+ @SuppressWarnings("null")
+ public ExtractUsernamePasswordFromBasicAuth() {
+ contextCreationStrategy = new ChildContextLookup<>(UsernamePasswordContext.class, true).compose(
+ new ChildContextLookup<>(AuthenticationContext.class));
+ }
+
+ /**
+ * Sets the creation strategy for the {@link UsernamePasswordContext}.
+ *
+ * @param strategy creation strategy
+ *
+ * @since 5.1.3
+ */
+ public void setUsernamePasswordContextCreationStrategy(
+ @Nonnull final Function<ProfileRequestContext,UsernamePasswordContext> strategy) {
+ checkSetterPreconditions();
+
+ contextCreationStrategy = Constraint.isNotNull(strategy,
+ "UsernamePasswordContext creation strategy cannot be null");
+ }
+
/** {@inheritDoc} */
- // CheckStyle: ReturnCount OFF
@Override
protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext,
@Nonnull final AuthenticationContext authenticationContext) {
- final UsernamePasswordContext upCtx =
- authenticationContext.ensureSubcontext(UsernamePasswordContext.class);
+ final UsernamePasswordContext upCtx = contextCreationStrategy.apply(profileRequestContext);
upCtx.setUsername(null);
upCtx.setPassword(null);
@@ -89,7 +115,6 @@ public class ExtractUsernamePasswordFromBasicAuth extends AbstractExtractionActi
upCtx.setUsername(applyTransforms(profileRequestContext, decodedCredentials.getFirst()))
.setPassword(decodedCredentials.getSecond());
}
- // CheckStyle: ReturnCount ON
/**
* Gets the encoded credentials passed in via the {@link HttpHeaders#AUTHORIZATION} header. This method checks to
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list