[java-identity-provider] branch main updated: IDP-2081 - Add variant of MFA context isAcceptable with specific input
Scott Cantor
cantor.2 at osu.edu
Wed Mar 15 16:22:41 UTC 2023
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=f942b63adcd5e9220a1015ff0facd13ff271cf28
The following commit(s) were added to refs/heads/main by this push:
new f942b63ad IDP-2081 - Add variant of MFA context isAcceptable with specific input
f942b63ad is described below
commit f942b63adcd5e9220a1015ff0facd13ff271cf28
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 15 12:22:01 2023 -0400
IDP-2081 - Add variant of MFA context isAcceptable with specific input
https://shibboleth.atlassian.net/browse/IDP-2081
---
.../context/MultiFactorAuthenticationContext.java | 35 +++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/MultiFactorAuthenticationContext.java b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/MultiFactorAuthenticationContext.java
index 13dad3913..524185b1b 100644
--- a/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/MultiFactorAuthenticationContext.java
+++ b/idp-authn-api/src/main/java/net/shibboleth/idp/authn/context/MultiFactorAuthenticationContext.java
@@ -17,11 +17,13 @@
package net.shibboleth.idp.authn.context;
+import java.security.Principal;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+import javax.security.auth.Subject;
import net.shibboleth.idp.authn.AuthenticationFlowDescriptor;
import net.shibboleth.idp.authn.AuthenticationResult;
@@ -197,5 +199,36 @@ public final class MultiFactorAuthenticationContext extends BaseContext {
return false;
}
-
+
+ /**
+ * Get whether any active result in this context contains the input {@link Principal}.
+ *
+ * <p>This is a "crude" means of testing for the existence of a particular {@link Principal}
+ * inside an active result. Usually this is used to test for the existence of a particular custom
+ * value used to represent a particular login quality or type.</p>
+ *
+ * @param principal input to check for
+ *
+ * @return true iff an active and presumably usable result contains the input
+ *
+ * @since 5.0.0
+ */
+ public boolean isActive(@Nonnull final Principal principal) {
+ final AuthenticationContext authnContext = (AuthenticationContext) getParent();
+ if (authnContext != null) {
+ for (final AuthenticationResult result : activeResults.values()) {
+ assert result != null;
+ // Only include Principals from fresh results or when forced authn is off.
+ if (!(authnContext.isForceAuthn() && result.isPreviousResult())) {
+ final Subject subject = result.getSubject();
+ if (subject.getPrincipals().contains(principal)) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list