@@ -77,67 +77,6 @@ public WebAuthn4JWebAuthnManager() {
77
77
this (new WebAuthnDataConverter ());
78
78
}
79
79
80
- /**
81
- * Wraps WebAuthnAuthentication to proper {@link RuntimeException} (mainly {@link AuthenticationException} subclass.
82
- *
83
- * @param e exception to be wrapped
84
- * @return wrapping exception
85
- */
86
- @ SuppressWarnings ("squid:S3776" )
87
- static RuntimeException wrapWithAuthenticationException (WebAuthnException e ) {
88
- // ValidationExceptions
89
- if (e instanceof com .webauthn4j .validator .exception .BadAaguidException ) {
90
- return new BadAaguidException (e .getMessage (), e );
91
- } else if (e instanceof com .webauthn4j .validator .exception .BadAlgorithmException ) {
92
- return new BadAlgorithmException (e .getMessage (), e );
93
- } else if (e instanceof com .webauthn4j .validator .exception .BadAttestationStatementException ) {
94
- if (e instanceof com .webauthn4j .validator .exception .KeyDescriptionValidationException ) {
95
- return new KeyDescriptionValidationException (e .getMessage (), e );
96
- } else {
97
- return new BadAttestationStatementException (e .getMessage (), e );
98
- }
99
- } else if (e instanceof com .webauthn4j .validator .exception .BadChallengeException ) {
100
- return new BadChallengeException (e .getMessage (), e );
101
- } else if (e instanceof com .webauthn4j .validator .exception .BadOriginException ) {
102
- return new BadOriginException (e .getMessage (), e );
103
- } else if (e instanceof com .webauthn4j .validator .exception .BadRpIdException ) {
104
- return new BadRpIdException (e .getMessage (), e );
105
- } else if (e instanceof com .webauthn4j .validator .exception .BadSignatureException ) {
106
- return new BadSignatureException (e .getMessage (), e );
107
- } else if (e instanceof com .webauthn4j .validator .exception .CertificateException ) {
108
- return new CertificateException (e .getMessage (), e );
109
- } else if (e instanceof com .webauthn4j .validator .exception .ConstraintViolationException ) {
110
- return new ConstraintViolationException (e .getMessage (), e );
111
- } else if (e instanceof com .webauthn4j .validator .exception .MaliciousCounterValueException ) {
112
- return new MaliciousCounterValueException (e .getMessage (), e );
113
- } else if (e instanceof com .webauthn4j .validator .exception .MaliciousDataException ) {
114
- return new MaliciousDataException (e .getMessage (), e );
115
- } else if (e instanceof com .webauthn4j .validator .exception .MissingChallengeException ) {
116
- return new MissingChallengeException (e .getMessage (), e );
117
- } else if (e instanceof com .webauthn4j .validator .exception .PublicKeyMismatchException ) {
118
- return new PublicKeyMismatchException (e .getMessage (), e );
119
- } else if (e instanceof com .webauthn4j .validator .exception .SelfAttestationProhibitedException ) {
120
- return new SelfAttestationProhibitedException (e .getMessage (), e );
121
- } else if (e instanceof com .webauthn4j .validator .exception .TokenBindingException ) {
122
- return new TokenBindingException (e .getMessage (), e );
123
- } else if (e instanceof com .webauthn4j .validator .exception .TrustAnchorNotFoundException ) {
124
- return new TrustAnchorNotFoundException (e .getMessage (), e );
125
- } else if (e instanceof com .webauthn4j .validator .exception .UnexpectedExtensionException ) {
126
- return new UnexpectedExtensionException (e .getMessage (), e );
127
- } else if (e instanceof com .webauthn4j .validator .exception .UserNotPresentException ) {
128
- return new UserNotPresentException (e .getMessage (), e );
129
- } else if (e instanceof com .webauthn4j .validator .exception .UserNotVerifiedException ) {
130
- return new UserNotVerifiedException (e .getMessage (), e );
131
- } else if (e instanceof com .webauthn4j .validator .exception .ValidationException ) {
132
- return new ValidationException ("WebAuthn validation error" , e );
133
- }
134
- // DataConversionException
135
- else if (e instanceof com .webauthn4j .converter .exception .DataConversionException ) {
136
- return new DataConversionException ("WebAuthn data conversion error" , e );
137
- } else {
138
- return new AuthenticationServiceException (null , e );
139
- }
140
- }
141
80
142
81
public void verifyRegistrationData (
143
82
WebAuthnRegistrationData registrationData
@@ -152,11 +91,7 @@ public void verifyRegistrationData(
152
91
153
92
WebAuthnRegistrationContext registrationContext = createRegistrationContext (registrationData );
154
93
155
- try {
156
- registrationContextValidator .validate (registrationContext );
157
- } catch (WebAuthnException e ) {
158
- throw wrapWithAuthenticationException (e );
159
- }
94
+ registrationContextValidator .validate (registrationContext );
160
95
}
161
96
162
97
@ Override
@@ -184,11 +119,7 @@ public void verifyAuthenticationData(WebAuthnAuthenticationData authenticationDa
184
119
transports
185
120
);
186
121
187
- try {
188
- authenticationContextValidator .validate (authenticationContext , authenticator );
189
- } catch (WebAuthnException e ) {
190
- throw wrapWithAuthenticationException (e );
191
- }
122
+ authenticationContextValidator .validate (authenticationContext , authenticator );
192
123
193
124
}
194
125
0 commit comments