[java-idp-plugin-webauthn] branch main updated: Cleanup WebAuthn user.name field names
Phil Smart
philip.smart at jisc.ac.uk
Mon Sep 16 11:31:45 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=e89acdb63e7c2e7dfa2f7d5b0e2aac08bd5f4835
The following commit(s) were added to refs/heads/main by this push:
new e89acdb Cleanup WebAuthn user.name field names
e89acdb is described below
commit e89acdb63e7c2e7dfa2f7d5b0e2aac08bd5f4835
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Mon Sep 16 12:31:42 2024 +0100
Cleanup WebAuthn user.name field names
---
.../admin/CredentialCreationOptionsParameters.java | 36 +++++++++++-----------
.../context/WebAuthnRegistrationContext.java | 10 +++---
.../CredentialCreationOptionsParametersTest.java | 10 +++---
.../authn/webauthn/admin/impl/AddUserName.java | 2 +-
.../CreatePublicKeyCredentialCreationOptions.java | 6 ++--
.../admin/impl/StorePublicKeyCredential.java | 6 ++--
.../impl/YubicoWebAuthnAuthenticationClient.java | 2 +-
...eatePublicKeyCredentialCreationOptionsTest.java | 2 +-
.../admin/impl/StorePublicKeyCredentialTest.java | 2 +-
.../webauthn/client/impl/MockWebAuthnClient.java | 4 +--
10 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
index 8525973..6ad7887 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParameters.java
@@ -47,9 +47,9 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
@Nonnull @NonnullElements private final Set<PublicKeyCredentialDescriptor> excludeCredentials;
/**
- * The username (user.name) of the user that is the subject of this authentication.
+ * The user.name of the user identity.
*/
- @Nonnull @NotEmpty private final String username;
+ @Nonnull @NotEmpty private final String name;
/**
* The user.displayName supplied to the authenticator during registration. A human-palatable name for the user
@@ -83,7 +83,7 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
super(builder.userVerificationRequirement, builder.challenge);
this.excludeCredentials = Constraint.isNotNull(builder.excludeCredentials,
"Exclude credentails can not be null");
- this.username = Constraint.isNotEmpty(builder.username, "Username can not be null or empty");
+ this.name = Constraint.isNotEmpty(builder.name, "User.name can not be null or empty");
this.residentKeyRequirement = Constraint.isNotNull(builder.residentKeyRequirement,
"Resident key requirement can not be null");
this.userId = Constraint.isNotNull(builder.userId, "UserID can not be null");
@@ -105,12 +105,12 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
/**
- * Get the username.
+ * Get the WebAuthn user.name.
*
- * @return the username.
+ * @return the name.
*/
- @Nonnull @NotEmpty public final String getUsername() {
- return username;
+ @Nonnull @NotEmpty public final String getName() {
+ return name;
}
@@ -216,20 +216,20 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
* @param excludeCredentials the credentials to exclude
* @return the next stage
*/
- public IUsernameStage withExcludeCredentials(
+ public INameStage withExcludeCredentials(
@Nonnull final Set<PublicKeyCredentialDescriptor> excludeCredentials);
}
/** Stage interface.*/
- public interface IUsernameStage {
+ public interface INameStage {
/**
- * The username of the user that is the subject of this authentication.
+ * The user.name of the user identity.
*
- * @param username the username
+ * @param name the user.name
* @return the next stage
*/
- public IDisplayNameStage withUsername(@Nonnull @NotEmpty final String username);
+ public IDisplayNameStage withName(@Nonnull @NotEmpty final String name);
}
/** Stage interface.*/
@@ -314,7 +314,7 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
/** Builder class.*/
public static final class Builder implements IUserVerificationRequirementStage, IChallengeStage,
- IExcludeCredentialsStage, IUsernameStage, IDisplayNameStage, IResidentKeyRequirementStage,
+ IExcludeCredentialsStage, INameStage, IDisplayNameStage, IResidentKeyRequirementStage,
IUserHandleStage, IAttestationConveyancePreferenceStage, IBuildStage {
/** Does the authentication/registration require user verification.*/
@@ -326,8 +326,8 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
/** Credentials that have already been registered with the IdP.*/
private Set<PublicKeyCredentialDescriptor> excludeCredentials = Collections.emptySet();
- /** The username of the user that is the subject of this authentication.*/
- private String username;
+ /** The user.name.*/
+ private String name;
/** The requirement on registering a ResidentKey. Also know as a discoverable credential.*/
private ResidentKeyRequirement residentKeyRequirement;
@@ -372,15 +372,15 @@ public final class CredentialCreationOptionsParameters extends BaseOptionsParame
}
@Override
- public IUsernameStage withExcludeCredentials(
+ public INameStage withExcludeCredentials(
@Nonnull final Set<PublicKeyCredentialDescriptor> exclude) {
excludeCredentials = exclude;
return this;
}
@Override
- public IDisplayNameStage withUsername(@Nonnull final String uname) {
- username = uname;
+ public IDisplayNameStage withName(@Nonnull final String uname) {
+ name = uname;
return this;
}
diff --git a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
index 8a8568e..9e45f2f 100644
--- a/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
+++ b/webauthn-api/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/context/WebAuthnRegistrationContext.java
@@ -40,7 +40,7 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
* The WebAuthn user.name of the user. A human-palatable identifier for a user account. It is intended only
* for display by the authenticator, and to help the user select between accounts.
*/
- @Nullable private String webAuthnUsername;
+ @Nullable private String name;
/** A public key credential containing the assertion response that is the result of creating a new credential.*/
@Nullable private PublicKeyCredential<AuthenticatorAttestationResponse, ClientRegistrationExtensionOutputs>
@@ -87,8 +87,8 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
*
* @param username The WebAuthn user.name to set.
*/
- @Nonnull public BaseWebAuthnContext setWebAuthnUsername(@Nullable final String username) {
- webAuthnUsername = username;
+ @Nonnull public BaseWebAuthnContext setName(@Nullable final String webAuthnName) {
+ name = webAuthnName;
return this;
}
@@ -98,8 +98,8 @@ public final class WebAuthnRegistrationContext extends BaseWebAuthnContext {
*
* @return the WebAuthn user.name.
*/
- @Nullable public String getWebAuthnUsername() {
- return webAuthnUsername;
+ @Nullable public String getName() {
+ return name;
}
/**
diff --git a/webauthn-api/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParametersTest.java b/webauthn-api/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParametersTest.java
index 14cf22e..4556293 100644
--- a/webauthn-api/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParametersTest.java
+++ b/webauthn-api/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/CredentialCreationOptionsParametersTest.java
@@ -38,7 +38,7 @@ public class CredentialCreationOptionsParametersTest {
.withUserVerificationRequirement(UserVerificationRequirement.DISCOURAGED)
.withChallenge(new byte[0])
.withExcludeCredentials(CollectionSupport.emptySet())
- .withUsername("username")
+ .withName("username")
.withDisplayName("displayName")
.withResidentKeyRequirement(ResidentKeyRequirement.DISCOURAGED)
.withUserId(new byte[0])
@@ -46,7 +46,7 @@ public class CredentialCreationOptionsParametersTest {
.withAuthenticatorAttachment(AuthenticatorAttachment.CROSS_PLATFORM)
.build();
assertNotNull(options);
- assertEquals(options.getUsername(), "username");
+ assertEquals(options.getName(), "username");
}
@SuppressWarnings("null")
@@ -56,7 +56,7 @@ public class CredentialCreationOptionsParametersTest {
.withUserVerificationRequirement(UserVerificationRequirement.DISCOURAGED)
.withChallenge(new byte[0])
.withExcludeCredentials(CollectionSupport.emptySet())
- .withUsername(null)
+ .withName(null)
.withDisplayName("displayName")
.withResidentKeyRequirement(ResidentKeyRequirement.DISCOURAGED)
.withUserId(new byte[0])
@@ -72,7 +72,7 @@ public class CredentialCreationOptionsParametersTest {
.withUserVerificationRequirement(UserVerificationRequirement.DISCOURAGED)
.withChallenge(new byte[0])
.withExcludeCredentials(CollectionSupport.emptySet())
- .withUsername("username")
+ .withName("username")
.withDisplayName("displayName")
.withResidentKeyRequirement(ResidentKeyRequirement.DISCOURAGED)
.withUserId(null)
@@ -88,7 +88,7 @@ public class CredentialCreationOptionsParametersTest {
.withUserVerificationRequirement(UserVerificationRequirement.DISCOURAGED)
.withChallenge(new byte[0])
.withExcludeCredentials(null)
- .withUsername("username")
+ .withName("username")
.withDisplayName("displayName")
.withResidentKeyRequirement(ResidentKeyRequirement.DISCOURAGED)
.withUserId(new byte[0])
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/AddUserName.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/AddUserName.java
index c62e798..8b766db 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/AddUserName.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/AddUserName.java
@@ -119,7 +119,7 @@ public class AddUserName extends AbstractWebAuthnAction<WebAuthnRegistrationCont
return;
}
log.trace("{} Populating User.name '{}' for user '{}'",getLogPrefix(),webAuthnUserName, username);
- context.setWebAuthnUsername(webAuthnUserName);
+ context.setName(webAuthnUserName);
}
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
index 2152326..46fe5a5 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptions.java
@@ -83,8 +83,8 @@ public class CreatePublicKeyCredentialCreationOptions extends AbstractWebAuthnAc
ActionSupport.buildEvent(profileRequestContext, WebAuthnRegistrationEventIds.INVALID_REGISTRATION_CTX);
return;
}
- final String username = context.getWebAuthnUsername();
- if (username == null) {
+ final String name = context.getName();
+ if (name == null) {
log.error("{} user.name is null",getLogPrefix());
ActionSupport.buildEvent(profileRequestContext, WebAuthnRegistrationEventIds.INVALID_REGISTRATION_CTX);
return;
@@ -122,7 +122,7 @@ public class CreatePublicKeyCredentialCreationOptions extends AbstractWebAuthnAc
.withUserVerificationRequirement(uvRequirement)
.withChallenge(challenge)
.withExcludeCredentials(existingCredentialDescriptors)
- .withUsername(username)
+ .withName(name)
.withDisplayName(displayName)
.withResidentKeyRequirement(residentKeyRequirement)
.withUserId(userId)
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
index 1cb874e..abb34ae 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredential.java
@@ -90,8 +90,8 @@ public class StorePublicKeyCredential extends AbstractWebAuthnAuditingAction<Web
return;
}
- final String webAuthnUsername = context.getWebAuthnUsername();
- if (webAuthnUsername == null) {
+ final String name = context.getName();
+ if (name == null) {
log.error("Unable to find user.name in registration context");
ActionSupport.buildEvent(profileRequestContext, WebAuthnRegistrationEventIds.INVALID_REGISTRATION);
return;
@@ -121,7 +121,7 @@ public class StorePublicKeyCredential extends AbstractWebAuthnAuditingAction<Web
.build();
final UserIdentity user = UserIdentity.builder()
- .name(webAuthnUsername)
+ .name(name)
.displayName(displayName)
.id(new ByteArray(context.getUserId()))
.build();
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
index 152b737..69e6f3c 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/YubicoWebAuthnAuthenticationClient.java
@@ -115,7 +115,7 @@ public class YubicoWebAuthnAuthenticationClient implements WebAuthnAuthenticatio
final UserIdentity identity =
- UserIdentity.builder().name(creationOptions.getUsername())
+ UserIdentity.builder().name(creationOptions.getName())
.displayName(creationOptions.getDisplayName())
.id(new ByteArray(creationOptions.getUserId()))
.build();
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptionsTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptionsTest.java
index 5fb3e84..2b7935b 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptionsTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/CreatePublicKeyCredentialCreationOptionsTest.java
@@ -58,7 +58,7 @@ public class CreatePublicKeyCredentialCreationOptionsTest extends AbstractWebAut
context.setResidentKeyRequirement(ResidentKeyRequirement.PREFERRED);
context.setDisplayName("display name");
context.setUsername("username");
- context.setWebAuthnUsername("username");
+ context.setName("username");
context.setUserId(generateRandomBytes(10));
context.setAttestationConveyancePreference(AttestationConveyancePreference.NONE);
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredentialTest.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredentialTest.java
index 5aa1a58..0b31c10 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredentialTest.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/StorePublicKeyCredentialTest.java
@@ -60,7 +60,7 @@ public class StorePublicKeyCredentialTest extends AbstractWebAuthnTest {
regContext = addWebAuthnRegistrationContext();
regContext.setUsername("jdoe");
- regContext.setWebAuthnUsername("jdoe");
+ regContext.setName("jdoe");
regContext.setDisplayName("John Doe");
userId = generateRandomBytes(16);
regContext.setUserId(userId);
diff --git a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/MockWebAuthnClient.java b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/MockWebAuthnClient.java
index 3b958c0..e23b872 100644
--- a/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/MockWebAuthnClient.java
+++ b/webauthn-impl/src/test/java/net/shibboleth/idp/plugin/authn/webauthn/client/impl/MockWebAuthnClient.java
@@ -111,8 +111,8 @@ public class MockWebAuthnClient implements WebAuthnAuthenticationClient {
final CredentialCreationOptionsParameters creationOptions) throws WebAuthnAuthenticationClientException {
final UserIdentity identity =
- UserIdentity.builder().name(creationOptions.getUsername())
- .displayName(creationOptions.getUsername())
+ UserIdentity.builder().name(creationOptions.getName())
+ .displayName(creationOptions.getDisplayName())
.id(new ByteArray(creationOptions.getUserId()))
.build();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list