6.1.1 JSON error with REST authn after update

552 views
Skip to first unread message

Alex.B.

unread,
Oct 31, 2019, 1:52:52 PM10/31/19
to CAS Community
Hi,

We updated CAS from 5.3.14 to 6.1.1 and the REST authn doesn't work anymore. Nothing changed on the rest service side (the same JSON is returned to CAS).

We get this error :

2019-10-31 11:27:34,293 ERROR [org.apereo.cas.authentication.PolicyBasedAuthenticationManager] - <[service_name]: [Error while extracting response for type [class org.apereo.cas.authentication.principal.SimplePrincipal] and content type [application/json;charset=UTF-8]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token
 at [Source: (PushbackInputStream); line: 1, column: 104] (through reference chain: org.apereo.cas.authentication.principal.SimplePrincipal["attributes"]->java.util.LinkedHashMap["mail"]) / JSON parse error: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token
 at [Source: (PushbackInputStream); line: 1, column: 104] (through reference chain: org.apereo.cas.authentication.principal.SimplePrincipal["attributes"]->java.util.LinkedHashMap["mail"])]>


cas.properties :

cas.authn.rest.uri=https://service_uri
cas.authn.rest.name=service_name

This is an example of the JSON we are receiving from the REST service :

{ "@class": "org.apereo.cas.authentication.principal.SimplePrincipal", "id": "TEST01", "attributes": { "eduPersonAffiliation": ["employee", "member"], "bciCodeEtablissement": "123456", "bciMatricule": "NULL_VALUE", "mail": "test...@test.com", "sn": "Test", "givenName": "Test", "displayName": "test Test", "isMemberOf": ["na...@test.com", "registra...@test.com", "abc-scien...@test.com", "klm-etude...@test.com", "klm-etude...@test.com", "klm-prap...@test.com", "klm.sans...@test.com"] } }

Thank you for your help!

Alex.

Andy Ng

unread,
Nov 1, 2019, 12:38:48 AM11/1/19
to CAS Community
Bump, 

Since I also observed same error while testing JSON white list (https://apereo.github.io/cas/6.1.x/installation/Whitelist-Authentication.html#json-file) on CAS 6.1.x:


 parse error: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of `java.util.ArrayList<java.lang.Object>` out of VALUE_STRING token

Seems like is a bug in parsing JSON array...

Andy


Chris M.

unread,
Nov 4, 2019, 11:29:06 AM11/4/19
to CAS Community
Hello!

We have the same problem as Alex here.

Thanks!
{ "@class": "org.apereo.cas.authentication.principal.SimplePrincipal", "id": "TEST01", "attributes": { "eduPersonAffiliation": ["employee", "member"], "bciCodeEtablissement": "123456", "bciMatricule": "NULL_VALUE", "mail": "test...@test.com", "sn": "Test", "givenName": "Test", "displayName": "test Test", "isMemberOf": ["na...@test.com", "registr...@test.com", "abc-scien...@test.com", "klm-etude...@test.com", "klm-etude...@test.com", "klm-prap...@test.com", "klm.sans...@test.com"] } }

Andy Ng

unread,
Nov 4, 2019, 8:25:09 PM11/4/19
to CAS Community
Hi all,

Still don't know how to fix it, but I found something here:

SimplePrincipal attribute is:
private Map<String, Object> attributes = new HashMap<>();


SimplePrincipal attribute is:
private Map<String, List<Object>> attributes = new HashMap<>();


Maybe this is related to the bug we encountered here?

- Andy



Nono

unread,
Mar 29, 2020, 12:41:05 PM3/29/20
to CAS Community
Hello guys,

i think i have found a sollution (not elegant) :

- in the war overlay you create this class : java/org/apereo/cas/config/CasRestAuthenticationConfiguration.java
- you copy paste the original code for github
- in the MAPPER object definition you add the following line :
.configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);

The empty value will be converted to null => juste make sure null value is not problem in the rest of the code.

Hope this help

Nono

unread,
Mar 29, 2020, 12:41:53 PM3/29/20
to CAS Community
The authentication works again with this btw
Reply all
Reply to author
Forward
0 new messages