pingidentity / scim2

The UnboundID SCIM 2.0 SDK for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Certificates are not displayed in Base64

beldahanit opened this issue · comments

I have implemented a RESTful API using Unboundid SCIM server classes. At one path it returns a user data including certificates. I am using this class to return the certificates
com.unboundid.scim2.common.types.X509Certificate
this is set on the
com.unboundid.scim2.common.types.UserResource by resource.setX509Certificates(certLst);

When I test it I get in an output in JSON:
@produces({MEDIA_TYPE_SCIM, MediaType.APPLICATION_JSON})

data like this

"x509Certificates": [
{
"value": [
48,
-126,
6,
-104,
48,
-126,
4,
-128,

However, I would expect according to the RCF: https://tools.ietf.org/html/rfc7643
that this will be displayed in Base64?

Or do I do anything wrong?

Thanks.

Hi @beldahanit,

I've tried to reproduce this, but I wasn't successful. I suspect this is caused by an incorrect ObjectMapper configuration when the user resource is serialized into a string by Jackson. An example of using the SCIM SDK's ObjectMapper:

var user = new UserResource()
    .setUserName("Babs Jensen")
    .setX509Certificates(
        new X509Certificate().setValue("certificate".getBytes()),
        new X509Certificate().setValue("cert".getBytes()),
        new X509Certificate().setValue("c".getBytes()));
System.out.println(user);

// Equivalent to the previous print statement, but this explicitly uses the SCIM
// SDK's ObjectMapper.
System.out.println(JsonUtils.valueToNode(user).toPrettyString());

Both print statements result in the same base64-encoded values:

{
  "schemas" : [ "urn:ietf:params:scim:schemas:core:2.0:User" ],
  "userName" : "Babs Jensen",
  "x509Certificates" : [ {
    "value" : "Y2VydGlmaWNhdGU="
  }, {
    "value" : "Y2VydA=="
  }, {
    "value" : "Yw=="
  } ]
}

I would verify that you're using an object mapper from the SCIM SDK's JsonUtils.createObjectMapper() method. If you are still able to reproduce this on the latest version of the SCIM SDK, please open a new issue.