-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
90f371d
commit 6f0c926
Showing
63 changed files
with
492 additions
and
141 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ | |
import java.util.Base64; | ||
|
||
/** | ||
* JSON deserializer for the attestation object. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
*/ | ||
@Component | ||
|
@@ -43,14 +45,28 @@ public class AttestationObjectDeserializer extends StdDeserializer<AttestationOb | |
|
||
private final CBORMapper cborMapper = new CBORMapper(); | ||
|
||
/** | ||
* No-arg deserializer constructor. | ||
*/ | ||
public AttestationObjectDeserializer() { | ||
this(null); | ||
} | ||
|
||
/** | ||
* Deserializer constructor with value class parameter. | ||
* @param vc Value class. | ||
*/ | ||
public AttestationObjectDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
/** | ||
* Deserialize the FIDO2 attestation object from JSON request. | ||
* @param jsonParser JSON parser. | ||
* @param deserializationContext Deserialization context. | ||
* @return Deserialized FIDO2 attestation object. | ||
* @throws Fido2DeserializationException Thrown in case JSON deserialization fails. | ||
*/ | ||
@Override | ||
public AttestationObject deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws Fido2DeserializationException { | ||
try { | ||
|
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 |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer; | ||
import com.wultra.powerauth.fido2.errorhandling.Fido2DeserializationException; | ||
import com.wultra.powerauth.fido2.rest.model.entity.AttestationStatement; | ||
import com.wultra.powerauth.fido2.rest.model.enumeration.SignatureAlgorithm; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
@@ -32,6 +33,8 @@ | |
import java.util.Map; | ||
|
||
/** | ||
* JSON deserializer for the attestation statement. | ||
* | ||
* @author Petr Dvorak, [email protected] | ||
*/ | ||
@Component | ||
|
@@ -41,25 +44,44 @@ public class AttestationStatementDeserializer extends StdDeserializer<Attestatio | |
@Serial | ||
private static final long serialVersionUID = -3598363993363470844L; | ||
|
||
/** | ||
* No-arg deserializer constructor. | ||
*/ | ||
public AttestationStatementDeserializer() { | ||
this(null); | ||
} | ||
|
||
/** | ||
* Deserializer constructor with value class parameter. | ||
* @param vc Value class. | ||
*/ | ||
public AttestationStatementDeserializer(Class<AttestationStatement> vc) { | ||
super(vc); | ||
} | ||
|
||
/** | ||
* Deserialize the FIDO2 attestation object from JSON request. | ||
* @param jsonParser JSON parser. | ||
* @param deserializationContext Deserialization context. | ||
* @return Deserialized FIDO2 attestation statement. | ||
* @throws Fido2DeserializationException Thrown in case JSON deserialization fails. | ||
*/ | ||
@Override | ||
public AttestationStatement deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { | ||
final Map<String, Object> map = jsonParser.readValueAs(new TypeReference<>() {}); | ||
final AttestationStatement result = new AttestationStatement(); | ||
final Integer alg = (Integer) map.get("alg"); | ||
if (alg != null && -7 == alg) { | ||
result.setAlgorithm(SignatureAlgorithm.ES256); | ||
} else { | ||
result.setAlgorithm(SignatureAlgorithm.UNKNOWN); | ||
public AttestationStatement deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws Fido2DeserializationException { | ||
try { | ||
final Map<String, Object> map = jsonParser.readValueAs(new TypeReference<>() {}); | ||
final AttestationStatement result = new AttestationStatement(); | ||
final Integer alg = (Integer) map.get("alg"); | ||
if (alg != null && -7 == alg) { | ||
result.setAlgorithm(SignatureAlgorithm.ES256); | ||
} else { | ||
result.setAlgorithm(SignatureAlgorithm.UNKNOWN); | ||
} | ||
result.setSignature((byte[]) map.get("sig")); | ||
return result; | ||
} catch (IOException e) { | ||
logger.debug(e.getMessage(), e); | ||
throw new Fido2DeserializationException(e.getMessage(), e); | ||
} | ||
result.setSignature((byte[]) map.get("sig")); | ||
return result; | ||
} | ||
} |
Oops, something went wrong.