feat(jans-auth): add type prefixes to each keys which application stores in cache (original) (raw)

The value jansId = "test", jansClaim=[test, test2, ...] in jansClaim table can led to exception:

java.lang.ClassCastException: class io.jans.as.persistence.model.Scope cannot be cast to class io.jans.model.JansAttribute (io.jans.as.persistence.model.Scope and io.jans.model.JansAttribute are in unnamed module of loader org.eclipse.jetty.ee9.webapp.WebAppClassLoader @6b7d1df8)
    at io.jans.as.common.service.AttributeService.getAttributeByDn(AttributeService.java:46) ~[jans-auth-common-0.0.0-nightly.jar:?]
    at io.jans.as.server.service.AttributeService$Proxy$_$$_WeldClientProxy.getAttributeByDn(Unknown Source) ~[classes/:?]
    at io.jans.as.server.service.ScopeService.fillClaims(ScopeService.java:271) ~[classes/:?]
    at io.jans.as.server.service.ScopeService.getClaims(ScopeService.java:264) ~[classes/:?]

The problematic place which put value into cache is there.

We need to add prefixes to each keys which we put into cache. Example: $_SCOPE_$test=value
Also we need to check other places in code to protect against similar data issues.