3232import com .fasterxml .jackson .databind .annotation .JsonSerialize ;
3333import com .google .common .cache .Cache ;
3434import com .google .common .cache .CacheBuilder ;
35- import com .upokecenter .cbor .CBORObject ;
36- import com .yubico .fido .metadata .FidoMetadataDownloaderException ;
37- import com .yubico .fido .metadata .UnexpectedLegalHeader ;
3835import com .yubico .internal .util .CertificateParser ;
3936import com .yubico .internal .util .JacksonCodecs ;
4037import com .yubico .util .Either ;
5350import com .yubico .webauthn .data .AuthenticatorSelectionCriteria ;
5451import com .yubico .webauthn .data .AuthenticatorTransport ;
5552import com .yubico .webauthn .data .ByteArray ;
56- import com .yubico .webauthn .data .COSEAlgorithmIdentifier ;
5753import com .yubico .webauthn .data .RelyingPartyIdentity ;
5854import com .yubico .webauthn .data .ResidentKeyRequirement ;
5955import com .yubico .webauthn .data .UserIdentity ;
60- import com .yubico .webauthn .data .exception .Base64UrlException ;
6156import com .yubico .webauthn .exception .AssertionFailedException ;
6257import com .yubico .webauthn .exception .RegistrationFailedException ;
63- import com .yubico .webauthn .extension .appid .InvalidAppIdException ;
6458import demo .webauthn .data .AssertionRequestWrapper ;
6559import demo .webauthn .data .AssertionResponse ;
6660import demo .webauthn .data .CredentialRegistration ;
6761import demo .webauthn .data .RegistrationRequest ;
6862import demo .webauthn .data .RegistrationResponse ;
6963import java .io .IOException ;
70- import java .security .DigestException ;
71- import java .security .InvalidAlgorithmParameterException ;
72- import java .security .InvalidKeyException ;
73- import java .security .NoSuchAlgorithmException ;
7464import java .security .SecureRandom ;
75- import java .security .SignatureException ;
76- import java .security .cert .CertPathValidatorException ;
7765import java .security .cert .CertificateException ;
7866import java .security .cert .X509Certificate ;
7967import java .time .Clock ;
8068import java .util .Arrays ;
8169import java .util .Collection ;
8270import java .util .Collections ;
83- import java .util .HashMap ;
8471import java .util .List ;
85- import java .util .Map ;
8672import java .util .Optional ;
8773import java .util .Set ;
8874import java .util .SortedSet ;
@@ -112,11 +98,7 @@ public class WebAuthnServer {
11298
11399 private final RelyingParty rp ;
114100
115- public WebAuthnServer ()
116- throws InvalidAppIdException , CertificateException , CertPathValidatorException ,
117- InvalidAlgorithmParameterException , Base64UrlException , DigestException ,
118- FidoMetadataDownloaderException , UnexpectedLegalHeader , IOException ,
119- NoSuchAlgorithmException , SignatureException , InvalidKeyException {
101+ public WebAuthnServer () {
120102 this (
121103 new InMemoryRegistrationStorage (),
122104 newCache (),
@@ -130,11 +112,7 @@ public WebAuthnServer(
130112 Cache <ByteArray , RegistrationRequest > registerRequestStorage ,
131113 Cache <ByteArray , AssertionRequestWrapper > assertRequestStorage ,
132114 RelyingPartyIdentity rpIdentity ,
133- Set <String > origins )
134- throws InvalidAppIdException , CertificateException , CertPathValidatorException ,
135- InvalidAlgorithmParameterException , Base64UrlException , DigestException ,
136- FidoMetadataDownloaderException , UnexpectedLegalHeader , IOException ,
137- NoSuchAlgorithmException , SignatureException , InvalidKeyException {
115+ Set <String > origins ) {
138116 this .userStorage = userStorage ;
139117 this .registerRequestStorage = registerRequestStorage ;
140118 this .assertRequestStorage = assertRequestStorage ;
@@ -579,29 +557,6 @@ private CredentialRegistration addRegistration(
579557 return reg ;
580558 }
581559
582- static ByteArray rawEcdaKeyToCose (ByteArray key ) {
583- final byte [] keyBytes = key .getBytes ();
584-
585- if (!(keyBytes .length == 64 || (keyBytes .length == 65 && keyBytes [0 ] == 0x04 ))) {
586- throw new IllegalArgumentException (
587- String .format (
588- "Raw key must be 64 bytes long or be 65 bytes long and start with 0x04, was %d bytes starting with %02x" ,
589- keyBytes .length , keyBytes [0 ]));
590- }
591-
592- final int start = keyBytes .length == 64 ? 0 : 1 ;
593-
594- Map <Long , Object > coseKey = new HashMap <>();
595-
596- coseKey .put (1L , 2L ); // Key type: EC
597- coseKey .put (3L , COSEAlgorithmIdentifier .ES256 .getId ());
598- coseKey .put (-1L , 1L ); // Curve: P-256
599- coseKey .put (-2L , Arrays .copyOfRange (keyBytes , start , start + 32 )); // x
600- coseKey .put (-3L , Arrays .copyOfRange (keyBytes , start + 32 , start + 64 )); // y
601-
602- return new ByteArray (CBORObject .FromObject (coseKey ).EncodeToBytes ());
603- }
604-
605560 private static class AuthDataSerializer extends JsonSerializer <AuthenticatorData > {
606561 @ Override
607562 public void serialize (
0 commit comments