[java-idp-plugin-webauthn] 07/11: Rename authenticator policy outcome to ACCEPT from ALLOW
Phil Smart
philip.smart at jisc.ac.uk
Fri Oct 18 17:13:32 UTC 2024
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-webauthn.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-webauthn.git;a=commit;h=b78a280707f9aba6ba346acb25b3b885467f7c3b
commit b78a280707f9aba6ba346acb25b3b885467f7c3b
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Tue Oct 8 14:39:23 2024 +0100
Rename authenticator policy outcome to ACCEPT from ALLOW
---
.../webauthn/admin/policy/AuthenticatorPolicy.java | 18 ++++++---------
.../admin/impl/CheckAuthenticatorPolicy.java | 4 ++--
.../impl/AbstractAuthenticatorPolicyRule.java | 4 ++--
.../impl/ChainingAuthenticatorPolicyRule.java | 4 ++--
.../admin/impl/CheckAuthenticatorPolicyTest.java | 8 +++----
.../impl/AllowlistAuthenticatorPolicyTest.java | 6 ++---
.../AuthenticatorCapabilitiesPolicyRuleTest.java | 4 ++--
.../impl/ChainingAuthenticatorPolicyRuleTest.java | 26 +++++++++++-----------
8 files changed, 35 insertions(+), 39 deletions(-)
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/AuthenticatorPolicy.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/AuthenticatorPolicy.java
index b26c10b..0e280cd 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/AuthenticatorPolicy.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/AuthenticatorPolicy.java
@@ -32,8 +32,8 @@ public interface AuthenticatorPolicy extends IdentifiedComponent{
* Representation of the three outcomes of an AuthenticatorPolicy.
*/
public enum AuthenticatorPolicyOutcome {
- /** Allow the authenticator. */
- ALLOW,
+ /** Accept the authenticator. */
+ ACCEPT,
/** Reject the authenticator. */
REJECT,
/** The policy was not active and should be ignored. */
@@ -45,25 +45,21 @@ public interface AuthenticatorPolicy extends IdentifiedComponent{
* @param outcome the outcome created from the boolean
* @return the outcome associated with the boolean
*/
- public static AuthenticatorPolicyOutcome of(final boolean outcome) {
- if (outcome) {
- return AuthenticatorPolicyOutcome.ALLOW;
- } else {
- return AuthenticatorPolicyOutcome.REJECT;
- }
+ @Nonnull public static AuthenticatorPolicyOutcome of(final boolean outcome) {
+ return outcome ? AuthenticatorPolicyOutcome.ACCEPT: AuthenticatorPolicyOutcome.REJECT;
}
}
/**
- * Execute the policy. Return {@link AuthenticatorPolicyOutcome#ALLOW} if allowed,
+ * Execute and evaluate the policy. Return {@link AuthenticatorPolicyOutcome#ACCEPT} if allowed,
* {@link AuthenticatorPolicyOutcome#REJECT} if rejected, and {@link AuthenticatorPolicyOutcome#IGNORE} otherwise.
*
* @param aaguid the authenticator attestation GUID.
* @param prc the profile request context
*
- * @return the authenticator policy outcome: ALLOW if allowed, REJECT if rejected, and IGNORE if the
+ * @return the authenticator policy outcome: ACCEPT if allowed, REJECT if rejected, and IGNORE if the
* policy is to be ignored (e.g. the policy is not active)
*/
- AuthenticatorPolicyOutcome accept(@Nonnull final AAGUID aaguid, @Nullable final ProfileRequestContext prc);
+ AuthenticatorPolicyOutcome evaluate(@Nonnull final AAGUID aaguid, @Nullable final ProfileRequestContext prc);
}
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicy.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicy.java
index 47f17e7..0d2ae87 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicy.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicy.java
@@ -122,7 +122,7 @@ public class CheckAuthenticatorPolicy extends AbstractWebAuthnAction<WebAuthnReg
final ByteArray aaguid = attestedCredData.get().getAaguid();
final AAGUID authenticatorAttestationGUID = new AAGUID(aaguid);
- if (localPolicy.accept(authenticatorAttestationGUID, profileRequestContext)
+ if (localPolicy.evaluate(authenticatorAttestationGUID, profileRequestContext)
== AuthenticatorPolicyOutcome.REJECT) {
if (log.isWarnEnabled()) {
log.warn("{} Public key registration failed for '{}', authenticator '{}' not allowed", getLogPrefix(),
@@ -134,7 +134,7 @@ public class CheckAuthenticatorPolicy extends AbstractWebAuthnAction<WebAuthnReg
return;
} else {
if (log.isDebugEnabled()) {
- log.debug("{} Authenticator '{}' allowed", getLogPrefix(), authenticatorAttestationGUID.asGuidString());
+ log.debug("{} Authenticator '{}' accepted", getLogPrefix(), authenticatorAttestationGUID.asGuidString());
}
}
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AbstractAuthenticatorPolicyRule.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AbstractAuthenticatorPolicyRule.java
index b95817b..96cc82a 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AbstractAuthenticatorPolicyRule.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AbstractAuthenticatorPolicyRule.java
@@ -35,7 +35,7 @@ import net.shibboleth.shared.primitive.LoggerFactory;
* A base class for {@link AuthenticatorPolicy authenticator policies}. Ensures the AAGUID is not null before it is
* passed to the policy rule implementation. Can be enabled and disabled by the activiation condition.
*
- * <p>Returns {@link AuthenticatorPolicyOutcome#ALLOW} if the authenticator is accepted, returns
+ * <p>Returns {@link AuthenticatorPolicyOutcome#ACCEPT} if the authenticator is accepted, returns
* {@link AuthenticatorPolicyOutcome#REJECT} if the authenticator is rejected, returns
* {@link AuthenticatorPolicyOutcome#IGNORE} if the rule is to be ignored.</p>
*/
@@ -98,7 +98,7 @@ public abstract class AbstractAuthenticatorPolicyRule extends AbstractIdentifiab
/** {@inheritDoc} */
@Override
- public AuthenticatorPolicyOutcome accept(@Nullable final AAGUID aaguid, @Nullable final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(@Nullable final AAGUID aaguid, @Nullable final ProfileRequestContext prc) {
if (!activationCondition.test(aaguid, prc)) {
//not active for this request
log.trace("AuthenticatorPolicy rule '{}' not active for this request", getId());
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRule.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRule.java
index da43205..f941442 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRule.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRule.java
@@ -77,7 +77,7 @@ public class ChainingAuthenticatorPolicyRule extends AbstractAuthenticatorPolicy
log.trace("Trying AuthenticatoryPolicy rule '{}' for authenticator '{}'", policy.getId(),
aaguid.asGuidString());
}
- final AuthenticatorPolicyOutcome outcome = policy.accept(aaguid, prc);
+ final AuthenticatorPolicyOutcome outcome = policy.evaluate(aaguid, prc);
if (outcome == AuthenticatorPolicyOutcome.REJECT) {
if (log.isDebugEnabled()) {
log.debug("AuthenticatorPolicy rule '{}' rejected authenticator '{}'", policy.getId(),
@@ -96,7 +96,7 @@ public class ChainingAuthenticatorPolicyRule extends AbstractAuthenticatorPolicy
}
}
}
- return AuthenticatorPolicyOutcome.ALLOW;
+ return AuthenticatorPolicyOutcome.ACCEPT;
}
}
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicyTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicyTest.java
index eb6c6d6..63885bf 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicyTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CheckAuthenticatorPolicyTest.java
@@ -78,8 +78,8 @@ public class CheckAuthenticatorPolicyTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
- return AuthenticatorPolicyOutcome.ALLOW;
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
+ return AuthenticatorPolicyOutcome.ACCEPT;
}
});
checkAction.initialize();
@@ -99,7 +99,7 @@ public class CheckAuthenticatorPolicyTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
return AuthenticatorPolicyOutcome.IGNORE;
}
});
@@ -120,7 +120,7 @@ public class CheckAuthenticatorPolicyTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
return AuthenticatorPolicyOutcome.REJECT;
}
});
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AllowlistAuthenticatorPolicyTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AllowlistAuthenticatorPolicyTest.java
index d30aedc..e22e6e7 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AllowlistAuthenticatorPolicyTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AllowlistAuthenticatorPolicyTest.java
@@ -52,8 +52,8 @@ public class AllowlistAuthenticatorPolicyTest extends AbstractWebAuthnTest {
policy.setAllowedAuthenticators(CollectionSupport.setOf(new AAGUID(aaguid).asGuidString()));
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
- assertTrue(accepted == AuthenticatorPolicyOutcome.ALLOW);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
+ assertTrue(accepted == AuthenticatorPolicyOutcome.ACCEPT);
}
@@ -61,7 +61,7 @@ public class AllowlistAuthenticatorPolicyTest extends AbstractWebAuthnTest {
public void testNotAllowed() throws ComponentInitializationException {
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
assertTrue(accepted == AuthenticatorPolicyOutcome.REJECT);
}
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AuthenticatorCapabilitiesPolicyRuleTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AuthenticatorCapabilitiesPolicyRuleTest.java
index e3d9348..d194ba9 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AuthenticatorCapabilitiesPolicyRuleTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/AuthenticatorCapabilitiesPolicyRuleTest.java
@@ -52,8 +52,8 @@ public class AuthenticatorCapabilitiesPolicyRuleTest extends AbstractWebAuthnTes
policy.setAuthenticatorCapabilityAcceptor(entries -> true);
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
- assertTrue(accepted == AuthenticatorPolicyOutcome.ALLOW);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
+ assertTrue(accepted == AuthenticatorPolicyOutcome.ACCEPT);
}
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRuleTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRuleTest.java
index a2c8b9d..7d2fdb9 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRuleTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/policy/impl/ChainingAuthenticatorPolicyRuleTest.java
@@ -58,14 +58,14 @@ public class ChainingAuthenticatorPolicyRuleTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
- return AuthenticatorPolicyOutcome.ALLOW;
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
+ return AuthenticatorPolicyOutcome.ACCEPT;
}
}));
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
- assertTrue(accepted == AuthenticatorPolicyOutcome.ALLOW);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
+ assertTrue(accepted == AuthenticatorPolicyOutcome.ACCEPT);
}
@@ -79,13 +79,13 @@ public class ChainingAuthenticatorPolicyRuleTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
return AuthenticatorPolicyOutcome.REJECT;
}
}));
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
assertTrue(accepted == AuthenticatorPolicyOutcome.REJECT);
}
@@ -100,8 +100,8 @@ public class ChainingAuthenticatorPolicyRuleTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
- return AuthenticatorPolicyOutcome.ALLOW;
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
+ return AuthenticatorPolicyOutcome.ACCEPT;
}
}, new AuthenticatorPolicy() {
@@ -111,13 +111,13 @@ public class ChainingAuthenticatorPolicyRuleTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
return AuthenticatorPolicyOutcome.REJECT;
}
}));
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
assertTrue(accepted == AuthenticatorPolicyOutcome.REJECT);
}
@@ -132,14 +132,14 @@ public class ChainingAuthenticatorPolicyRuleTest extends AbstractWebAuthnTest {
}
@Override
- public AuthenticatorPolicyOutcome accept(final AAGUID aaguid, final ProfileRequestContext prc) {
+ public AuthenticatorPolicyOutcome evaluate(final AAGUID aaguid, final ProfileRequestContext prc) {
return AuthenticatorPolicyOutcome.IGNORE;
}
}));
policy.initialize();
- final AuthenticatorPolicyOutcome accepted = policy.accept(new AAGUID(aaguid), prc);
- assertTrue(accepted == AuthenticatorPolicyOutcome.ALLOW);
+ final AuthenticatorPolicyOutcome accepted = policy.evaluate(new AAGUID(aaguid), prc);
+ assertTrue(accepted == AuthenticatorPolicyOutcome.ACCEPT);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list