Hi,
I am using Resteasy 3.0-beta5 Skeleton Key in my project. I have setup the
whole thing...SSL certs, skeleton key config and so on. I am using
the OAuthManagedResourceValve to secure a jax-rs API. After authentication
from the sso server, I get the following exception.
00:07:15,581 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874:
WildFly 8.0.0.Alpha1 "WildFly" started in 29220ms - Started 1153 of 1247
services (228 services are lazy, passive or on-demand)
00:07:25,144 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) --- invoke: /login.jsp
00:07:32,068 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) --- invoke: /j_security_check
00:07:32,069 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) <--- Begin oauthAuthenticate
00:07:32,140 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) authenticate userSessionManage.login(): foobar
00:07:32,259 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) --- sign access code
00:07:32,289 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) --- build redirect
00:07:32,290 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-1) <--- end oauthAuthenticate
00:07:33,183 INFO
[org.jboss.resteasy.skeleton.key.as7.OAuthAuthenticationServerValve]
(ajp-/192.168.1.101:8009-2) --- invoke: /j_oauth_resolve_access_code
00:07:33,390 INFO [org.jboss.resteasy.skeleton.key.as7.ServletOAuthLogin]
(ajp-/192.168.1.101:8009-1) media type: application/json
00:07:33,390 INFO [org.jboss.resteasy.skeleton.key.as7.ServletOAuthLogin]
(ajp-/192.168.1.101:8009-1) Content-Type header: application/json
00:07:34,810 ERROR [org.apache.catalina.connector] (ajp-/192.168.1.101:8009-1)
JBWEB001018: An exception or error occurred in the container during the
request processing: org.jboss.resteasy.spi.ReaderException:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "access_token" (class
org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse), not
marked as ignorable (4 known properties: , "token", "expiresIn",
"tokenType", "refreshToken"])
at [Source:
org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream@934ef4;
line: 1, column: 18] (through reference chain:
org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse["access_token"])
at
org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:227)
[resteasy-client-3.0-beta-5.jar:]
at
org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:135)
[resteasy-client-3.0-beta-5.jar:]
at
org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:193)
[resteasy-jaxrs-3.0-beta-5.jar:]
at
org.jboss.resteasy.skeleton.key.as7.ServletOAuthLogin.resolveCode(ServletOAuthLogin.java:283)
[skeleton-key-as7-3.0-beta-5.jar:]
at
org.jboss.resteasy.skeleton.key.as7.OAuthManagedResourceValve.oauth(OAuthManagedResourceValve.java:272)
[skeleton-key-as7-3.0-beta-5.jar:]
at
org.jboss.resteasy.skeleton.key.as7.OAuthManagedResourceValve.authenticate(OAuthManagedResourceValve.java:174)
[skeleton-key-as7-3.0-beta-5.jar:]
at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:447)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.jboss.resteasy.skeleton.key.as7.OAuthManagedResourceValve.invoke(OAuthManagedResourceValve.java:137)
[skeleton-key-as7-3.0-beta-5.jar:]
at
org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
[wildfly-web-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:559)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:473)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at
org.apache.coyote.ajp.AjpAprProtocol$AjpConnectionHandler.process(AjpAprProtocol.java:454)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2036)
[jbossweb-8.0.0.Alpha1.jar:8.0.0.Alpha1]
at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_01]
Caused by:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
Unrecognized field "access_token" (class
org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse), not
marked as ignorable (4 known properties: , "token", "expiresIn",
"tokenType", "refreshToken"])
at [Source:
org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream@934ef4;
line: 1, column: 18] (through reference chain:
org.jboss.resteasy.skeleton.key.representations.AccessTokenResponse["access_token"])
at
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:79)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:555)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:708)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1159)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:315)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:121)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:1179)
[jackson-databind-2.2.1.jar:2.2.1]
at
com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:635)
[jackson-databind-2.2.1.jar:2.2.1]
at
org.jboss.resteasy.plugins.providers.jackson.ResteasyJackson2Provider.readFrom(ResteasyJackson2Provider.java:120)
[resteasy-jackson2-provider-3.0-beta-5.jar:]
at
org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:45)
[resteasy-jaxrs-3.0-beta-5.jar:]
at
org.jboss.resteasy.security.doseta.DigitalVerificationInterceptor.aroundReadFrom(DigitalVerificationInterceptor.java:32)
at
org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:48)
[resteasy-jaxrs-3.0-beta-5.jar:]
at
org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
[resteasy-jaxrs-3.0-beta-5.jar:]
at
org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:48)
[resteasy-jaxrs-3.0-beta-5.jar:]
at
org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:191)
[resteasy-client-3.0-beta-5.jar:]
... 17 more
I have written a custom JacksonJsonProvider and ObjectMapper context
resolver as follows:
@Provider
@Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard"
JSON variants
@Produces(MediaType.WILDCARD)
public class CustomJacksonJsonProvider extends JacksonJsonProvider {
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private Logger log = Logger.getLogger( this.getClass() );
public CustomJacksonJsonProvider(){
super();
try {
_mapperConfig.setMapper( new ObjectMapper()
.registerModule( new Hibernate4Module().configure(
Hibernate4Module.Feature.FORCE_LAZY_LOADING, false ) )
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,
false)
.configure(MapperFeature.USE_ANNOTATIONS, true)
.configure(MapperFeature.AUTO_DETECT_FIELDS, false)
.setDateFormat(new SimpleDateFormat(DATE_FORMAT)));
log.info( "FooBar API CustomJacksonJsonProvider initialized successfully"
);
} catch (Exception e) {
e.printStackTrace();
log.error( "FooBar API CustomJacksonJsonProvider initialization failed" );
}
}
@Override
public boolean isReadable(Class<?> aClass, Type type,
Annotation[] annotations, MediaType mediaType) {
if (FindAnnotation.findAnnotation(aClass, annotations, NoJackson.class) !=
null)
return false;
return super.isReadable(aClass, type, annotations, mediaType);
}
@Override
public boolean isWriteable(Class<?> aClass, Type type,
Annotation[] annotations, MediaType mediaType) {
if (FindAnnotation.findAnnotation(aClass, annotations, NoJackson.class) !=
null)
return false;
return super.isWriteable(aClass, type, annotations, mediaType);
}
@Override
public void writeTo(Object value, Class<?> type, Type genericType,
Annotation[] annotations, MediaType mediaType,
MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)
throws IOException, WebApplicationException {
super.writeTo(value, type, genericType, annotations, mediaType,
httpHeaders, entityStream);
}
}
@Provider
public class CustomObjectMapperProvider implements
ContextResolver<ObjectMapper> {
private ObjectMapper mapper;
public static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
private Logger log = Logger.getLogger( this.getClass() );
public CustomObjectMapperProvider() throws Exception {
this.mapper = new ObjectMapper();
mapper.registerModule( new Hibernate4Module().configure(
Hibernate4Module.Feature.FORCE_LAZY_LOADING, false ) );
mapper.setDateFormat( new SimpleDateFormat(DATE_FORMAT) );
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setSerializationInclusion( Include.NON_NULL);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
mapper.configure( MapperFeature.AUTO_DETECT_FIELDS, true );
mapper.setAnnotationIntrospector( new JacksonAnnotationIntrospector() );
log.info( "FooBar API CustomObjectMapperProvider initialized successfully"
);
}
public ObjectMapper getContext(Class<?> objectType) {
log.info( "getMapper called" );
return mapper;
}
}
But it seems my ObjectMapper context resolver isn't being called when an
object mapper is needed.
By the way, the source for the POJO involved in the exception can be found
here:
https://github.com/resteasy/Resteasy/blob/master/jaxrs/security/skeleton-key-idm/skeleton-key-core/src/main/java/org/jboss/resteasy/skeleton/key/representations/AccessTokenResponse.java
Any help would be greatly appreciated.
Thanks.
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_may
_______________________________________________
Resteasy-users mailing list
Resteasy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/resteasy-users