oltu-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OLTU-126) No enum constant GrantType.password
Date Tue, 29 Oct 2013 11:28:32 GMT

    [ https://issues.apache.org/jira/browse/OLTU-126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13807881#comment-13807881
] 

Christian commented on OLTU-126:
--------------------------------

Possible solution: Override GrantType's valueOf method.

{code:title=GrantType.java}
    public static GrantType valueOf(String name) {
        if (name == null)
            throw new NullPointerException("Name is null");
        for (GrantType value : GrantType.values()) {
            if (value.toString().equals(name)) {
                return value;
            }
        }
        throw new IllegalArgumentException(
                "No enum constant " + GrantType.class.getCanonicalName() + "." + name);
    }
{code}

> No enum constant GrantType.password
> -----------------------------------
>
>                 Key: OLTU-126
>                 URL: https://issues.apache.org/jira/browse/OLTU-126
>             Project: Apache Oltu
>          Issue Type: Bug
>          Components: oauth2-authzserver, oauth2-client, oauth2-common
>    Affects Versions: 0.31
>         Environment: JBoss 7.1.1
>            Reporter: Christian
>            Priority: Critical
>
> There seems a problem with de-/serialization of GrantTypes. When using the Oltu client
for own services, the GrantType is serialized by the toString()-method, which returns lower
case identifiers.
>         OAuthClientRequest request = OAuthClientRequest
>                 .tokenLocation("http://localhost:8080" + CONTEXT_PATH + "/oauth2/token")
>                 .setClientId("test")
>                 .setGrantType(GrantType.PASSWORD)
>                 .setUsername(email)
>                 .setPassword(password)
>                 .buildBodyMessage();
>         OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
>         OAuthJSONAccessTokenResponse oauthResponse = oAuthClient.accessToken(request);
> While on the server OAuthUnauthenticatedTokenRequest's constructor will call GrantType.valueOf(String),
which only accepts upper case identifiers.
> That results in an exception:
> java.lang.IllegalArgumentException: No enum constant org.apache.oltu.oauth2.common.message.types.GrantType.password
>  at java.lang.Enum.valueOf(Enum.java:236) [rt.jar:1.7.0_45]
>  at org.apache.oltu.oauth2.common.message.types.GrantType.valueOf(GrantType.java:29)
[org.apache.oltu.oauth2.common-0.31.jar:0.31
>  at org.example.oauth2.TokenEndpoint.authorize(TokenEndpoint.java:60) [example-services-1.0.0-SNAPSHOT.jar:]
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_45]
>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) [rt.jar:1.7.0_45]
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[rt.jar:1.7.0_45]
>  at java.lang.reflect.Method.invoke(Method.java:606) [rt.jar:1.7.0_45]
>  at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:155) [resteasy-jaxrs-2.3.2.Final.jar:]
>  at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:257) [resteasy-jaxrs-2.3.2.Final.jar:]
>  at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:222) [resteasy-jaxrs-2.3.2.Final.jar:]
>  at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:211) [resteasy-jaxrs-2.3.2.Final.jar:]



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message