Skip to content

SPC extension #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,20 @@ public class AssertionExtensionInputs implements ExtensionInputs {
private final AppId appid;
private final Extensions.LargeBlob.LargeBlobAuthenticationInput largeBlob;
private final Extensions.Prf.PrfAuthenticationInput prf;
private final Extensions.Spc.SpcAuthenticationInput spc;
private final Boolean uvm;

@JsonCreator
private AssertionExtensionInputs(
@JsonProperty("appid") AppId appid,
@JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobAuthenticationInput largeBlob,
@JsonProperty("prf") Extensions.Prf.PrfAuthenticationInput prf,
@JsonProperty("spc") Extensions.Spc.SpcAuthenticationInput spc,
@JsonProperty("uvm") Boolean uvm) {
this.appid = appid;
this.largeBlob = largeBlob;
this.prf = prf;
this.spc = spc;
this.uvm = (uvm != null && uvm) ? true : null;
}

Expand All @@ -83,6 +86,7 @@ public AssertionExtensionInputs merge(AssertionExtensionInputs other) {
this.appid != null ? this.appid : other.appid,
this.largeBlob != null ? this.largeBlob : other.largeBlob,
this.prf != null ? this.prf : other.prf,
this.spc != null ? this.spc : other.spc,
this.uvm != null ? this.uvm : other.uvm);
}

Expand All @@ -103,6 +107,9 @@ public Set<String> getExtensionIds() {
if (prf != null) {
ids.add(Extensions.Prf.EXTENSION_ID);
}
if (spc != null) {
ids.add(Extensions.Spc.EXTENSION_ID);
}
if (getUvm()) {
ids.add(Extensions.Uvm.EXTENSION_ID);
}
Expand Down Expand Up @@ -212,6 +219,21 @@ public AssertionExtensionInputsBuilder prf(Extensions.Prf.PrfAuthenticationInput
return this;
}

/**
* Enable the Secure Payment Confirmation extension (<code>spc</code>).
*
* <p>This extension indicates that a credential is either being created for or used for Secure
* Payment Confirmation, respectively.
*
* @see <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">§5.
* Secure Payment Confirmation extension (SPC)</a>
*/
public AssertionExtensionInputsBuilder spc(Extensions.Spc.SpcAuthenticationInput spc) {
this.spc = spc;
return this;
}

/**
* Enable the User Verification Method Extension (<code>uvm</code>).
*
Expand Down Expand Up @@ -299,6 +321,37 @@ private Extensions.Prf.PrfAuthenticationInput getPrfJson() {
: null;
}

/**
* The input to the Secure Payment Confirmation (<code>spc</code>) extension, if any.
*
* <p>This extension indicates that a credential is either being created for or used for Secure
* Payment Confirmation, respectively.
*
* @see <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">§5.
* Secure Payment Confirmation extension (SPC)</a>
*/
public Optional<Extensions.Spc.SpcAuthenticationInput> getSpc() {
return Optional.ofNullable(spc);
}

/** For JSON serialization, to omit false and null values. */
@JsonProperty("spc")
private Extensions.Spc.SpcAuthenticationInput getSpcJson() {
return spc != null
&& (spc.getIsPayment()
|| spc.getBrowserBoundPubKeyCredParams().isPresent()
|| spc.getRpId().isPresent()
|| spc.getTopOrigin().isPresent()
|| spc.getPayeeName().isPresent()
|| spc.getPayeeOrigin().isPresent()
|| spc.getPaymentEntitiesLogos().isPresent()
|| spc.getTotal().isPresent()
|| spc.getInstrument().isPresent())
? spc
: null;
}

/**
* @return <code>true</code> if the User Verification Method Extension (<code>uvm</code>) is
* enabled, <code>false</code> otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,18 @@ public class ClientAssertionExtensionOutputs implements ClientExtensionOutputs {

private final Extensions.Prf.PrfAuthenticationOutput prf;

private final Extensions.Spc.SpcAuthenticationOutput spc;

@JsonCreator
private ClientAssertionExtensionOutputs(
@JsonProperty("appid") Boolean appid,
@JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobAuthenticationOutput largeBlob,
@JsonProperty("prf") Extensions.Prf.PrfAuthenticationOutput prf) {
@JsonProperty("prf") Extensions.Prf.PrfAuthenticationOutput prf,
@JsonProperty("spc") Extensions.Spc.SpcAuthenticationOutput spc) {
this.appid = appid;
this.largeBlob = largeBlob;
this.prf = prf;
this.spc = spc;
}

@Override
Expand All @@ -91,6 +95,9 @@ public Set<String> getExtensionIds() {
if (prf != null) {
ids.add(Extensions.Prf.EXTENSION_ID);
}
if (spc != null) {
ids.add(Extensions.Spc.EXTENSION_ID);
}
return ids;
}

Expand Down Expand Up @@ -135,6 +142,20 @@ public Optional<Extensions.Prf.PrfAuthenticationOutput> getPrf() {
return Optional.ofNullable(prf);
}

/**
* The extension output for the <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">Secure
* Payment Confirmation extension (<code>spc</code>)</a>, if any.
*
* @see com.yubico.webauthn.data.Extensions.Spc.SpcAuthenticationOutput
* @see <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">§5.
* Secure Payment Confirmation extension (SPC)</a>
*/
public Optional<Extensions.Spc.SpcAuthenticationOutput> getSpc() {
return Optional.ofNullable(spc);
}

public static class ClientAssertionExtensionOutputsBuilder {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,21 @@ public class ClientRegistrationExtensionOutputs implements ClientExtensionOutput

private final Extensions.Prf.PrfRegistrationOutput prf;

private final Extensions.Spc.SpcRegistrationOutput spc;

@JsonCreator
private ClientRegistrationExtensionOutputs(
@JsonProperty("appidExclude") Boolean appidExclude,
@JsonProperty("credProps")
Extensions.CredentialProperties.CredentialPropertiesOutput credProps,
@JsonProperty("largeBlob") Extensions.LargeBlob.LargeBlobRegistrationOutput largeBlob,
@JsonProperty("prf") Extensions.Prf.PrfRegistrationOutput prf) {
@JsonProperty("prf") Extensions.Prf.PrfRegistrationOutput prf,
@JsonProperty("spc") Extensions.Spc.SpcRegistrationOutput spc) {
this.appidExclude = appidExclude;
this.credProps = credProps;
this.largeBlob = largeBlob;
this.prf = prf;
this.spc = spc;
}

@Override
Expand All @@ -89,6 +93,9 @@ public Set<String> getExtensionIds() {
if (prf != null) {
ids.add(Extensions.Prf.EXTENSION_ID);
}
if (spc != null) {
ids.add(Extensions.Spc.EXTENSION_ID);
}
return ids;
}

Expand Down Expand Up @@ -148,4 +155,18 @@ public Optional<Extensions.LargeBlob.LargeBlobRegistrationOutput> getLargeBlob()
public Optional<Extensions.Prf.PrfRegistrationOutput> getPrf() {
return Optional.ofNullable(prf);
}

/**
* The extension output for the <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">Secure
* Payment Confirmation (<code>spc</code>) extension</a>, if any.
*
* @see com.yubico.webauthn.data.Extensions.Spc.SpcRegistrationOutput
* @see <a
* href="https://www.w3.org/TR/secure-payment-confirmation/#sctn-payment-extension-registration">§5.
* Secure Payment Confirmation extension (SPC)</a>
*/
public Optional<Extensions.Spc.SpcRegistrationOutput> getSpc() {
return Optional.ofNullable(spc);
}
}
Loading