Skip to content

Commit

Permalink
Optimize getParsedAuthenticatorData()
Browse files Browse the repository at this point in the history
  • Loading branch information
emlun committed Nov 10, 2022
1 parent 350c784 commit a6d89fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ public class AuthenticatorAssertionResponse implements AuthenticatorResponse {
*/
private final ByteArray userHandle;

// This overrides the default getter in AuthenticatorResponse which re-parses the authenticator
// data on every invocation. This "optimization" has no measurable impact on performance, but it
// seems rude to obviously waste cycles for nothing.
private final transient AuthenticatorData parsedAuthenticatorData;

@NonNull
@Getter(onMethod = @__({@Override}))
private final transient CollectedClientData clientData;
Expand All @@ -85,6 +90,7 @@ private AuthenticatorAssertionResponse(
@JsonProperty("userHandle") final ByteArray userHandle)
throws IOException, Base64UrlException {
this.authenticatorData = authenticatorData;
this.parsedAuthenticatorData = new AuthenticatorData(authenticatorData);
this.clientDataJSON = clientDataJSON;
this.signature = signature;
this.userHandle = userHandle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ private AuthenticatorAttestationResponse(
this.clientData = new CollectedClientData(clientDataJSON);
}

// The default getter in AuthenticatorResponse re-parses the authenticator data on every
// invocation. This "optimization" override has no measurable impact on performance, but it seems
// rude to obviously waste cycles for nothing.
@Override
public AuthenticatorData getParsedAuthenticatorData() {
return attestation.getAuthenticatorData();
}

public static AuthenticatorAttestationResponseBuilder.MandatoryStages builder() {
return new AuthenticatorAttestationResponseBuilder.MandatoryStages();
}
Expand Down

0 comments on commit a6d89fd

Please sign in to comment.