-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serialize/deserialize PublicKeyCredentialCreationOptions and Publ…
…icKeyCredentialRequestOptions support with ObjectMapper gh-16433 PublicKeyCredentialRequestOptions gh-16434 PublicKeyCredentialCreationOptions
- Loading branch information
1 parent
d3332e1
commit bab5868
Showing
38 changed files
with
1,186 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...mework/security/web/webauthn/jackson/AuthenticationExtensionsClientInputDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.security.web.webauthn.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInput; | ||
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInput; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Jackson deserializer for {@link AuthenticationExtensionsClientInput} | ||
* | ||
* @author Justin Cranford | ||
* @since 6.5 | ||
*/ | ||
@SuppressWarnings("serial") | ||
class AuthenticationExtensionsClientInputDeserializer extends StdDeserializer<AuthenticationExtensionsClientInput> { | ||
|
||
AuthenticationExtensionsClientInputDeserializer() { | ||
super(AuthenticationExtensionsClientInput.class); | ||
} | ||
|
||
@Override | ||
public AuthenticationExtensionsClientInput deserialize(JsonParser parser, DeserializationContext ctxt) | ||
throws IOException { | ||
if (parser.nextToken() != JsonToken.END_OBJECT) { | ||
String extensionId = parser.currentName(); | ||
Object value = parser.readValueAs(Object.class); | ||
return new ImmutableAuthenticationExtensionsClientInput(extensionId, value); | ||
} | ||
return null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ework/security/web/webauthn/jackson/AuthenticationExtensionsClientInputsDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.security.web.webauthn.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInput; | ||
import org.springframework.security.web.webauthn.api.AuthenticationExtensionsClientInputs; | ||
import org.springframework.security.web.webauthn.api.ImmutableAuthenticationExtensionsClientInputs; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Jackson deserializer for {@link AuthenticationExtensionsClientInputs} | ||
* | ||
* @author Justin Cranford | ||
* @since 6.5 | ||
*/ | ||
@SuppressWarnings("serial") | ||
class AuthenticationExtensionsClientInputsDeserializer extends StdDeserializer<AuthenticationExtensionsClientInputs> { | ||
|
||
AuthenticationExtensionsClientInputsDeserializer() { | ||
super(AuthenticationExtensionsClientInputs.class); | ||
} | ||
|
||
@Override | ||
public AuthenticationExtensionsClientInputs deserialize(JsonParser parser, DeserializationContext ctxt) | ||
throws IOException { | ||
final AuthenticationExtensionsClientInputDeserializer authenticationExtensionsClientInputDeserializer = new AuthenticationExtensionsClientInputDeserializer(); | ||
|
||
final List<AuthenticationExtensionsClientInput> extensions = new ArrayList<>(); | ||
while (parser.nextToken() != JsonToken.END_OBJECT) { | ||
extensions.add(authenticationExtensionsClientInputDeserializer.deserialize(parser, ctxt)); | ||
} | ||
return new ImmutableAuthenticationExtensionsClientInputs(extensions); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
...ngframework/security/web/webauthn/jackson/AuthenticatorSelectionCriteriaDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Copyright 2002-2024 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.security.web.webauthn.jackson; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import org.springframework.security.web.webauthn.api.AuthenticatorAttachment; | ||
import org.springframework.security.web.webauthn.api.AuthenticatorSelectionCriteria; | ||
import org.springframework.security.web.webauthn.api.AuthenticatorSelectionCriteria.AuthenticatorSelectionCriteriaBuilder; | ||
import org.springframework.security.web.webauthn.api.ResidentKeyRequirement; | ||
import org.springframework.security.web.webauthn.api.UserVerificationRequirement; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Jackson deserializer for {@link AuthenticatorSelectionCriteria} | ||
* | ||
* @author Justin Cranford | ||
* @since 6.5 | ||
*/ | ||
@SuppressWarnings("serial") | ||
class AuthenticatorSelectionCriteriaDeserializer extends StdDeserializer<AuthenticatorSelectionCriteria> { | ||
|
||
AuthenticatorSelectionCriteriaDeserializer() { | ||
super(AuthenticatorSelectionCriteria.class); | ||
} | ||
|
||
@Override | ||
public AuthenticatorSelectionCriteria deserialize(JsonParser parser, DeserializationContext ctxt) | ||
throws IOException { | ||
final AuthenticatorSelectionCriteriaBuilder builder = AuthenticatorSelectionCriteria.builder(); | ||
while (parser.nextToken() != JsonToken.END_OBJECT) { | ||
final String fieldName = parser.currentName(); | ||
parser.nextToken(); | ||
if ("authenticatorAttachment".equals(fieldName)) { | ||
builder.authenticatorAttachment(AuthenticatorAttachment.valueOf(parser.getText())); | ||
} else if ("residentKey".equals(fieldName)) { | ||
builder.residentKey(ResidentKeyRequirement.valueOf(parser.getText())); | ||
} else if ("userVerification".equals(fieldName)) { | ||
builder.userVerification(UserVerificationRequirement.valueOf(parser.getText())); | ||
} else { | ||
throw new IOException("Unsupported field name: " + fieldName); | ||
} | ||
} | ||
return builder.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.