com.fasterxml.jackson.databind.DeserializationContext

Here are the examples of the java api com.fasterxml.jackson.databind.DeserializationContext taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1169 Examples 7

19 Source : WebAuthenticationDetailsDeserializer.java
with MIT License
from ZeroOrInfinity

@SuppressWarnings("DuplicatedCode")
@Override
public WebAuthenticationDetails deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    JsonNode jsonNode = mapper.readTree(p);
    final Clreplaced<WebAuthenticationDetails> detailsClreplaced = WebAuthenticationDetails.clreplaced;
    try {
        final Clreplaced<String> stringClreplaced = String.clreplaced;
        final Constructor<WebAuthenticationDetails> privateConstructor = detailsClreplaced.getDeclaredConstructor(stringClreplaced, stringClreplaced);
        privateConstructor.setAccessible(true);
        final String remoteAddress = jsonNode.get("remoteAddress").asText(null);
        final String sessionId = jsonNode.get("sessionId").asText(null);
        return privateConstructor.newInstance(remoteAddress, sessionId);
    } catch (NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
        final String msg = String.format("WebAuthenticationDetails Jackson 反序列化错误: %s", e.getMessage());
        throw new IOException(msg, e);
    }
}

19 Source : TemporaryUserDeserializer.java
with MIT License
from ZeroOrInfinity

@SuppressWarnings("DuplicatedCode")
@Override
public TemporaryUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    JsonNode jsonNode = mapper.readTree(p);
    Set<? extends GrantedAuthority> authorities = mapper.convertValue(jsonNode.get("authorities"), new TypeReference<Set<SimpleGrantedAuthority>>() {
    });
    JsonNode preplacedword = this.readJsonNode(jsonNode, "preplacedword");
    TemporaryUser result = new TemporaryUser(this.readJsonNode(jsonNode, "username").asText(), preplacedword.asText(""), this.readJsonNode(jsonNode, "enabled").asBoolean(), this.readJsonNode(jsonNode, "accountNonExpired").asBoolean(), this.readJsonNode(jsonNode, "credentialsNonExpired").asBoolean(), this.readJsonNode(jsonNode, "accountNonLocked").asBoolean(), authorities, mapper.convertValue(jsonNode.get("authUser"), new TypeReference<AuthUser>() {
    }), jsonNode.get("encodeState").asText());
    if (preplacedword.asText(null) == null) {
        result.eraseCredentials();
    }
    return result;
}

19 Source : AuthUserJsonDeserializer.java
with MIT License
from ZeroOrInfinity

@Override
public AuthUser deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    final JsonNode jsonNode = mapper.readTree(p);
    final String uuid = jsonNode.get("uuid").asText();
    final String username = jsonNode.get("username").asText();
    final String nickname = jsonNode.get("nickname").asText(null);
    final String avatar = jsonNode.get("avatar").asText(null);
    final String blog = jsonNode.get("blog").asText(null);
    final String company = jsonNode.get("company").asText(null);
    final String location = jsonNode.get("location").asText(null);
    final String email = jsonNode.get("email").asText(null);
    final String remark = jsonNode.get("remark").asText(null);
    final AuthUserGender gender = mapper.convertValue(jsonNode.get("gender"), new TypeReference<AuthUserGender>() {
    });
    final String source = jsonNode.get("source").asText(null);
    final AuthToken token = mapper.convertValue(jsonNode.get("token"), new TypeReference<AuthToken>() {
    });
    final JsonNode rawUserInfoNode = jsonNode.get("rawUserInfo");
    final String rawUserInfoString = mapper.writeValuereplacedtring(rawUserInfoNode);
    final JSONObject rawUserInfo = (JSONObject) JSONObject.parse(rawUserInfoString);
    rawUserInfo.remove("@clreplaced");
    return AuthUser.builder().uuid(uuid).username(username).nickname(nickname).avatar(avatar).blog(blog).company(company).location(location).email(email).remark(remark).gender(gender).source(source).token(token).rawUserInfo(rawUserInfo).build();
}

19 Source : DefaultOAuth2AuthenticatedPrincipalDeserializer.java
with MIT License
from ZeroOrInfinity

@Override
public DefaultOAuth2AuthenticatedPrincipal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    final JsonNode jsonNode = mapper.readTree(p);
    // 获取 authorities
    JsonNode authoritiesNode = jsonNode.get("authorities");
    Collection<GrantedAuthority> authorities;
    try {
        Collection<? extends GrantedAuthority> tempAuthorities = mapper.convertValue(jsonNode.get("authorities"), new TypeReference<Collection<SimpleGrantedAuthority>>() {
        });
        // noinspection unchecked
        authorities = (Collection<GrantedAuthority>) tempAuthorities;
    } catch (Exception e) {
        String authoritiesString = authoritiesNode.toString();
        String prefix = "[\"java.util.Collections$UnmodifiableCollection\",";
        if (authoritiesString.startsWith(prefix)) {
            authoritiesString = authoritiesString.substring(prefix.length());
            int cutLen = 2;
            // noinspection AlibabaUndefineMagicConstant
            if (authoritiesString.length() == 3) {
                cutLen = 1;
            }
            authoritiesString = authoritiesString.substring(0, authoritiesString.length() - cutLen);
        }
        String prefix2 = "\\[\"org\\.springframework\\.security\\.core\\.authority\\.SimpleGrantedAuthority\",";
        authoritiesString = authoritiesString.replaceAll(prefix2, "");
        authoritiesString = authoritiesString.replaceAll("],", ",");
        // noinspection unchecked
        List<LinkedHashMap<String, String>> list = JsonUtil.json2Object(authoritiesString, ArrayList.clreplaced);
        authorities = new ArrayList<>();
        if (nonNull(list)) {
            for (LinkedHashMap<String, String> map : list) {
                authorities.add(new SimpleGrantedAuthority(map.get("authority")));
            }
        }
    }
    final JsonNode attributesNode = jsonNode.get("attributes");
    final String name = jsonNode.get("name").asText(null);
    // 创建 authorities map
    Map<String, Object> attributes = mapper.readValue(attributesNode.toString(), new TypeReference<Map<String, Object>>() {
    });
    DefaultOAuth2AuthenticatedPrincipal principal;
    if (nonNull(name)) {
        principal = new DefaultOAuth2AuthenticatedPrincipal(name, attributes, authorities);
    } else {
        principal = new DefaultOAuth2AuthenticatedPrincipal(attributes, authorities);
    }
    return principal;
}

19 Source : BearerTokenAuthenticationTokenDeserializer.java
with MIT License
from ZeroOrInfinity

@Override
public BearerTokenAuthenticationToken deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    final JsonNode jsonNode = mapper.readTree(p);
    final String token = jsonNode.get("token").asText(null);
    // 创建 jwt 对象
    BearerTokenAuthenticationToken bearerToken = new BearerTokenAuthenticationToken(token);
    // 为了安全, 不信任反序列化后的凭证; 一般认证成功后都会自动释放密码.
    bearerToken.eraseCredentials();
    return bearerToken;
}

19 Source : UserDeserializer.java
with MIT License
from ZeroOrInfinity

/**
 * This method will create {@link User} object. It will ensure successful object creation even if preplacedword key is null in
 * serialized json, because credentials may be removed from the {@link User} by invoking {@link User#eraseCredentials()}.
 * In that case there won't be any preplacedword key in serialized json.
 *
 * @param jp the JsonParser
 * @param ctxt the DeserializationContext
 * @return the user
 * @throws IOException if a exception during IO occurs
 * @throws JsonProcessingException if an error during JSON processing occurs
 */
@SuppressWarnings("DuplicatedCode")
@Override
public User deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectMapper mapper = (ObjectMapper) jp.getCodec();
    JsonNode jsonNode = mapper.readTree(jp);
    Set<? extends GrantedAuthority> authorities = mapper.convertValue(jsonNode.get("authorities"), new TypeReference<Set<SimpleGrantedAuthority>>() {
    });
    JsonNode preplacedword = this.readJsonNode(jsonNode, "preplacedword");
    User result = new User(this.readJsonNode(jsonNode, "username").asText(), preplacedword.asText(""), this.readJsonNode(jsonNode, "enabled").asBoolean(), this.readJsonNode(jsonNode, "accountNonExpired").asBoolean(), this.readJsonNode(jsonNode, "credentialsNonExpired").asBoolean(), this.readJsonNode(jsonNode, "accountNonLocked").asBoolean(), authorities);
    if (preplacedword.asText(null) == null) {
        result.eraseCredentials();
    }
    return result;
}

19 Source : ToJsonDeserializer.java
with Apache License 2.0
from zebrunner

@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    JsonNode node = mapper.readTree(p);
    return mapper.writeValuereplacedtring(node);
}

19 Source : LocalDateTimeDeserializer.java
with MIT License
from YunaiV

@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    return LocalDateTime.ofInstant(Instant.ofEpochMilli(p.getValueAsLong()), ZoneId.systemDefault());
}

19 Source : JsonObjectDeserializer.java
with Apache License 2.0
from yuanmabiji

@Override
public final T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    try {
        ObjectCodec codec = jp.getCodec();
        JsonNode tree = codec.readTree(jp);
        return deserializeObject(jp, ctxt, codec, tree);
    } catch (Exception ex) {
        if (ex instanceof IOException) {
            throw (IOException) ex;
        }
        throw new JsonMappingException(jp, "Object deserialize error", ex);
    }
}

19 Source : LngLatAltDeserializer.java
with Apache License 2.0
from YANG-DB

private double extractDouble(JsonParser jp, DeserializationContext ctxt, boolean optional) throws JsonParseException, IOException {
    JsonToken token = jp.nextToken();
    if (token == null) {
        if (optional)
            return Double.NaN;
        else
            throw ctxt.mappingException("Unexpected end-of-input when binding data into LngLatAlt");
    } else {
        switch(token) {
            case END_ARRAY:
                if (optional)
                    return Double.NaN;
                else
                    throw ctxt.mappingException("Unexpected end-of-input when binding data into LngLatAlt");
            case VALUE_NUMBER_FLOAT:
                return jp.getDoubleValue();
            case VALUE_NUMBER_INT:
                return jp.getLongValue();
            default:
                throw ctxt.mappingException("Unexpected token (" + token.name() + ") when binding data into LngLatAlt ");
        }
    }
}

19 Source : LngLatAltDeserializer.java
with Apache License 2.0
from YANG-DB

@Override
public LngLatAlt deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    if (jp.isExpectedStartArrayToken()) {
        return deserializeArray(jp, ctxt);
    }
    throw ctxt.mappingException(LngLatAlt.clreplaced);
}

19 Source : CreateCursorRequestDeserializer.java
with Apache License 2.0
from YANG-DB

// endregion
// region StdDeserializer Imlementation
@Override
public CreateCursorRequest deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    String cursorType = node.get("cursorType").asText();
    Clreplaced<? extends CreateCursorRequest> cursorClreplaced = this.cursorClreplacedes.get(cursorType);
    if (cursorClreplaced == null) {
        throw new Exception(String.format("Unregistered cursorType: %s", cursorType));
    }
    return this.mapper.readValue(this.mapper.writeValuereplacedtring(node), cursorClreplaced);
}

19 Source : FilterDeserializer.java
with Apache License 2.0
from yahoo

/**
 * Deserialize JSON string to JSON objects.
 */
@Override
public Filter deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectMapper codec = (ObjectMapper) p.getCodec();
    JsonNode node = codec.readTree(p);
    if (node.has(CONDITION_FIELD_NAME)) {
        return (Filter) codec.treeToValue(node, LogicalRule.clreplaced);
    } else {
        return (Filter) codec.treeToValue(node, RelationalRule.clreplaced);
    }
}

19 Source : XrpCurrencyAmountDeserializer.java
with ISC License
from XRPLF

@Override
public XrpCurrencyAmount deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
    return XrpCurrencyAmount.ofDrops(jsonParser.getValueAsLong());
}

19 Source : TransactionDeserializer.java
with ISC License
from XRPLF

@Override
public Transaction deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
    ObjectMapper objectMapper = (ObjectMapper) jsonParser.getCodec();
    ObjectNode objectNode = objectMapper.readTree(jsonParser);
    TransactionType transactionType = TransactionType.forValue(objectNode.get("TransactionType").asText());
    return objectMapper.treeToValue(objectNode, Transaction.typeMap.inverse().get(transactionType));
}

19 Source : MarkerDeserializer.java
with ISC License
from XRPLF

@Override
public Marker deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
    ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
    JsonNode node = mapper.readTree(jsonParser);
    if (node instanceof TextNode) {
        return Marker.of(node.asText());
    }
    return Marker.of(mapper.writeValuereplacedtring(node));
}

19 Source : LedgerIndexDeserializer.java
with ISC License
from XRPLF

@Override
public LedgerIndex deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
    return LedgerIndex.of(jsonParser.getValuereplacedtring());
}

19 Source : SpelDeserializer.java
with Apache License 2.0
from xm-online

@Override
public Expression deserialize(JsonParser jp, DeserializationContext context) throws IOException {
    String expressionString = jp.getCodec().readValue(jp, String.clreplaced);
    return parser.parseExpression(expressionString);
}

19 Source : JpaEntityDeserializer.java
with Apache License 2.0
from xiangxik

@Override
public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    I identifier = p.readValueAs(enreplacedyInformation.getIdType());
    return identifier == null ? null : enreplacedyManager.getReference(enreplacedyInformation.getJavaType(), identifier);
}

19 Source : UserDeserializer.java
with MIT License
from wuyouzhuguli

@Override
public User deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException {
    JsonNode node = parser.getCodec().readTree(parser);
    String userName = node.get("user-name").asText();
    User user = new User();
    user.setUserName(userName);
    return user;
}

19 Source : ParseDeserializer.java
with Apache License 2.0
from wuyichen24

@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    // or overloaded with an appropriate format
    return LocalDateTime.parse(p.getValuereplacedtring());
}

19 Source : MissionInstructionDeserializer.java
with MIT License
from woowacourse-teams

@Override
public MissionInstruction deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
    return new MissionInstruction(p.getText());
}

19 Source : KakaoUserResponseDeserializer.java
with MIT License
from woowacourse-teams

@Override
public KakaoUserResponse deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    final JsonNode jsonNode = p.getCodec().readTree(p);
    final JsonNode properties = jsonNode.get("properties");
    final JsonNode kakaoAccount = jsonNode.get("kakao_account");
    final JsonNode isEmailValid = Objects.nonNull(kakaoAccount.get("is_email_valid")) ? kakaoAccount.get("is_email_valid") : kakaoAccount.get("email_valid");
    final JsonNode isEmailVerified = Objects.nonNull(kakaoAccount.get("is_email_verified")) ? kakaoAccount.get("is_email_valid") : kakaoAccount.get("email_verified");
    final String profileImage = Objects.nonNull(properties.get("profile_image")) ? properties.get("profile_image").textValue() : null;
    final String thumbnailImage = Objects.nonNull(properties.get("thumbnail_image")) ? properties.get("thumbnail_image").textValue() : null;
    // TODO: 2020/08/12 Test에서 Serialize를 쓰는데, 그 과정에서 Getter 이름과 필드명 충돌로 인해 임시로 추가해놓음.
    return createKakaoUserResponse(jsonNode, properties, kakaoAccount, isEmailValid, isEmailVerified, profileImage, thumbnailImage);
}

19 Source : ImageUrlDeserializer.java
with MIT License
from woowacourse-teams

@Override
public ImageUrl deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException, JsonProcessingException {
    return new ImageUrl(p.getText());
}

19 Source : CashDeserializer.java
with MIT License
from woowacourse-teams

@Override
public Cash deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    return new Cash(new BigDecimal(p.getText()));
}

19 Source : HackyLocalDateTimeDeserializer.java
with Apache License 2.0
from WojciechZankowski

@Override
public LocalDateTime deserialize(final JsonParser parser, final DeserializationContext context) throws IOException {
    final String val = parser.getValuereplacedtring();
    // #HACK In Daily List they return "0" if data is not available
    if (val == null || val.equals("0")) {
        return null;
    }
    return super.deserialize(parser, context);
}

19 Source : HackyBigDecimalDeserializer.java
with Apache License 2.0
from WojciechZankowski

@Override
public BigDecimal deserialize(final JsonParser parser, final DeserializationContext ctx) throws IOException {
    final String val = parser.getValuereplacedtring();
    // #HACK Sometimes instead of a null they return N/A in number field
    // #HACK In Daily List they return empty String if number is N/A
    // #HACK In Key Stats they return NaN for revenuePerEmployee
    if (val == null || "N/A".equalsIgnoreCase(val) || "NaN".equalsIgnoreCase(val) || val.isEmpty()) {
        return null;
    }
    try {
        return parser.getDecimalValue();
    } catch (IOException e) {
        // #HACK In Daily List they return numbers as a String
        return new BigDecimal(val);
    }
}

19 Source : AbstractEnumDeserializer.java
with Apache License 2.0
from WojciechZankowski

@Override
public T deserialize(final JsonParser parser, final DeserializationContext ctxt) throws IOException {
    final String value = parser.getValuereplacedtring();
    if (value == null) {
        return UNKNOWN;
    }
    final T enumInstance = MAPPER.get(value);
    if (enumInstance == null) {
        return UNKNOWN;
    }
    return enumInstance;
}

19 Source : ZonedDateTimeFromISOOffsetDateTimeDeserializer.java
with MIT License
from willianantunes

@Override
public ZonedDateTime deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException, JsonProcessingException {
    return ZonedDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(jsonParser.readValueAs(String.clreplaced)));
}

19 Source : ColorDeserializer.java
with MIT License
from wildmountainfarms

@Override
public Color deserialize(JsonParser p, DeserializationContext context) throws IOException {
    String string = p.getValuereplacedtring();
    String valueString = string.substring(5);
    valueString = valueString.substring(0, valueString.length() - 1);
    String[] split = valueString.split(", ");
    int r = Integer.parseInt(split[0]);
    int g = Integer.parseInt(split[1]);
    int b = Integer.parseInt(split[2]);
    int a = Integer.parseInt(split[3]);
    return new Color(r, g, b, a);
}

19 Source : CustomDateDeserializer.java
with MIT License
from wildbit

@Override
public Date deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException {
    JsonNode node = jsonParser.getCodec().readTree(jsonParser);
    final String date = node.textValue();
    for (String DATE_FORMAT : DATE_FORMATS) {
        try {
            return new SimpleDateFormat(DATE_FORMAT).parse(date);
        } catch (ParseException e) {
        }
    }
    throw new JsonParseException(jsonParser, getParsingErrorMessage(date));
}

19 Source : ErrorReportingSettableBeanProperty.java
with GNU Lesser General Public License v3.0
from WenlinMao

@Override
public void deserializeAndSet(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException {
    try {
        delegate.deserializeAndSet(p, ctxt, instance);
    } catch (Exception e) {
        if (jsonErrorConsumer != null) {
            jsonErrorConsumer.accept(new JsonError(e.getMessage(), p.getParsingContext(), e));
        }
    }
}

19 Source : ErrorReportingSettableBeanProperty.java
with GNU Lesser General Public License v3.0
from WenlinMao

@Override
public Object deserializeSetAndReturn(JsonParser p, DeserializationContext ctxt, Object instance) throws IOException {
    return delegate.deserializeSetAndReturn(p, ctxt, instance);
}

19 Source : MoneyDeserializer.java
with MIT License
from weltraumpirat

@Override
public Money deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    JsonNode node = p.getCodec().readTree(p);
    final String text = node.asText();
    return MoneyMapper.toMoney(text);
}

19 Source : AmountDeserializer.java
with MIT License
from weltraumpirat

@Override
public Amount deserialize(final JsonParser p, final DeserializationContext ctxt) throws IOException {
    JsonNode node = p.getCodec().readTree(p);
    final String amount = node.asText();
    return toAmount(amount);
}

19 Source : ByteArrayDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
public byte[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    return Base64UrlUtil.decode(p.getValuereplacedtring());
}

19 Source : AuthenticatorObjectFormDeserializer.java
with Apache License 2.0
from webauthn4j

/**
 * {@inheritDoc}
 */
@Override
public AttestationObjectForm deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    String value = p.getValuereplacedtring();
    AttestationObjectForm result = new AttestationObjectForm();
    result.setAttestationObject(base64UrlStringToAttestationObjectConverter.convert(value));
    result.setAttestationObjectBase64(value);
    return result;
}

19 Source : TransactionConfirmationDisplaysDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
public TransactionConfirmationDisplays deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    return new TransactionConfirmationDisplays(p.getIntValue());
}

19 Source : MatcherProtectionsDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
public MatcherProtections deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    return new MatcherProtections(p.getIntValue());
}

19 Source : KeyProtectionsDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
public KeyProtections deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    return new KeyProtections(p.getIntValue());
}

19 Source : AttachmentHintsDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
public AttachmentHints deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    return new AttachmentHints(p.getLongValue());
}

19 Source : X509CertificateDeserializer.java
with Apache License 2.0
from webauthn4j

/**
 * {@inheritDoc}
 */
@Override
@Nullable
public X509Certificate deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    byte[] value = p.getBinaryValue();
    if (value.length == 0) {
        return null;
    }
    return CertificateUtil.generateX509Certificate(value);
}

19 Source : TPMTPublicDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
@NonNull
public TPMTPublic deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    byte[] value = p.getBinaryValue();
    try {
        return deserialize(value);
    } catch (IllegalArgumentException e) {
        throw new InvalidFormatException(p, "input byte array contains surplus data", value, TPMTPublic.clreplaced);
    }
}

19 Source : TPMSAttestDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
@NonNull
public TPMSAttest deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    byte[] value = p.getBinaryValue();
    ByteBuffer buffer = ByteBuffer.wrap(value);
    byte[] magicBytes = new byte[4];
    buffer.get(magicBytes);
    TPMGenerated magic = TPMGenerated.create(magicBytes);
    byte[] typeBytes = new byte[2];
    buffer.get(typeBytes);
    TPMISTAttest type = TPMISTAttest.create(typeBytes);
    int qualifiedSignerSize = UnsignedNumberUtil.getUnsignedShort(buffer);
    byte[] qualifiedSigner = new byte[qualifiedSignerSize];
    buffer.get(qualifiedSigner);
    int extraDataSize = UnsignedNumberUtil.getUnsignedShort(buffer);
    byte[] extraData = new byte[extraDataSize];
    buffer.get(extraData);
    TPMSClockInfo clock = extractClockInfo(buffer);
    BigInteger firmwareVersion = UnsignedNumberUtil.getUnsignedLong(buffer);
    TPMUAttest attested = extractTPMUAttest(type, buffer);
    if (buffer.remaining() > 0) {
        throw new InvalidFormatException(p, "input byte array contains surplus data", value, TPMTPublic.clreplaced);
    }
    return new TPMSAttest(magic, type, qualifiedSigner, extraData, clock, firmwareVersion, attested);
}

19 Source : ChallengeDeserializer.java
with Apache License 2.0
from webauthn4j

/**
 * {@inheritDoc}
 */
@Override
@NonNull
public Challenge deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    String str = p.getValuereplacedtring();
    try {
        return new DefaultChallenge(str);
    } catch (IllegalArgumentException e) {
        throw new InvalidFormatException(null, "value is out of range", str, DefaultChallenge.clreplaced);
    }
}

19 Source : AuthenticatorDataDeserializer.java
with Apache License 2.0
from webauthn4j

/**
 * {@inheritDoc}
 */
@Override
@NonNull
public AuthenticatorData<? extends ExtensionAuthenticatorOutput> deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    byte[] value = p.getBinaryValue();
    return new AuthenticatorDataConverter(objectConverter).convert(value);
}

19 Source : AuthenticationExtensionsAuthenticatorOutputsEnvelopeDeserializer.java
with Apache License 2.0
from webauthn4j

/**
 * {@inheritDoc}
 */
@Override
@NonNull
public AuthenticationExtensionsAuthenticatorOutputsEnvelope<? extends ExtensionAuthenticatorOutput> deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    JavaType javaType = SimpleType.constructUnsafe(AuthenticationExtensionsAuthenticatorOutputs.clreplaced);
    AuthenticationExtensionsAuthenticatorOutputs<? extends ExtensionAuthenticatorOutput> authenticationExtensionsAuthenticatorOutputs = ctxt.readValue(p, javaType);
    int length = (int) p.getCurrentLocation().getByteOffset();
    return new AuthenticationExtensionsAuthenticatorOutputsEnvelope<>(authenticationExtensionsAuthenticatorOutputs, length);
}

19 Source : AAGUIDDeserializer.java
with Apache License 2.0
from webauthn4j

@Override
@NonNull
public AAGUID deserialize(@NonNull JsonParser p, @NonNull DeserializationContext ctxt) throws IOException {
    return new AAGUID(p.getBinaryValue());
}

19 Source : RawResponseDeserializer.java
with Apache License 2.0
from web3j

@Override
public Response deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    Response deserializedResponse = (Response) defaultDeserializer.deserialize(jp, ctxt);
    deserializedResponse.setRawResponse(getRawResponse(jp));
    return deserializedResponse;
}

19 Source : RawResponseDeserializer.java
with Apache License 2.0
from web3j

// Must implement ResolvableDeserializer when modifying BeanDeserializer
// otherwise deserializing throws JsonMappingException
@Override
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
    ((ResolvableDeserializer) defaultDeserializer).resolve(ctxt);
}

See More Examples