Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Not A Problem
-
oauth2-0.31
-
None
-
None
-
JBoss 7.1.1
Description
There seems a problem with de-/serialization of GrantType}}s. 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:]