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

Christian updated OLTU-126:
---------------------------

    Description: 
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:]

  was:
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 com.attress.contacts.oauth2.TokenEndpoint.authorize(TokenEndpoint.java:60) 
[contacts-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:]


> 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)

Reply via email to