You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Behrang Saeedzadeh (JIRA)" <ji...@apache.org> on 2016/08/10 02:19:22 UTC

[jira] [Updated] (CXF-7004) Custom DateTime property is not serialized to JSON properly

     [ https://issues.apache.org/jira/browse/CXF-7004?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Behrang Saeedzadeh updated CXF-7004:
------------------------------------
    Description: 
The following code:

{code}
import au.com.sportsbet.pii.utils.CryptoUtils;
import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys;
import org.apache.cxf.rs.security.jose.jwk.JwkUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.interfaces.RSAPrivateKey;
import java.time.LocalDateTime;

public class TestCase {

    public static void main(String[] args) throws IOException {
        final RSAPrivateKey privateKey = CryptoUtils.loadRsaPrivateKey(Paths.get("a-private-key.der"));
        final JsonWebKey jwk = JwkUtils.fromRSAPrivateKey(privateKey, "RSA-OAEP-256");
        jwk.setKeyId("test");
        jwk.setKeyProperty("created-at", LocalDateTime.now());

        final JsonWebKeys webKeys = new JsonWebKeys(jwk);

        JwkUtils.jwkSetToJson(webKeys, new FileOutputStream("test.jwk.json"));
    }

}
{code}

Produces the following malformed JSON:

{code}
{
  "keys": [
    {
      "kty": "RSA",
      "alg": "RSA-OAEP-256",
      "n": "...",
      "d": "...",
      "p": "...",
      "q": "...",
      "dp": "...",
      "dq": "...",
      "qi": "...",
      "kid": "test",
      "created-at": 2016
      -0
      8
      -10
      T11: 0
      1: 51.036
    }
  ]
}
{code}

Basically the `LocalDateTime` is not converted to `String` before getting serialized to JSON.

  was:
The following code:

{code}
import au.com.sportsbet.pii.utils.CryptoUtils;
import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys;
import org.apache.cxf.rs.security.jose.jwk.JwkUtils;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.security.interfaces.RSAPrivateKey;
import java.time.LocalDateTime;

public class TestCase {

    public static void main(String[] args) throws IOException {
        final RSAPrivateKey privateKey = CryptoUtils.loadRsaPrivateKey(Paths.get("a-private-key.der"));
        final JsonWebKey piiJWK = JwkUtils.fromRSAPrivateKey(privateKey, "RSA-OAEP-256");
        piiJWK.setKeyId("test");
        piiJWK.setKeyProperty("created-at", LocalDateTime.now());

        final JsonWebKeys webKeys = new JsonWebKeys(piiJWK);

        JwkUtils.jwkSetToJson(webKeys, new FileOutputStream("test.jwk.json"));
    }

}
{code}

Produces the following malformed JSON:

{code}
{
  "keys": [
    {
      "kty": "RSA",
      "alg": "RSA-OAEP-256",
      "n": "...",
      "d": "...",
      "p": "...",
      "q": "...",
      "dp": "...",
      "dq": "...",
      "qi": "...",
      "kid": "test",
      "created-at": 2016
      -0
      8
      -10
      T11: 0
      1: 51.036
    }
  ]
}
{code}

Basically the `LocalDateTime` is not converted to `String` before getting serialized to JSON.


> Custom DateTime property is not serialized to JSON properly
> -----------------------------------------------------------
>
>                 Key: CXF-7004
>                 URL: https://issues.apache.org/jira/browse/CXF-7004
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS Security
>    Affects Versions: 3.1.7
>            Reporter: Behrang Saeedzadeh
>
> The following code:
> {code}
> import au.com.sportsbet.pii.utils.CryptoUtils;
> import org.apache.cxf.rs.security.jose.jwk.JsonWebKey;
> import org.apache.cxf.rs.security.jose.jwk.JsonWebKeys;
> import org.apache.cxf.rs.security.jose.jwk.JwkUtils;
> import java.io.FileOutputStream;
> import java.io.IOException;
> import java.nio.file.Paths;
> import java.security.interfaces.RSAPrivateKey;
> import java.time.LocalDateTime;
> public class TestCase {
>     public static void main(String[] args) throws IOException {
>         final RSAPrivateKey privateKey = CryptoUtils.loadRsaPrivateKey(Paths.get("a-private-key.der"));
>         final JsonWebKey jwk = JwkUtils.fromRSAPrivateKey(privateKey, "RSA-OAEP-256");
>         jwk.setKeyId("test");
>         jwk.setKeyProperty("created-at", LocalDateTime.now());
>         final JsonWebKeys webKeys = new JsonWebKeys(jwk);
>         JwkUtils.jwkSetToJson(webKeys, new FileOutputStream("test.jwk.json"));
>     }
> }
> {code}
> Produces the following malformed JSON:
> {code}
> {
>   "keys": [
>     {
>       "kty": "RSA",
>       "alg": "RSA-OAEP-256",
>       "n": "...",
>       "d": "...",
>       "p": "...",
>       "q": "...",
>       "dp": "...",
>       "dq": "...",
>       "qi": "...",
>       "kid": "test",
>       "created-at": 2016
>       -0
>       8
>       -10
>       T11: 0
>       1: 51.036
>     }
>   ]
> }
> {code}
> Basically the `LocalDateTime` is not converted to `String` before getting serialized to JSON.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)