cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl von Randow (JIRA)" <>
Subject [jira] [Commented] (CXF-6573) AccessToken doesn't serialize with snake-case
Date Wed, 02 Sep 2015 22:07:45 GMT


Karl von Randow commented on CXF-6573:

Ah right. Maybe it's possible to have the {{OAuthJSONProvider}} registered as a provider and
used in preference to the other JSON providers, as it only serialises the classes it recognises...
I haven't tried that, as I'm not sure how the ordering will work. Perhaps the intention is
to have it in its own JAX-RS Application?

Yes, it is possible to use annotations to get the Jackson serialisation to match {{OAuthJSONProvider}}.
I am using a Jackson mix-in to achieve this at the moment (so please excuse the abstract modifiers,
they're a feature of doing this as a Jackson ObjectMapper mixin):

@JsonInclude(value = Include.NON_NULL)
public abstract class AccessTokenMixin extends AccessToken {

    abstract public String getTokenType();

    abstract public String getTokenKey();

    abstract public String getRefreshToken();

    abstract public Map<String, String> getParameters();

    @JsonInclude(value = Include.NON_DEFAULT)
    abstract public long getExpiresIn();

    abstract public long getIssuedAt();


These annotations could go into {{AccessToken}}. Also we should add the following method to
support deserialisation:

    public void add(String key, String value) {
        getParameters().put(key, value);

This omits {{expires_in}} when its the default value (-1), so no need to change anything there.
I've annotated {{getIssuedAt}} with {{@JsonIgnore}} so it doesn't get included.

Similarly for {{ClientAccessToken}}:

public abstract class ClientAccessTokenMixin extends ClientAccessToken {

    abstract public String getApprovedScope();


Similar things could be done for {{OAuthError}}.

If this looks good to you, I'm happy to create a pull request with this and add it to this

> AccessToken doesn't serialize with snake-case
> ---------------------------------------------
>                 Key: CXF-6573
>                 URL:
>             Project: CXF
>          Issue Type: Wish
>          Components: JAX-RS Security
>    Affects Versions: 3.1.2
>            Reporter: Karl von Randow
>            Priority: Minor
> The class doesn't declare and JAXB
(or other) annotations to influence how it is serialized. So it uses the default serialization
style of the JAXB context.
> In my case this is camel case.
> This means that the AccessToken response from the AccessTokenService uses camel case.
The OAuth docs _appear_ (I'm not a scholar of them) to indicate that it should be snake case.
> Is that true? Is this a thing? Would it be something you'd consider, adding `@XmlElement(name
= "token_key")` annotations? That would be a breaking change for existing users...

This message was sent by Atlassian JIRA

View raw message